Skip to content

Commit 74fe85a

Browse files
Claudecrazywhalecc
andauthored
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>
1 parent 51d7d60 commit 74fe85a

2 files changed

Lines changed: 27 additions & 4 deletions

File tree

src/SPC/builder/Extension.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,15 +434,26 @@ public function buildUnixShared(): void
434434
logger()->info("Extension [{$this->getName()}] patched before shared configure");
435435
}
436436

437+
// Parse and add SPC_EXTRA_PHP_VARS as environment variables
437438
$phpvars = getenv('SPC_EXTRA_PHP_VARS') ?: '';
439+
if ($phpvars !== '') {
440+
// Parse space-separated key=value pairs
441+
$parts = preg_split('/\s+/', trim($phpvars), -1, PREG_SPLIT_NO_EMPTY);
442+
foreach ($parts as $part) {
443+
if (str_contains($part, '=')) {
444+
[$key, $value] = explode('=', $part, 2);
445+
$env[$key] = $value;
446+
}
447+
}
448+
}
438449

439450
shell()->cd($this->source_dir)
440451
->setEnv($env)
441452
->appendEnv($this->getExtraEnv())
442453
->exec(
443454
'./configure ' . $this->getUnixConfigureArg(true) .
444455
' --with-php-config=' . BUILD_BIN_PATH . '/php-config ' .
445-
"--enable-shared --disable-static {$phpvars}"
456+
'--enable-shared --disable-static'
446457
);
447458

448459
if ($this->patchBeforeSharedMake()) {

src/SPC/builder/linux/LinuxBuilder.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,27 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
9393

9494
// prepare build php envs
9595
// $musl_flag = SPCTarget::getLibc() === 'musl' ? ' -D__MUSL__' : ' -U__MUSL__';
96-
$php_configure_env = SystemUtil::makeEnvVarString([
96+
$env_vars = [
9797
'CFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'),
9898
'CPPFLAGS' => '-I' . BUILD_INCLUDE_PATH, // . ' -Dsomethinghere', // . $musl_flag,
9999
'LDFLAGS' => '-L' . BUILD_LIB_PATH,
100100
// 'LIBS' => SPCTarget::getRuntimeLibs(), // do not pass static libraries here yet, they may contain polyfills for libc functions!
101-
]);
101+
];
102102

103+
// Parse and add SPC_EXTRA_PHP_VARS as environment variables
103104
$phpvars = getenv('SPC_EXTRA_PHP_VARS') ?: '';
105+
if ($phpvars !== '') {
106+
// Parse space-separated key=value pairs
107+
$parts = preg_split('/\s+/', trim($phpvars), -1, PREG_SPLIT_NO_EMPTY);
108+
foreach ($parts as $part) {
109+
if (str_contains($part, '=')) {
110+
[$key, $value] = explode('=', $part, 2);
111+
$env_vars[$key] = $value;
112+
}
113+
}
114+
}
115+
116+
$php_configure_env = SystemUtil::makeEnvVarString($env_vars);
104117

105118
$embed_type = getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') ?: 'static';
106119
if ($embed_type !== 'static' && SPCTarget::isStatic()) {
@@ -123,7 +136,6 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
123136
$json_74 .
124137
$zts .
125138
$maxExecutionTimers .
126-
$phpvars . ' ' .
127139
$this->makeStaticExtensionArgs() . ' '
128140
));
129141

0 commit comments

Comments
 (0)