-
-
Notifications
You must be signed in to change notification settings - Fork 22.1k
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 regular macOS build by passing -isysroot to compiler so correct system headers are found #21339
Conversation
Nobody else seems to report such issues building on macOS, so it would be better to diagnose why it's not working on your system when it works for others. If we can avoid hardcoding such paths, that's better. CC @bruvzg |
Well it's semi-hardcoding. The same is done in the iphone/detect.py file. The highest NSAppKitVersionNumber defined for me in And the highest one in is
A wild assumption is that because my mac initially came with 10.11 installed, and then I updated to 10.12, for some reason the headers files in /System/Library/Frameworks/ were not updated. To be fair I'm not sure why appkit headers are shipped in both the xcode sdk and in the root. |
I'm using macOS 10.13.6 and can't check whats going on 10.12, but Xcode can be installed anywhere outside of Setting |
Looks like Same with I am not particularly experienced with scons, but other build systems like cmake, qmake specify an isysroot by default. |
Same can be used with
|
Another way to fix the issue would be to add
|
Besides checking if (@available(macOS 10.12, *)) {
// macOS 10.12 or later code path
} else {
// code for earlier than 10.12
} |
Previously the compiler would use system headers located at /System/Library/Frameworks, which could result in compilation failures due to the headers not always being up-to-date in regards to the latest installed macOS SDK headers that come with Xcode. Fix the issue by passing the SDK path via the -isysroot option to the compiler and linker invocations. If no custom SDK path is given, the build system queries the SDK path via xcrun --show-sdk-path, which returns something similar to /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/ /Developer/SDKs/MacOSX.sdk/ Querying via xcrun is now also done for iphone (and simulator) platforms as well. Here is an example of a compilation failure message due to outdated headers: platform/osx/os_osx.mm:1421:41: error: use of undeclared identifier 'NSAppKitVersionNumber10_12'; did you mean 'NSAppKitVersionNumber'? if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_12) { ^~~~~~~~~~~~~~~~~~~~~~~~~~ NSAppKitVersionNumber /System/Library/Frameworks/AppKit.framework/Headers/NSApplication.h:26:28: note: 'NSAppKitVersionNumber' declared here
Updated PR to query macOS / iOS / Simulator SDK path via xcrun, and pass the result as -isysroot. |
The original issue is fixed by #23822, so this should no longer be needed. Thanks for the proposal nevertheless! |
It's still a good idea to select correct SDK, even if it's building without error, default SDK may cause problems.
|
Ok, merging then :) |
Hi.
I tried building master branch of Godot, and failed due to a compilation issue.
Here is the invocation and error message:
This is on macOS 10.12.6, XCode Version 9.2 (9C40b)
It seems that the headers found in Appkit.framework under /System/Library/Frameworks/ are not up-to-date with respect with what is present in the SDK that comes with Xcode.
My pull request fixes that by passing -isysroot to point to the Xcode SDK.
This allows me to build successfully on my machine.
Thought it might make sense to fix it upstream as well.