Skip to content

Find the macOS SDK when only the Command Line Tools are installed - #2614

Open
iurisilvio wants to merge 1 commit into
Automattic:masterfrom
iurisilvio:macos-sdk-command-line-tools
Open

Find the macOS SDK when only the Command Line Tools are installed#2614
iurisilvio wants to merge 1 commit into
Automattic:masterfrom
iurisilvio:macos-sdk-command-line-tools

Conversation

@iurisilvio

@iurisilvio iurisilvio commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Building on a Mac without a full Xcode fails at the link step, after compiling every dependency:

error: warning: unable to open library directory
'/Library/Developer/CommandLineTools/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.sdk/usr/lib': FileNotFound

Platforms/MacOSX.platform/Developer/SDKs/ only exists inside an Xcode installation. With the Command Line Tools selected, xcode-select --print-path returns /Library/Developer/CommandLineTools and the SDKs sit directly under SDKs/.

Changes

Ask xcrun --show-sdk-path for the SDK, which answers for either layout. That also retires the xcode-select call, which only existed to build the pinned path.

The pinned MacOSX15.sdk was not holding the build to that SDK to begin with — zig resolves the SDK for the link itself, and the paths added here only supplement it:

same native build     probing for MacOSX15.sdk     minos 26.6.1   sdk 26.5
                      xcrun --show-sdk-path only   minos 26.6.1   sdk 26.5

What a binary runs on comes from the target, not from this block. With the triple publish.yaml passes:

$ zig build -Dtarget=aarch64-macos -Doptimize=ReleaseFast
    minos 13.0    sdk 26.4

One real difference: the old -isystem had compilation pull headers from the 15 SDK, so FontManagerMacos.cc now compiles against the newest installed one instead. At minos 13.0, anything introduced after 13.0 is weak-linked and clang warns if it is called unguarded — nothing the current CoreText usage goes near, but it is the actual behavioral change between the two versions.

Verification

macOS 26 arm64, Command Line Tools only (no Xcode), zig 0.16.0: zig build succeeds and the full suite passes (305 tests).

  • Have you updated CHANGELOG.md? — no user-visible change

Comment thread build.zig
break candidate;
} else std.mem.trim(
u8,
b.run(&.{ "xcrun", "--show-sdk-path" }),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like it would be super simple to only rely on this command rather than checking predefined directories. Does that work for you?

I did a little reading and it doesn't seem like using the latest SDK breaks compatibility with old macOS. Backward compatibility for macOS binaries is specified by a zig target like "x86_64-macos.10.15-none", which is the equivalent of the clang arg "-mmacos-version-min".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you're right! Thank you! I cleaned up the code, works for me and I agree it is backward compatible.

@iurisilvio
iurisilvio force-pushed the macos-sdk-command-line-tools branch from 6c18a1c to 972fddb Compare August 24, 2026 08:22
The SDK path was built as `xcode-select --print-path` plus
`Platforms/MacOSX.platform/Developer/SDKs/`, which only exists inside a full
Xcode. With the Command Line Tools selected the SDKs sit directly under
`SDKs/`, so the link step failed with

    warning: unable to open library directory
    '/Library/Developer/CommandLineTools/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.sdk/usr/lib'

after compiling everything.

Ask xcrun for the SDK instead, which answers for either layout.

The pinned MacOSX15.sdk was not holding the build to that SDK to begin with:
zig resolves the SDK for the link itself and the paths added here only
supplement it, so a native build recorded `sdk 26.5` with or without the pin.
What a binary runs on comes from the target -- `-Dtarget=aarch64-macos`, which
is what publish.yaml passes, gives `minos 13.0` -- and not from here.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@iurisilvio
iurisilvio force-pushed the macos-sdk-command-line-tools branch from 972fddb to cc0c9de Compare August 24, 2026 08:25
@iurisilvio

Copy link
Copy Markdown
Contributor Author

I don't think the Windows failure is related to this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants