|
11 | 11 | use SPC\store\DirDiff; |
12 | 12 | use SPC\store\FileSystem; |
13 | 13 | use SPC\store\SourcePatcher; |
| 14 | +use SPC\toolchain\ToolchainManager; |
| 15 | +use SPC\toolchain\ZigToolchain; |
14 | 16 | use SPC\util\GlobalEnvManager; |
15 | 17 | use SPC\util\SPCConfigUtil; |
16 | 18 | use SPC\util\SPCTarget; |
@@ -65,7 +67,8 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void |
65 | 67 | // php 8.5 contains opcache extension by default, |
66 | 68 | // if opcache_jit is enabled for 8.5 or opcache enabled, |
67 | 69 | // we need to disable undefined behavior sanitizer. |
68 | | - f_putenv('SPC_COMPILER_EXTRA=-fno-sanitize=undefined'); |
| 70 | + $compiler_extra = getenv('SPC_COMPILER_EXTRA') ?: ''; |
| 71 | + f_putenv('SPC_COMPILER_EXTRA=' . trim($compiler_extra . ' -fno-sanitize=undefined')); |
69 | 72 | } |
70 | 73 |
|
71 | 74 | if ($this->getOption('enable-zts', false)) { |
@@ -266,6 +269,11 @@ protected function buildFpm(): void |
266 | 269 | */ |
267 | 270 | protected function buildEmbed(): void |
268 | 271 | { |
| 272 | + $compiler_extra = getenv('SPC_COMPILER_EXTRA') ?: ''; |
| 273 | + if (!str_contains($compiler_extra, '-lcompiler_rt') && ToolchainManager::getToolchainClass() === ZigToolchain::class) { |
| 274 | + $compiler_extra = trim($compiler_extra . ' -lcompiler_rt'); |
| 275 | + GlobalEnvManager::putenv("SPC_COMPILER_EXTRA={$compiler_extra}"); |
| 276 | + } |
269 | 277 | $sharedExts = array_filter($this->exts, static fn ($ext) => $ext->isBuildShared()); |
270 | 278 | $sharedExts = array_filter($sharedExts, static function ($ext) { |
271 | 279 | return Config::getExt($ext->getName(), 'build-with-php') === true; |
|
0 commit comments