sanity check after toolset init

This commit is contained in:
DubbleClick
2025-07-01 18:22:05 +07:00
parent a6d68b9ecf
commit 8d47e56010
2 changed files with 14 additions and 3 deletions

View File

@@ -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 */