mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-17 20:34:51 +08:00
musl paths in zig toolchain are hogwash, of course
This commit is contained in:
parent
88f9172866
commit
fd89e83798
@ -12,17 +12,11 @@ class ZigToolchain implements ToolchainInterface
|
||||
{
|
||||
public function initEnv(): void
|
||||
{
|
||||
$arch = getenv('GNU_ARCH');
|
||||
// Set environment variables for musl toolchain
|
||||
// Set environment variables for zig toolchain
|
||||
GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_CC=zig-cc');
|
||||
GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_CXX=zig-c++');
|
||||
GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_AR=ar');
|
||||
GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_LD=ld');
|
||||
GlobalEnvManager::addPathIfNotExists('/usr/local/musl/bin');
|
||||
GlobalEnvManager::addPathIfNotExists("/usr/local/musl/{$arch}-linux-musl/bin");
|
||||
|
||||
GlobalEnvManager::putenv("SPC_LD_LIBRARY_PATH=/usr/local/musl/lib:/usr/local/musl/{$arch}-linux-musl/lib");
|
||||
GlobalEnvManager::putenv("SPC_LIBRARY_PATH=/usr/local/musl/lib:/usr/local/musl/{$arch}-linux-musl/lib");
|
||||
}
|
||||
|
||||
public function afterInit(): void
|
||||
|
||||
@ -24,9 +24,6 @@ class SPCTarget
|
||||
public static function isStatic(): bool
|
||||
{
|
||||
// if SPC_LIBC is set, it means the target is static, remove it when 3.0 is released
|
||||
if (getenv('SPC_LIBC') === 'musl') {
|
||||
return true;
|
||||
}
|
||||
if ($target = getenv('SPC_TARGET')) {
|
||||
if (str_contains($target, '-macos') || str_contains($target, '-native') && PHP_OS_FAMILY === 'Darwin') {
|
||||
return false;
|
||||
@ -39,6 +36,9 @@ class SPCTarget
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (getenv('SPC_LIBC') === 'musl') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -47,10 +47,6 @@ class SPCTarget
|
||||
*/
|
||||
public static function getLibc(): ?string
|
||||
{
|
||||
$libc = getenv('SPC_LIBC');
|
||||
if ($libc !== false) {
|
||||
return $libc;
|
||||
}
|
||||
$target = getenv('SPC_TARGET');
|
||||
if (str_contains($target, '-gnu')) {
|
||||
return 'glibc';
|
||||
@ -64,6 +60,10 @@ class SPCTarget
|
||||
if (PHP_OS_FAMILY === 'Linux' && str_contains($target, '-native')) {
|
||||
return 'musl';
|
||||
}
|
||||
$libc = getenv('SPC_LIBC');
|
||||
if ($libc !== false) {
|
||||
return $libc;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -72,15 +72,8 @@ class SPCTarget
|
||||
*/
|
||||
public static function getLibcVersion(): ?string
|
||||
{
|
||||
$env = getenv('SPC_TARGET');
|
||||
$libc = getenv('SPC_LIBC');
|
||||
if ($libc !== false) {
|
||||
// legacy method: get a version from system
|
||||
return SystemUtil::getLibcVersionIfExists($libc);
|
||||
}
|
||||
// TODO: zig target parser
|
||||
|
||||
return null;
|
||||
$libc = self::getLibc();
|
||||
return SystemUtil::getLibcVersionIfExists($libc);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user