r/programming • • Oct 22 '26

examining the macOS gcc binary

https://zoey-on-github.github.io/blog/macgcc.html
75 Upvotes

4 comments sorted by

View all comments

12

u/chucker23n Oct 23 '26

if you’re wondering why this is, my guess is because of SIP.

That may be a factor, but the main point is that Xcode is designed to be self-contained. You can use xcode-select to switch to a "main" toolchain, which anything like gcc or xcrun will then point to. Thus, you can install beta versions, older versions, etc. of Xcode side-by-side, or install the command-line-only tools instead of Xcode, and everything will just point there instead.

I.e., xcode-select and xcrun d disambiguation

See also the manpages:

xcode-select controls the location of the developer directory used
by xcrun(1), xcodebuild(1), cc(1), and other Xcode and BSD
development tools. This also controls the locations that are searched
for by man(1) for developer tool manpages.

This allows you to easily switch between different versions of the
Xcode tools and can be used to update the path to the Xcode if it
is moved after installation.

And:

xcrun provides a means to locate or invoke developer tools from
the command-line, without requiring users to modify Makefiles or
otherwise take inconvenient measures to support multiple Xcode tool
chains.

(xcrun goes further and disambiguates different SDK versions.)