@@ -331,7 +331,13 @@ protected function buildFrankenphp(): void
331331 if (getenv ('SPC_CMD_VAR_PHP_EMBED_TYPE ' ) === 'shared ' ) {
332332 $ libphpVersion = preg_replace ('/\.\d$/ ' , '' , $ libphpVersion );
333333 }
334- $ debugFlags = $ this ->getOption ('--with-debug ' ) ? "'-w -s' " : '' ;
334+ $ debugFlags = $ this ->getOption ('no-strip ' ) ? "'-w -s' " : '' ;
335+ $ extLdFlags = "-extldflags '-pie' " ;
336+ $ muslTags = '' ;
337+ if (PHP_OS_FAMILY === 'Linux ' && getenv ('SPC_LIBC ' ) === 'musl ' ) {
338+ $ extLdFlags = "-extldflags '-static-pie -Wl,-z,stack-size=0x80000' " ;
339+ $ muslTags = 'static_build, ' ;
340+ }
335341
336342 $ config = (new SPCConfigUtil ($ this ))->config ($ this ->ext_list , $ this ->lib_list , with_dependencies: true );
337343
@@ -344,10 +350,10 @@ protected function buildFrankenphp(): void
344350 'CGO_CFLAGS ' => $ config ['cflags ' ],
345351 'CGO_LDFLAGS ' => "{$ config ['ldflags ' ]} {$ config ['libs ' ]} {$ lrt }" ,
346352 'XCADDY_GO_BUILD_FLAGS ' => '-buildmode=pie ' .
347- '-ldflags \"-linkmode=external -extldflags \' -pie \ ' ' . $ debugFlags .
353+ '-ldflags \"-linkmode=external ' . $ extLdFlags . ' ' . $ debugFlags .
348354 '-X \'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP ' .
349355 "{$ frankenPhpVersion } PHP {$ libphpVersion } Caddy' \\\" " .
350- "-tags=nobadger,nomysql,nopgx {$ nobrotli }{$ nowatcher }" ,
356+ "-tags= { $ muslTags } nobadger,nomysql,nopgx {$ nobrotli }{$ nowatcher }" ,
351357 'LD_LIBRARY_PATH ' => BUILD_LIB_PATH ,
352358 ];
353359 shell ()->cd (BUILD_BIN_PATH )
0 commit comments