remove extra libraries for php configure/make, since they're the same and only depend on the target libc

This commit is contained in:
DubbleClick
2025-07-04 14:27:48 +07:00
parent 3070376fb6
commit d65d82ff0a
7 changed files with 18 additions and 15 deletions

View File

@@ -64,9 +64,8 @@ class SPCConfigUtil
// embed
$libs = trim("-lphp -lc {$libs}");
$extra_env = getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS');
if (is_string($extra_env)) {
$libs .= ' ' . trim($extra_env, '"');
if ($extra_libs = SPCTarget::getRuntimeLibs()) {
$libs .= " {$extra_libs}";
}
// c++
if ($this->builder->hasCpp()) {

View File

@@ -74,6 +74,17 @@ class SPCTarget
return null;
}
public static function getRuntimeLibs(): string
{
if (PHP_OS_FAMILY === 'Linux') {
return self::getLibc() === 'musl' ? 'ldl -lpthread -lm' : '-ldl -lrt -lpthread -lm -lresolv -lutil';
}
if (PHP_OS_FAMILY === 'Darwin') {
return '-lresolv';
}
return '';
}
/**
* Returns the libc version if set, for other OS, it will always return null.
*/