File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111use SPC \exception \WrongUsageException ;
1212use SPC \store \Config ;
1313use SPC \store \FileSystem ;
14+ use SPC \toolchain \ToolchainManager ;
15+ use SPC \toolchain \ZigToolchain ;
16+ use SPC \util \GlobalEnvManager ;
1417use SPC \util \SPCConfigUtil ;
1518use SPC \util \SPCTarget ;
1619
@@ -543,6 +546,11 @@ public function getLibraryDependencies(bool $recursive = false): array
543546 */
544547 protected function getSharedExtensionEnv (): array
545548 {
549+ $ compiler_extra = getenv ('SPC_COMPILER_EXTRA ' ) ?: '' ;
550+ if (!str_contains ($ compiler_extra , '-lcompiler_rt ' ) && ToolchainManager::getToolchainClass () === ZigToolchain::class) {
551+ $ compiler_extra = trim ($ compiler_extra . ' -lcompiler_rt ' );
552+ GlobalEnvManager::putenv ("SPC_COMPILER_EXTRA= {$ compiler_extra }" );
553+ }
546554 $ config = (new SPCConfigUtil ($ this ->builder , ['no_php ' => true ]))->getExtensionConfig ($ this );
547555 [$ staticLibs , $ sharedLibs ] = $ this ->splitLibsIntoStaticAndShared ($ config ['libs ' ]);
548556 $ preStatic = PHP_OS_FAMILY === 'Darwin ' ? '' : '-Wl,--start-group ' ;
Original file line number Diff line number Diff line change 1111use SPC \store \DirDiff ;
1212use SPC \store \FileSystem ;
1313use SPC \store \SourcePatcher ;
14+ use SPC \toolchain \ToolchainManager ;
15+ use SPC \toolchain \ZigToolchain ;
1416use SPC \util \GlobalEnvManager ;
1517use SPC \util \SPCConfigUtil ;
1618use SPC \util \SPCTarget ;
@@ -267,6 +269,11 @@ protected function buildFpm(): void
267269 */
268270 protected function buildEmbed (): void
269271 {
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+ }
270277 $ sharedExts = array_filter ($ this ->exts , static fn ($ ext ) => $ ext ->isBuildShared ());
271278 $ sharedExts = array_filter ($ sharedExts , static function ($ ext ) {
272279 return Config::getExt ($ ext ->getName (), 'build-with-php ' ) === true ;
Original file line number Diff line number Diff line change @@ -64,12 +64,6 @@ public function afterInit(): void
6464 $ extra_libs = trim ($ extra_libs . ' -lunwind ' );
6565 GlobalEnvManager::putenv ("SPC_EXTRA_LIBS= {$ extra_libs }" );
6666 }
67- $ compiler_extra = getenv ('SPC_COMPILER_EXTRA ' ) ?: '' ;
68- if (!str_contains ($ compiler_extra , '-lcompiler_rt ' )) {
69- // Add unwind library if not already present
70- $ compiler_extra = trim ($ compiler_extra . ' -lcompiler_rt ' );
71- GlobalEnvManager::putenv ("SPC_COMPILER_EXTRA= {$ compiler_extra }" );
72- }
7367 $ cflags = getenv ('SPC_DEFAULT_C_FLAGS ' ) ?: getenv ('CFLAGS ' ) ?: '' ;
7468 $ has_avx512 = str_contains ($ cflags , '-mavx512 ' ) || str_contains ($ cflags , '-march=x86-64-v4 ' );
7569 if (!$ has_avx512 ) {
You can’t perform that action at this time.
0 commit comments