File tree Expand file tree Collapse file tree 3 files changed +16
-5
lines changed
Expand file tree Collapse file tree 3 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -140,7 +140,7 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
140140
141141 $ embed_type = getenv ('SPC_CMD_VAR_PHP_EMBED_TYPE ' ) ?: 'static ' ;
142142 if ($ embed_type !== 'static ' && getenv ('SPC_LIBC ' ) === 'musl ' ) {
143- throw new RuntimeException ('Musl libc does not support dynamic linking of PHP embed! ' );
143+ throw new WrongUsageException ('Musl libc does not support dynamic linking of PHP embed! ' );
144144 }
145145 shell ()->cd (SOURCE_PATH . '/php-src ' )
146146 ->exec (
@@ -300,6 +300,7 @@ protected function buildEmbed(): void
300300 ->exec (getenv ('SPC_CMD_PREFIX_PHP_MAKE ' ) . ' INSTALL_ROOT= ' . BUILD_ROOT_PATH . " {$ vars } install " );
301301
302302 $ ldflags = getenv ('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS ' );
303+ $ realLibName = 'libphp.so ' ;
303304 if (preg_match ('/-release\s+(\S+)/ ' , $ ldflags , $ matches )) {
304305 $ release = $ matches [1 ];
305306 $ realLibName = 'libphp- ' . $ release . '.so ' ;
@@ -338,8 +339,8 @@ protected function buildEmbed(): void
338339 }
339340 chdir ($ cwd );
340341 }
341- if (!$ this ->getOption ('no-strip ' , false )) {
342- shell ()->cd (SOURCE_PATH . ' /php-src/sapi/cli ' )->exec (' strip --strip-all php ' );
342+ if (!$ this ->getOption ('no-strip ' , false ) && file_exists ( BUILD_LIB_PATH . ' / ' . $ realLibName ) ) {
343+ shell ()->cd (BUILD_LIB_PATH )->exec (" strip --strip-all $ realLibName " );
343344 }
344345 $ this ->patchPhpScripts ();
345346 }
Original file line number Diff line number Diff line change @@ -209,7 +209,7 @@ protected function sanityCheck(int $build_target): void
209209 if ($ ret !== 0 ) {
210210 throw new RuntimeException ('embed failed sanity check: build failed. Error message: ' . implode ("\n" , $ out ));
211211 }
212- // if someone changed to --enable-embed =shared, we need to add LD_LIBRARY_PATH
212+ // if someone changed to EMBED_TYPE =shared, we need to add LD_LIBRARY_PATH
213213 if (getenv ('SPC_CMD_VAR_PHP_EMBED_TYPE ' ) === 'shared ' ) {
214214 $ ext_path = 'LD_LIBRARY_PATH= ' . BUILD_ROOT_PATH . '/lib:$LD_LIBRARY_PATH ' ;
215215 FileSystem::removeFileIfExists (BUILD_ROOT_PATH . '/lib/libphp.a ' );
@@ -357,5 +357,9 @@ protected function buildFrankenphp(): void
357357 shell ()->cd (BUILD_BIN_PATH )
358358 ->setEnv ($ env )
359359 ->exec ("xcaddy build --output frankenphp {$ xcaddyModules }" );
360+
361+ if (!$ this ->getOption ('no-strip ' , false ) && file_exists (BUILD_BIN_PATH . '/frankenphp ' )) {
362+ shell ()->cd (BUILD_BIN_PATH )->exec ('strip --strip-all frankenphp ' );
363+ }
360364 }
361365}
Original file line number Diff line number Diff line change @@ -44,7 +44,13 @@ public static function init(): void
4444 // Define env vars for linux
4545 if (PHP_OS_FAMILY === 'Linux ' ) {
4646 $ arch = getenv ('GNU_ARCH ' );
47- if (SystemUtil::isMuslDist () || getenv ('SPC_LIBC ' ) === 'glibc ' ) {
47+
48+ if (str_contains (getenv ('CC ' ), 'zig ' )) {
49+ self ::putenv ('SPC_LINUX_DEFAULT_CC=zig-cc ' );
50+ self ::putenv ('SPC_LINUX_DEFAULT_CXX=zig-c++ ' );
51+ self ::putenv ('SPC_LINUX_DEFAULT_AR=ar ' );
52+ self ::putenv ('SPC_LINUX_DEFAULT_LD=ld.lld ' );
53+ } elseif (SystemUtil::isMuslDist () || getenv ('SPC_LIBC ' ) === 'glibc ' ) {
4854 self ::putenv ('SPC_LINUX_DEFAULT_CC=gcc ' );
4955 self ::putenv ('SPC_LINUX_DEFAULT_CXX=g++ ' );
5056 self ::putenv ('SPC_LINUX_DEFAULT_AR=ar ' );
You can’t perform that action at this time.
0 commit comments