diff --git a/src/SPC/toolchain/ZigToolchain.php b/src/SPC/toolchain/ZigToolchain.php index fce9bb5d..779401a0 100644 --- a/src/SPC/toolchain/ZigToolchain.php +++ b/src/SPC/toolchain/ZigToolchain.php @@ -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 diff --git a/src/SPC/util/SPCTarget.php b/src/SPC/util/SPCTarget.php index 03f26223..7298f2c8 100644 --- a/src/SPC/util/SPCTarget.php +++ b/src/SPC/util/SPCTarget.php @@ -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); } /**