mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 04:44:53 +08:00
explicitly disable avx512 if zig and march not high enough
This commit is contained in:
parent
f7744188f4
commit
2d1a61d184
@ -10,6 +10,8 @@ use SPC\exception\ValidationException;
|
|||||||
use SPC\exception\WrongUsageException;
|
use SPC\exception\WrongUsageException;
|
||||||
use SPC\store\Config;
|
use SPC\store\Config;
|
||||||
use SPC\store\FileSystem;
|
use SPC\store\FileSystem;
|
||||||
|
use SPC\toolchain\ToolchainManager;
|
||||||
|
use SPC\toolchain\ZigToolchain;
|
||||||
use SPC\util\SPCConfigUtil;
|
use SPC\util\SPCConfigUtil;
|
||||||
use SPC\util\SPCTarget;
|
use SPC\util\SPCTarget;
|
||||||
|
|
||||||
@ -427,13 +429,18 @@ class Extension
|
|||||||
logger()->info("Extension [{$this->getName()}] patched before shared configure");
|
logger()->info("Extension [{$this->getName()}] patched before shared configure");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$has_avx512 = str_contains($this->builder->arch_c_flags ?? '', '-mavx512') ||
|
||||||
|
str_contains($this->builder->arch_c_flags ?? '', '-march=x86-64-v3') ||
|
||||||
|
str_contains($this->arch_c_flags ?? '', '-march=x86-64-v4') ||
|
||||||
|
ToolchainManager::getToolchainClass() !== ZigToolchain::class;
|
||||||
|
|
||||||
shell()->cd($this->source_dir)
|
shell()->cd($this->source_dir)
|
||||||
->setEnv($env)
|
->setEnv($env)
|
||||||
->appendEnv($this->getExtraEnv())
|
->appendEnv($this->getExtraEnv())
|
||||||
->exec(
|
->exec(
|
||||||
'./configure ' . $this->getUnixConfigureArg(true) .
|
'./configure ' . $this->getUnixConfigureArg(true) .
|
||||||
' --with-php-config=' . BUILD_BIN_PATH . '/php-config ' .
|
' --with-php-config=' . BUILD_BIN_PATH . '/php-config ' .
|
||||||
'--enable-shared --disable-static'
|
'--enable-shared --disable-static' . (!$has_avx512 ? ' php_cv_have_avx512=no ' : '')
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($this->patchBeforeSharedMake()) {
|
if ($this->patchBeforeSharedMake()) {
|
||||||
|
|||||||
@ -6,8 +6,6 @@ namespace SPC\builder\extension;
|
|||||||
|
|
||||||
use SPC\builder\Extension;
|
use SPC\builder\Extension;
|
||||||
use SPC\store\FileSystem;
|
use SPC\store\FileSystem;
|
||||||
use SPC\toolchain\ToolchainManager;
|
|
||||||
use SPC\toolchain\ZigToolchain;
|
|
||||||
use SPC\util\CustomExt;
|
use SPC\util\CustomExt;
|
||||||
|
|
||||||
#[CustomExt('simdjson')]
|
#[CustomExt('simdjson')]
|
||||||
@ -33,18 +31,4 @@ class simdjson extends Extension
|
|||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSharedExtensionEnv(): array
|
|
||||||
{
|
|
||||||
$env = parent::getSharedExtensionEnv();
|
|
||||||
if (ToolchainManager::getToolchainClass() === ZigToolchain::class) {
|
|
||||||
$extra = getenv('SPC_COMPILER_EXTRA');
|
|
||||||
if (!str_contains((string) $extra, '-lstdc++')) {
|
|
||||||
f_putenv('SPC_COMPILER_EXTRA=' . clean_spaces($extra . ' -lstdc++'));
|
|
||||||
}
|
|
||||||
$env['CFLAGS'] .= ' -Xclang -target-feature -Xclang +evex512';
|
|
||||||
$env['CXXFLAGS'] .= ' -Xclang -target-feature -Xclang +evex512';
|
|
||||||
}
|
|
||||||
return $env;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,8 @@ use SPC\exception\PatchException;
|
|||||||
use SPC\exception\WrongUsageException;
|
use SPC\exception\WrongUsageException;
|
||||||
use SPC\store\FileSystem;
|
use SPC\store\FileSystem;
|
||||||
use SPC\store\SourcePatcher;
|
use SPC\store\SourcePatcher;
|
||||||
|
use SPC\toolchain\ToolchainManager;
|
||||||
|
use SPC\toolchain\ZigToolchain;
|
||||||
use SPC\util\GlobalEnvManager;
|
use SPC\util\GlobalEnvManager;
|
||||||
use SPC\util\SPCConfigUtil;
|
use SPC\util\SPCConfigUtil;
|
||||||
use SPC\util\SPCTarget;
|
use SPC\util\SPCTarget;
|
||||||
@ -103,6 +105,11 @@ class LinuxBuilder extends UnixBuilderBase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$has_avx512 = str_contains($this->arch_c_flags, '-mavx512') ||
|
||||||
|
str_contains($this->arch_c_flags, '-march=x86-64-v3') ||
|
||||||
|
str_contains($this->arch_c_flags, '-march=x86-64-v4') ||
|
||||||
|
ToolchainManager::getToolchainClass() !== ZigToolchain::class;
|
||||||
|
|
||||||
$this->seekPhpSrcLogFileOnException(fn () => shell()->cd(SOURCE_PATH . '/php-src')->exec(
|
$this->seekPhpSrcLogFileOnException(fn () => shell()->cd(SOURCE_PATH . '/php-src')->exec(
|
||||||
$php_configure_env . ' ' .
|
$php_configure_env . ' ' .
|
||||||
getenv('SPC_CMD_PREFIX_PHP_CONFIGURE') . ' ' .
|
getenv('SPC_CMD_PREFIX_PHP_CONFIGURE') . ' ' .
|
||||||
@ -116,6 +123,7 @@ class LinuxBuilder extends UnixBuilderBase
|
|||||||
$json_74 .
|
$json_74 .
|
||||||
$zts .
|
$zts .
|
||||||
$maxExecutionTimers .
|
$maxExecutionTimers .
|
||||||
|
(!$has_avx512 ? 'php_cv_have_avx512=no ' : '') .
|
||||||
$this->makeStaticExtensionArgs() . ' '
|
$this->makeStaticExtensionArgs() . ' '
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user