Skip to content

Commit e14301d

Browse files
committed
Symbol workaround for cross toolchain
1 parent 65f7404 commit e14301d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/SPC/builder/linux/LinuxBuilder.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,10 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
9797
$enableFrankenphp = ($build_target & BUILD_TARGET_FRANKENPHP) === BUILD_TARGET_FRANKENPHP;
9898

9999
// prepare build php envs
100+
$musl_flag = SPCTarget::getLibc() === 'musl' ? ' -D__MUSL__' : ' -U__MUSL__';
100101
$php_configure_env = SystemUtil::makeEnvVarString([
101102
'CFLAGS' => getenv('SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS'),
102-
'CPPFLAGS' => '-I' . BUILD_INCLUDE_PATH,
103+
'CPPFLAGS' => '-I' . BUILD_INCLUDE_PATH . $musl_flag,
103104
'LDFLAGS' => '-L' . BUILD_LIB_PATH,
104105
// 'LIBS' => SPCTarget::getRuntimeLibs(), // do not pass static libraries here yet, they may contain polyfills for libc functions!
105106
]);
@@ -343,12 +344,22 @@ protected function buildEmbed(): void
343344
$this->patchPhpScripts();
344345
}
345346

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+
*/
346356
private function getMakeExtraVars(): array
347357
{
348358
$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'));
349359
$static = SPCTarget::isStatic() ? '-all-static' : '';
350360
$lib = BUILD_LIB_PATH;
351361
return [
362+
'CPPFLAGS' => SPCTarget::getLibc() === 'musl' ? '-D__MUSL__' : '-U__MUSL__',
352363
'EXTRA_CFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'),
353364
'EXTRA_LIBS' => $config['libs'],
354365
'EXTRA_LDFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS'),

0 commit comments

Comments
 (0)