@@ -354,14 +354,13 @@ public function makeEmbedForUnix(TargetPackage $package, PackageInstaller $insta
354354
355355 // ------------- SPC_CMD_VAR_PHP_EMBED_TYPE=static -------------
356356
357- // process libphp.a for static embed
358- if (!file_exists ("{$ package ->getLibDir ()}/libphp.a " )) {
359- return ;
357+ // process libphp.a for static embed (only when present)
358+ if (file_exists ("{$ package ->getLibDir ()}/libphp.a " )) {
359+ $ ar = getenv ('AR ' ) ?: 'ar ' ;
360+ $ libphp_a = "{$ package ->getLibDir ()}/libphp.a " ;
361+ shell ()->exec ("{$ ar } -t {$ libphp_a } | grep ' \\.a$' | xargs -n1 {$ ar } d {$ libphp_a }" );
362+ UnixUtil::exportDynamicSymbols ($ libphp_a );
360363 }
361- $ ar = getenv ('AR ' ) ?: 'ar ' ;
362- $ libphp_a = "{$ package ->getLibDir ()}/libphp.a " ;
363- shell ()->exec ("{$ ar } -t {$ libphp_a } | grep ' \\.a$' | xargs -n1 {$ ar } d {$ libphp_a }" );
364- UnixUtil::exportDynamicSymbols ($ libphp_a );
365364
366365 // deploy embed php scripts
367366 $ package ->runStage ([$ this , 'patchUnixEmbedScripts ' ]);
@@ -510,7 +509,8 @@ public function patchUnixEmbedScripts(): void
510509 if (file_exists (BUILD_BIN_PATH . '/php-config ' )) {
511510 logger ()->debug ('Patching php-config prefix and libs order ' );
512511 $ php_config_str = FileSystem::readFile (BUILD_BIN_PATH . '/php-config ' );
513- $ php_config_str = str_replace ('prefix="" ' , 'prefix=" ' . BUILD_ROOT_PATH . '" ' , $ php_config_str );
512+ // anchor to start-of-line so we don't also match `program_prefix=""`
513+ $ php_config_str = preg_replace ('/^prefix=""/m ' , 'prefix=" ' . BUILD_ROOT_PATH . '" ' , $ php_config_str );
514514 // move mimalloc to the beginning of libs
515515 $ php_config_str = preg_replace ('/(libs=")(.*?)\s*( ' . preg_quote (BUILD_LIB_PATH , '/ ' ) . '\/mimalloc\.o)\s*(.*?)"/ ' , '$1$3 $2 $4" ' , $ php_config_str );
516516 // move lstdc++ to the end of libs
0 commit comments