-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix SDK issues on Mojave and High Sierra #7134
Conversation
Does this mean the The PR changes here make sense to me. What do they mean for current formulae workarounds? Are they no longer necessary and can be removed? Will they break stuff until they are changed? Basically: agree with the code as-is here but just have questions about rollout and formula changes. Thanks again @Bo98! |
Sorry, I mean invoking system
Yes.
No. The workarounds are overriding what we are changing here. They just will have nil effect after this change as they will be overwriting |
Ok, cool.
How about we just manually set the SDKROOT in the
🎉 |
Yeah that seems like the best idea. There's currently workarounds in about 2-3, but that just means 2-3 have been updated since October. I'll keep an eye out and see if that number increases. |
Nice work again @Bo98! Reminder to wait for a new tag before merging any PRs removing these workarounds 🎉. |
brew style
with your changes locally?brew tests
with your changes locally?The amount of workarounds is getting ridiculous. Time to tackle the core of the problem.
Mojave (and likely Catalina come Xcode 12)
After the removal of
/usr/include
, Apple directed people to use the SDK. However by default, Homebrew uses the latest SDK. This is wrong when dealing with system headers.For example, Git compiled against the system curl headers. On Mojave under Xcode 11, Homebrew would pick the 10.15 SDK. These curl headers are newer so the
LIBCURL_VERSION_NUM
was higher. This triggered Git to enable some features only available on newer curl. This compiled fine, but would fail at runtime because Mojave's curl library doesn't support the features Git was trying to use.Instead I changed it so to always prioritise matching the SDK with the OS version. In the event this is not found (which is the case for 10.10-10.13), then the
rescue BaseSDKLocator::NoSDKError
covers that already and returns the latest SDK.However, this doesn't quite solve the problem under all setups.
Xcode 11 on Mojave does NOT ship with the 10.14 SDK - only the CLT does. Because we prioritise Xcode SDK searching over the CLT, it will never find the 10.14 SDK. I've changed it now to search the CLT first. This is a notable change, but I can't see any reason why it would be problematic on older systems.
These changes also fixes significant GCC issues. GCC is compiled with various patches to the SDK. This does not work if the SDK used does not match what it was compiled with. We currently compile with the SDK matching the OS as it causes the least issues for those using GCC outside of the Homebrew environment, and actually matches the behaviour of Clang.
There is one outstanding issue: Ruby. This is arguably an Apple bug.
gem
does not work unlessSDKROOT
is set to the correct SDK matching the OS. We no longer set SDKROT in the superenv as of mid-2018. That was an area that I wanted to avoid touching as it certainly seems like something that could potentially trigger issues with a few formulae. I'm not sure of a nice way to solve this unless we made agem
shim or something.High Sierra
Additionally, there were a few issues on High Sierra, albeit less frequent. This was caused by the logic of
MacOS::CLT.separate_header_package?
. The naming is somewhat legacy as the "separate header package" was just some compatibilty crossover period and is no longer supplied. What this really was being used for was to see whether/usr/include
existed - and thus affect whether the-isysroot
would be set to the SDK or not. If it was false and the CLT was installed, no SDK would be inserted.This check was erroneous on High Sierra with CLT 10 installed. The check compared whether the CLT was version >= 10, but did not consider the fact that the system header situation only applies to Mojave and not High Sierra. This meant that both
/usr/include
and the equivalent in the 10.14 SDK was in the search path. Usually,/usr/include
takes priority but there was some cases where the SDK was used.The fix was to correct
MacOS::CLT.separate_header_package?
to also consider the OS version.