macos: improved SDK detection and linker integration with _mh_execute_header #10226
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If Zig didn't detect native SDK, always use shipped libc headers when targeting macOS.Fixes #10217cc @slimsagEDIT: Turns out this PR leads naturally to a fix of another long-standing issue, so I've now converged the two, one on top of the other.
Changes / fixes:
LC_BUILD_VERSION
load commandLC_BUILD_VERSION
load command - Apple strips off patch info from platform and SDK version info - without this, non-Zig tools may complain that the there's a mismatch between OS and platform as reported in creating dynamic libraries targeting macosx results in unusable .dylib files #1982__mh_execute_header
as a linker synthetic global symbol - fixes creating dynamic libraries targeting macosx results in unusable .dylib files #1982std.zig.system.darwin.isDarwinSDKInstalled
which checks for the presence of the SDK tooling without triggering the CLT installation popup - I believe this is a much better UX on a bare macOS systemcc @andrewrk @slimsag