macOS: update defaults not unwrap /usr/bin/{cc,c++} and not use -isysroot
On macOS we currently resolve /usr/bin/{cc,c++}
to whatever xcrun
says they use underneath (see commit 1f085e11). The idea is that those real compiler paths remain stable even if xcode-select
is used to change the default. This has the effect of making -isysroot
required for normal builds, which has not been problematic on its own because we've long required CMAKE_OSX_SYSROOT
to be set anyway. At one time even /usr/bin/{cc,c++}
required -isysroot
, which is why CMAKE_OSX_SYSROOT
is always used.
Discussion in issues #19120 (closed) and #19134 (closed) identified that using -isysroot
causes paths under /usr/local
to no longer be considered system directories. This differs from the normal behavior of /usr/bin/{cc,c++}
when run by hand.
Since -isysroot
is no longer required by /usr/bin/{cc,c++}
we should consider changing our defaults back to using those compilers directly and not using -isysroot
unless CMAKE_OSX_SYSROOT
is explicitly set by the user.
Achieving this will also mean we can no longer resolve /usr/bin/{cc,c++}
to the underlying compiler paths, meaning that we will require users to keep DEVELOPER_DIR
stable across all uses of /usr/bin/{cc,c++}
in a given build tree. Since our Makefile and Ninja generators require a stable environment anyway that is not a big deal.