@@ -97,9 +97,10 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
97
97
$ enableFrankenphp = ($ build_target & BUILD_TARGET_FRANKENPHP ) === BUILD_TARGET_FRANKENPHP ;
98
98
99
99
// prepare build php envs
100
+ $ musl_flag = SPCTarget::getLibc () === 'musl ' ? ' -D__MUSL__ ' : ' -U__MUSL__ ' ;
100
101
$ php_configure_env = SystemUtil::makeEnvVarString ([
101
102
'CFLAGS ' => getenv ('SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS ' ),
102
- 'CPPFLAGS ' => '-I ' . BUILD_INCLUDE_PATH ,
103
+ 'CPPFLAGS ' => '-I ' . BUILD_INCLUDE_PATH . $ musl_flag ,
103
104
'LDFLAGS ' => '-L ' . BUILD_LIB_PATH ,
104
105
// 'LIBS' => SPCTarget::getRuntimeLibs(), // do not pass static libraries here yet, they may contain polyfills for libc functions!
105
106
]);
@@ -343,12 +344,22 @@ protected function buildEmbed(): void
343
344
$ this ->patchPhpScripts ();
344
345
}
345
346
347
+ /**
348
+ * Return extra variables for php make command.
349
+ *
350
+ * @throws FileSystemException
351
+ * @throws RuntimeException
352
+ * @throws WrongUsageException
353
+ * @throws \ReflectionException
354
+ * @throws \Throwable
355
+ */
346
356
private function getMakeExtraVars (): array
347
357
{
348
358
$ config = (new SPCConfigUtil ($ this , ['libs_only_deps ' => true , 'absolute_libs ' => true ]))->config ($ this ->ext_list , $ this ->lib_list , $ this ->getOption ('with-suggested-exts ' ), $ this ->getOption ('with-suggested-libs ' ));
349
359
$ static = SPCTarget::isStatic () ? '-all-static ' : '' ;
350
360
$ lib = BUILD_LIB_PATH ;
351
361
return [
362
+ 'CPPFLAGS ' => SPCTarget::getLibc () === 'musl ' ? '-D__MUSL__ ' : '-U__MUSL__ ' ,
352
363
'EXTRA_CFLAGS ' => getenv ('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS ' ),
353
364
'EXTRA_LIBS ' => $ config ['libs ' ],
354
365
'EXTRA_LDFLAGS ' => getenv ('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS ' ),
0 commit comments