Skip to content

Commit 897cb00

Browse files
committed
Use failsafe for SPC_EXTRA_PHP_VARS
1 parent 018dfae commit 897cb00

4 files changed

Lines changed: 8 additions & 3 deletions

File tree

config/env.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
; SPC_LINUX_DEFAULT_CC: the default compiler for linux. (For alpine linux: `gcc`, default: `$GNU_ARCH-linux-musl-gcc`)
3535
; SPC_LINUX_DEFAULT_CXX: the default c++ compiler for linux. (For alpine linux: `g++`, default: `$GNU_ARCH-linux-musl-g++`)
3636
; SPC_LINUX_DEFAULT_AR: the default archiver for linux. (For alpine linux: `ar`, default: `$GNU_ARCH-linux-musl-ar`)
37+
; SPC_EXTRA_PHP_VARS: the extra vars for building php, used in `configure` and `make` command.
3738

3839
[global]
3940
; Build concurrency for make -jN, default is CPU_COUNT, this value are used in every libs.

src/SPC/builder/Extension.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,13 +427,15 @@ public function buildUnixShared(): void
427427
logger()->info("Extension [{$this->getName()}] patched before shared configure");
428428
}
429429

430+
$phpvars = getenv('SPC_EXTRA_PHP_VARS') ?: '';
431+
430432
shell()->cd($this->source_dir)
431433
->setEnv($env)
432434
->appendEnv($this->getExtraEnv())
433435
->exec(
434436
'./configure ' . $this->getUnixConfigureArg(true) .
435437
' --with-php-config=' . BUILD_BIN_PATH . '/php-config ' .
436-
'--enable-shared --disable-static ' . getenv('SPC_EXTRA_PHP_VARS')
438+
"--enable-shared --disable-static {$phpvars}"
437439
);
438440

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

src/SPC/builder/linux/LinuxBuilder.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
9595
// 'LIBS' => SPCTarget::getRuntimeLibs(), // do not pass static libraries here yet, they may contain polyfills for libc functions!
9696
]);
9797

98+
$phpvars = getenv('SPC_EXTRA_PHP_VARS') ?: '';
99+
98100
$embed_type = getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') ?: 'static';
99101
if ($embed_type !== 'static' && SPCTarget::isStatic()) {
100102
throw new WrongUsageException(
@@ -116,7 +118,7 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
116118
$json_74 .
117119
$zts .
118120
$maxExecutionTimers .
119-
getenv('SPC_EXTRA_PHP_VARS') . ' ' .
121+
"{$phpvars} " .
120122
$this->makeStaticExtensionArgs() . ' '
121123
));
122124

src/SPC/toolchain/ZigToolchain.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function afterInit(): void
6767
$cflags = getenv('SPC_DEFAULT_C_FLAGS') ?: getenv('CFLAGS') ?: '';
6868
$has_avx512 = str_contains($cflags, '-mavx512') || str_contains($cflags, '-march=x86-64-v4');
6969
if (!$has_avx512) {
70-
f_putenv('SPC_EXTRA_PHP_VARS=php_cv_have_avx512=no php_cv_have_avx512vbmi=no');
70+
GlobalEnvManager::putenv('SPC_EXTRA_PHP_VARS=php_cv_have_avx512=no php_cv_have_avx512vbmi=no');
7171
}
7272
}
7373

0 commit comments

Comments
 (0)