Repository navigation
fix(cmake): ignore /usr/local prefix on Darwin so host headers cannot shadow buildroot - #1290
Merged
crazywhalecc merged 1 commit intoNov 14, 2026
Conversation
… shadow buildroot Homebrew on Intel macOS installs into /usr/local, which is on the compiler default search path. cmake then resolves headers and packages from the host instead of buildroot, so the static build compiles against Intel Homebrew headers and fails at link time (issue crazywhalecc#1289). CMAKE_IGNORE_PREFIX_PATH drops /usr/local from cmake's prefix searches on Darwin. Guarded on cmake 3.23+ so older cmake is unaffected.
henderkes
approved these changes
Nov 14, 2026
crazywhalecc
approved these changes
Nov 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
On Intel macOS the static build compiled against Homebrew headers from
/usr/localinstead of theheaders spc installed in buildroot, and then failed at link time. Reported in #1289.
Why
/usr/local/includeis on the compiler default search path, and/usr/localis also a prefix cmakesearches ahead of
CMAKE_FIND_ROOT_PATH. Sofind_path,find_libraryandfind_packagereturnedhost paths even though the buildroot include dir was passed through
CMAKE_C_STANDARD_INCLUDE_DIRECTORIES. A target include dir coming from a host prefix is placedahead of the buildroot one on the compile line, which is why the host header won.
Change
One guard in the generated toolchain file, Darwin only.
CMAKE_IGNORE_PREFIX_PATHremoves the prefix from cmake searches, so the lookups stay insidebuildroot. The version guard keeps cmake below 3.23 unchanged, and Linux and Windows behaviour is
untouched. Apple Silicon Homebrew lives in
/opt/homebrew, so it keeps working. Only/usr/localon Darwin is ignored.
Verification
A minimal cmake reproduction, no PHP build needed. A fake host prefix stands in for
/usr/local, andboth prefixes ship an
openssl/x.hthat reports its own origin.Without the guard cmake resolves the host header and the build compiles against it. With the guard
the host prefix is skipped and the buildroot header wins.
The existing suite, with the change applied, on macOS arm64 with PHP 8.5
Caveat, stated plainly. I could not run a full spc build on Intel macOS hardware, so the end to end
build fix is unconfirmed on the machine that reported #1289. What is confirmed is the cmake lookup
mechanism and that the guard flips it from host to buildroot.
Script used for the reproduction above.
Refs #1289