From 51d7d608414e778ce98d99a2773d56c6b3f60f4f Mon Sep 17 00:00:00 2001 From: "anthropic-code-agent[bot]" <242468646+Claude@users.noreply.github.com> Date: Mon, 20 Apr 2026 04:48:32 +0000 Subject: [PATCH 1/2] Initial plan From 74fe85a9b69ccfd7c4723c578db603330b945450 Mon Sep 17 00:00:00 2001 From: "anthropic-code-agent[bot]" <242468646+Claude@users.noreply.github.com> Date: Mon, 20 Apr 2026 04:53:03 +0000 Subject: [PATCH 2/2] Fix AVX512 cache variables not being recognized by configure The issue was that SPC_EXTRA_PHP_VARS (containing php_cv_have_avx512=no and php_cv_have_avx512vbmi=no) were being passed as command-line arguments to ./configure instead of as environment variables. This caused PHP's autoconf system to ignore the cached values and run AVX512 checks anyway. Changes: - LinuxBuilder.php: Parse SPC_EXTRA_PHP_VARS and add them to the environment variable array that's passed to configure - Extension.php: Apply the same fix for shared extension builds The variables are now properly set in the environment before configure runs, allowing PHP's autoconf cache system to recognize and use them. Agent-Logs-Url: https://github.com/crazywhalecc/static-php-cli/sessions/03f84520-e96c-4748-aa05-bfd98e26fed8 Co-authored-by: crazywhalecc <20330940+crazywhalecc@users.noreply.github.com> --- src/SPC/builder/Extension.php | 13 ++++++++++++- src/SPC/builder/linux/LinuxBuilder.php | 18 +++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 63dc31d04..4b5c8109f 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -434,7 +434,18 @@ public function buildUnixShared(): void logger()->info("Extension [{$this->getName()}] patched before shared configure"); } + // Parse and add SPC_EXTRA_PHP_VARS as environment variables $phpvars = getenv('SPC_EXTRA_PHP_VARS') ?: ''; + if ($phpvars !== '') { + // Parse space-separated key=value pairs + $parts = preg_split('/\s+/', trim($phpvars), -1, PREG_SPLIT_NO_EMPTY); + foreach ($parts as $part) { + if (str_contains($part, '=')) { + [$key, $value] = explode('=', $part, 2); + $env[$key] = $value; + } + } + } shell()->cd($this->source_dir) ->setEnv($env) @@ -442,7 +453,7 @@ public function buildUnixShared(): void ->exec( './configure ' . $this->getUnixConfigureArg(true) . ' --with-php-config=' . BUILD_BIN_PATH . '/php-config ' . - "--enable-shared --disable-static {$phpvars}" + '--enable-shared --disable-static' ); if ($this->patchBeforeSharedMake()) { diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index ed26d64f3..fc3c71621 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -93,14 +93,27 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void // prepare build php envs // $musl_flag = SPCTarget::getLibc() === 'musl' ? ' -D__MUSL__' : ' -U__MUSL__'; - $php_configure_env = SystemUtil::makeEnvVarString([ + $env_vars = [ 'CFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'), 'CPPFLAGS' => '-I' . BUILD_INCLUDE_PATH, // . ' -Dsomethinghere', // . $musl_flag, 'LDFLAGS' => '-L' . BUILD_LIB_PATH, // 'LIBS' => SPCTarget::getRuntimeLibs(), // do not pass static libraries here yet, they may contain polyfills for libc functions! - ]); + ]; + // Parse and add SPC_EXTRA_PHP_VARS as environment variables $phpvars = getenv('SPC_EXTRA_PHP_VARS') ?: ''; + if ($phpvars !== '') { + // Parse space-separated key=value pairs + $parts = preg_split('/\s+/', trim($phpvars), -1, PREG_SPLIT_NO_EMPTY); + foreach ($parts as $part) { + if (str_contains($part, '=')) { + [$key, $value] = explode('=', $part, 2); + $env_vars[$key] = $value; + } + } + } + + $php_configure_env = SystemUtil::makeEnvVarString($env_vars); $embed_type = getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') ?: 'static'; if ($embed_type !== 'static' && SPCTarget::isStatic()) { @@ -123,7 +136,6 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void $json_74 . $zts . $maxExecutionTimers . - $phpvars . ' ' . $this->makeStaticExtensionArgs() . ' ' ));