From bb80c97b9c592e514b164e112f25c3d80777285b Mon Sep 17 00:00:00 2001 From: theluckystrike <51033404+theluckystrike@users.noreply.github.com> Date: Sat, 14 Nov 2026 16:23:58 +0700 Subject: [PATCH] fix(cmake): ignore /usr/local prefix on Darwin so host headers cannot 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 #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. --- src/StaticPHP/Runtime/Executor/UnixCMakeExecutor.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/StaticPHP/Runtime/Executor/UnixCMakeExecutor.php b/src/StaticPHP/Runtime/Executor/UnixCMakeExecutor.php index 25fef98d1..87b33b270 100644 --- a/src/StaticPHP/Runtime/Executor/UnixCMakeExecutor.php +++ b/src/StaticPHP/Runtime/Executor/UnixCMakeExecutor.php @@ -325,6 +325,13 @@ private function makeCmakeToolchainFile(): string $toolchain .= "\nset(CMAKE_CXX_STANDARD_LIBRARIES_INIT \"{$runtimeLibs}\")"; } } + // Homebrew on Intel macOS installs into /usr/local, which sits on the compiler's + // default search path, so find_* resolves host headers ahead of the ones spc + // installed in buildroot and packages end up compiled against them (issue #1289). + // Ignoring the prefix keeps cmake's searches inside the buildroot on Darwin. + if (PHP_OS_FAMILY === 'Darwin') { + $toolchain .= "\nif(CMAKE_VERSION VERSION_GREATER_EQUAL 3.23)\n set(CMAKE_IGNORE_PREFIX_PATH \"/usr/local\")\nendif()"; + } FileSystem::writeFile(SOURCE_PATH . '/toolchain.cmake', $toolchain); return $created = realpath(SOURCE_PATH . '/toolchain.cmake'); }