Repository navigation
Description
Summary
On an Intel Mac with Homebrew installed in /usr/local (the default Homebrew prefix on x86_64), libraries built with UnixCMakeExecutor are compiled against Homebrew's headers in /usr/local/include instead of the headers that spc installed in buildroot/include.
In my build, curl, libssh2 and librabbitmq were compiled with the headers of Homebrew's OpenSSL 4.1.0 while being linked against spc's OpenSSL 3.6.5. libssh2 and librabbitmq are reported as "Built package" successfully: the header/library mismatch is silent. It only surfaced because curl failed to link (_ASN1_STRING_get_length undefined: curl only defines its fallback when OPENSSL_VERSION_NUMBER < 0x40100000L, and it saw the 4.1 headers).
Apple Silicon builds are not affected in practice because Homebrew lives in /opt/homebrew, which is not a default compiler search path.
Environment
- static-php-cli: branch
v3, commit3ba9ffa0593b94202b48d6dde51e489191ecdbf1, run from source (php bin/spc, Composer--no-dev),spc --version: 3.0.0-alpha1 - Driven by FrankenPHP
build-static.sh/craft.ymlat tag v1.13.5 (commita3663e9e2cc4c258018a28ee068e50cc12f3ed2d),PHP_VERSION=8.5.12, default extension list of thatcraft.yml - macOS 26.7.1 (25G241), Intel x86_64
- Xcode Command Line Tools 26.6, Apple clang 21.0.0 (clang-2100.1.1.101), cctools / ld 1267, CMake 4.4.4
- Toolchain: default (
ClangNativeToolchain,SPC_USE_LLVMunset) - Homebrew in
/usr/local, with (among others)openssl@44.1.0,openssl@33.5.9,nghttp2,libnghttp3,libngtcp2,libssh2,brotli,zstdinstalled, so/usr/local/includecontainsopenssl/,nghttp2/,nghttp3/,ngtcp2/,libssh2*.h,brotli/,zstd*.h - No
CPATH,C_INCLUDE_PATH,LIBRARY_PATH,CFLAGSorCPPFLAGSset in the environment
Steps to reproduce
- On an Intel Mac, install Homebrew in
/usr/localandbrew install openssl@4(any formula that puts OpenSSL headers in/usr/local/include). - Build FrankenPHP's static binary with spc from source:
PHP_VERSION=8.5.12 FRANKENPHP_VERSION=1.13.5 ./build-static.sh(withdist/spcpointing tophp <static-php-cli>/bin/spc). - The build fails while linking the
curlexecutable:
Undefined symbols for architecture x86_64:
"_ASN1_STRING_get_length", referenced from:
_Curl_ossl_check_peer_cert in libcurl.a[157](openssl.c.o)
ld: symbol(s) not found for architecture x86_64
- The dependency file of that object shows where the headers came from:
$ grep -o '[^ ]*openssl/opensslv.h' \
<build-dir>/dist/source/curl/build/lib/CMakeFiles/libcurl_static.dir/vtls/openssl.c.o.d
/usr/local/include/openssl/opensslv.h
Root cause (as far as I can tell)
For curl, CMake receives the buildroot include directory from the imported targets / pkg-config results and emits it as -isystem <buildroot>/include (the same directory is also in CMAKE_C_FLAGS as -I, but clang treats a directory given both ways as a system directory). Apple clang searches /usr/local/include before the -isystem directories:
$ clang -E -v <same C_INCLUDES and C_FLAGS as curl> test.c
#include <...> search starts here:
<build-dir>/dist/source/curl/include
<build-dir>/dist/source/curl/build/lib
<build-dir>/dist/source/curl/lib
/usr/local/include <-- Homebrew, searched first
<build-dir>/dist/buildroot/include <-- spc's OpenSSL 3.6.5
/Library/Developer/CommandLineTools/usr/lib/clang/21/include
...
With the same flags, #include <openssl/opensslv.h> resolves to "OpenSSL 4.1.0 23 Oct 2026". Replacing -isystem <buildroot>/include with -I<buildroot>/include makes it resolve to "OpenSSL 3.6.5 29 Sep 2026".
How it was detected
After the failure I scanned every compiler dependency file produced during the build (*.d, *.Po, *.Plo under dist/source/) for paths under /usr/local/(include|opt|Cellar|lib)/:
$ find dist/source \( -name '*.d' -o -name '*.Po' -o -name '*.Plo' \) -print0 \
| xargs -0 grep -l -E '/usr/local/(include|opt|Cellar|lib)/' \
| cut -d/ -f3 | sort | uniq -c
110 curl
2 librabbitmq
26 libssh2
Headers pulled from /usr/local/include in those files: openssl/* (2076 references), nghttp2/* (214), libssh2*.h (212), ngtcp2/* (12), brotli/* (8), nghttp3/* (6), zstd*.h (4). All three affected libraries are built through UnixCMakeExecutor; no autoconf-built library showed up in the scan (note: autoconf steps that do not write dependency files are not covered by this check).
Suggested fix
- In
UnixCMakeExecutoron macOS (at least), pass-DCMAKE_NO_SYSTEM_FROM_IMPORTED=ONso that include directories of imported targets are emitted as-I(searched before/usr/local/include) instead of-isystem. Alternatively make sure<buildroot>/includeis passed with-Ionly, never with-isystem. - Consider also
-DCMAKE_SYSTEM_IGNORE_PREFIX_PATH=/usr/local(and/opt/homebrew,/opt/local) so thatfind_package/find_librarycannot pick Homebrew or MacPorts packages. - Optionally, a post-build check in
doctoror after each package (the scan above) would turn this silent contamination into a clear error.
Related, separate issue (same machine): empty libngtcp2_crypto_ossl.a
With cctools 1267, the libtool command used by ngtcp2 (ar cr .libs/libngtcp2_crypto_ossl.a <buildroot>/lib/libssl.a <buildroot>/lib/libcrypto.a <buildroot>/lib/libz.a ossl.o ../shared.o) produces an archive whose only member is __.SYMDEF SORTED (96 bytes) — ossl.o and shared.o are missing (ranlib: warning: archive member 'libssl.a' not a mach-o file). The existing workaround in src/Package/Library/ngtcp2.php (delete nested *.a members) then leaves an empty library, and curl fails to link (_ngtcp2_crypto_* undefined). ar cr test.a ossl.o ../shared.o works fine on the same machine.
A more robust workaround would be to rebuild the archive from the object files only, e.g. ar cr libngtcp2_crypto_ossl.a crypto/ossl/ossl.o crypto/shared.o && ranlib libngtcp2_crypto_ossl.a, or to pass OPENSSL_LIBS as -L… -lssl -lcrypto instead of .a paths so libtool does not put static archives into the archive. Happy to open a separate issue for this one if you prefer.
Activity
theluckystrike commentedon Nov 14, 2026
Root cause narrowed with a minimal cmake reproduction rather than a full build.
/usr/localis a prefix cmake searches ahead ofCMAKE_FIND_ROOT_PATH, and a target include dir resolved from a host prefix is placed ahead of the buildroot include on the compile line, which is why the existingCMAKE_C_STANDARD_INCLUDE_DIRECTORIESline does not save it.Patch up in #1290, one Darwin-only version-guarded
CMAKE_IGNORE_PREFIX_PATH "/usr/local", suite green at 472 tests. Honest caveat, I have no Intel macOS host, so the end to end build is unconfirmed on the reporting machine even though the lookup mechanism and the flip are.fix(cmake): ignore /usr/local prefix on Darwin so host headers cannot…