mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-17 20:34:51 +08:00
sanity check after toolset init
This commit is contained in:
parent
a6d68b9ecf
commit
8d47e56010
@ -8,6 +8,7 @@ use SPC\builder\traits\UnixSystemUtilTrait;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\toolchain\ToolchainManager;
|
||||
use SPC\toolchain\ZigToolchain;
|
||||
use SPC\util\SPCTarget;
|
||||
|
||||
class SystemUtil
|
||||
{
|
||||
@ -215,10 +216,12 @@ class SystemUtil
|
||||
return null;
|
||||
}
|
||||
if ($libc === 'musl') {
|
||||
if (self::isMuslDist()) {
|
||||
if (SPCTarget::getLibc() === 'musl') {
|
||||
$result = shell()->execWithResult('ldd 2>&1', false);
|
||||
} else {
|
||||
} elseif (is_file('/usr/local/musl/lib/libc.so')) {
|
||||
$result = shell()->execWithResult('/usr/local/musl/lib/libc.so 2>&1', false);
|
||||
} else {
|
||||
$result = shell()->execWithResult('/lib/ld-musl-x86_64.so.1 2>&1', false);
|
||||
}
|
||||
// Match Version * line
|
||||
// match ldd version: "Version 1.2.3" match 1.2.3
|
||||
|
||||
@ -5,8 +5,10 @@ declare(strict_types=1);
|
||||
namespace SPC\toolchain;
|
||||
|
||||
use SPC\builder\linux\SystemUtil;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\util\GlobalEnvManager;
|
||||
use SPC\util\SPCTarget;
|
||||
|
||||
class ToolchainManager
|
||||
{
|
||||
@ -47,7 +49,13 @@ class ToolchainManager
|
||||
public static function afterInitToolchain(): void
|
||||
{
|
||||
if (!getenv('SPC_TOOLCHAIN')) {
|
||||
throw new WrongUsageException('SPC_TOOLCHAIN not set');
|
||||
throw new WrongUsageException('SPC_TOOLCHAIN was not properly set. Please contact the developers.');
|
||||
}
|
||||
if (SPCTarget::getLibc() === 'musl' && !SPCTarget::isStatic() && !file_exists('/lib/ld-musl-x86_64.so.1')) {
|
||||
throw new RuntimeException('You are linking against musl libc dynamically, but musl libc is not installed. Please install it with `sudo dnf install musl-libc` or `sudo apt install musl`');
|
||||
}
|
||||
if (SPCTarget::getLibc() === 'glibc' && SystemUtil::isMuslDist()) {
|
||||
throw new RuntimeException('You are linking against glibc libc dynamically, which is only supported on glibc distros.');
|
||||
}
|
||||
$toolchain = getenv('SPC_TOOLCHAIN');
|
||||
/* @var ToolchainInterface $toolchain */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user