Skip to content

Commit 018dfae

Browse files
committed
suggestions
1 parent 31a4498 commit 018dfae

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

src/SPC/builder/Extension.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
use SPC\exception\WrongUsageException;
1111
use SPC\store\Config;
1212
use SPC\store\FileSystem;
13-
use SPC\toolchain\ToolchainManager;
14-
use SPC\toolchain\ZigToolchain;
1513
use SPC\util\SPCConfigUtil;
1614
use SPC\util\SPCTarget;
1715

@@ -429,17 +427,13 @@ public function buildUnixShared(): void
429427
logger()->info("Extension [{$this->getName()}] patched before shared configure");
430428
}
431429

432-
$has_avx512 = str_contains($this->builder->arch_c_flags ?? '', '-mavx512') ||
433-
str_contains($this->arch_c_flags ?? '', '-march=x86-64-v4') ||
434-
ToolchainManager::getToolchainClass() !== ZigToolchain::class;
435-
436430
shell()->cd($this->source_dir)
437431
->setEnv($env)
438432
->appendEnv($this->getExtraEnv())
439433
->exec(
440434
'./configure ' . $this->getUnixConfigureArg(true) .
441435
' --with-php-config=' . BUILD_BIN_PATH . '/php-config ' .
442-
'--enable-shared --disable-static' . (!$has_avx512 ? ' php_cv_have_avx512=no php_cv_have_avx512vbmi=no' : '')
436+
'--enable-shared --disable-static ' . getenv('SPC_EXTRA_PHP_VARS')
443437
);
444438

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

src/SPC/builder/linux/LinuxBuilder.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
use SPC\exception\WrongUsageException;
1010
use SPC\store\FileSystem;
1111
use SPC\store\SourcePatcher;
12-
use SPC\toolchain\ToolchainManager;
13-
use SPC\toolchain\ZigToolchain;
1412
use SPC\util\GlobalEnvManager;
1513
use SPC\util\SPCConfigUtil;
1614
use SPC\util\SPCTarget;
@@ -105,10 +103,6 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
105103
);
106104
}
107105

108-
$has_avx512 = str_contains($this->arch_c_flags, '-mavx512') ||
109-
str_contains($this->arch_c_flags, '-march=x86-64-v4') ||
110-
ToolchainManager::getToolchainClass() !== ZigToolchain::class;
111-
112106
$this->seekPhpSrcLogFileOnException(fn () => shell()->cd(SOURCE_PATH . '/php-src')->exec(
113107
$php_configure_env . ' ' .
114108
getenv('SPC_CMD_PREFIX_PHP_CONFIGURE') . ' ' .
@@ -122,7 +116,7 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
122116
$json_74 .
123117
$zts .
124118
$maxExecutionTimers .
125-
(!$has_avx512 ? 'php_cv_have_avx512=no php_cv_have_avx512vbmi=no ' : '') .
119+
getenv('SPC_EXTRA_PHP_VARS') . ' ' .
126120
$this->makeStaticExtensionArgs() . ' '
127121
));
128122

src/SPC/toolchain/ZigToolchain.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ public function afterInit(): void
6464
$extra_libs = trim($extra_libs . ' -lunwind');
6565
GlobalEnvManager::putenv("SPC_EXTRA_LIBS={$extra_libs}");
6666
}
67+
$cflags = getenv('SPC_DEFAULT_C_FLAGS') ?: getenv('CFLAGS') ?: '';
68+
$has_avx512 = str_contains($cflags, '-mavx512') || str_contains($cflags, '-march=x86-64-v4');
69+
if (!$has_avx512) {
70+
f_putenv('SPC_EXTRA_PHP_VARS=php_cv_have_avx512=no php_cv_have_avx512vbmi=no');
71+
}
6772
}
6873

6974
public function getCompilerInfo(): ?string

0 commit comments

Comments
 (0)