@@ -331,7 +331,13 @@ protected function buildFrankenphp(): void
331
331
if (getenv ('SPC_CMD_VAR_PHP_EMBED_TYPE ' ) === 'shared ' ) {
332
332
$ libphpVersion = preg_replace ('/\.\d$/ ' , '' , $ libphpVersion );
333
333
}
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
+ }
335
341
336
342
$ config = (new SPCConfigUtil ($ this ))->config ($ this ->ext_list , $ this ->lib_list , with_dependencies: true );
337
343
@@ -344,10 +350,10 @@ protected function buildFrankenphp(): void
344
350
'CGO_CFLAGS ' => $ config ['cflags ' ],
345
351
'CGO_LDFLAGS ' => "{$ config ['ldflags ' ]} {$ config ['libs ' ]} {$ lrt }" ,
346
352
'XCADDY_GO_BUILD_FLAGS ' => '-buildmode=pie ' .
347
- '-ldflags \"-linkmode=external -extldflags \' -pie \ ' ' . $ debugFlags .
353
+ '-ldflags \"-linkmode=external ' . $ extLdFlags . ' ' . $ debugFlags .
348
354
'-X \'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP ' .
349
355
"{$ frankenPhpVersion } PHP {$ libphpVersion } Caddy' \\\" " .
350
- "-tags=nobadger,nomysql,nopgx {$ nobrotli }{$ nowatcher }" ,
356
+ "-tags= { $ muslTags } nobadger,nomysql,nopgx {$ nobrotli }{$ nowatcher }" ,
351
357
'LD_LIBRARY_PATH ' => BUILD_LIB_PATH ,
352
358
];
353
359
shell ()->cd (BUILD_BIN_PATH )
0 commit comments