zig toolchain can always use libc

This commit is contained in:
henderkes 2025-12-03 15:02:14 +01:00
parent 719d818fd1
commit 98773ee5a6

View File

@ -6,6 +6,8 @@ namespace SPC\builder\linux\library;
use SPC\builder\linux\SystemUtil;
use SPC\store\FileSystem;
use SPC\toolchain\GccNativeToolchain;
use SPC\toolchain\ToolchainManager;
use SPC\util\executor\UnixAutoconfExecutor;
use SPC\util\SPCTarget;
@ -15,26 +17,19 @@ class liburing extends LinuxLibraryBase
public function patchBeforeBuild(): bool
{
if (!SystemUtil::isMuslDist()) {
return false;
if (SystemUtil::isMuslDist()) {
FileSystem::replaceFileStr($this->source_dir . '/configure', 'realpath -s', 'realpath');
return true;
}
FileSystem::replaceFileStr($this->source_dir . '/configure', 'realpath -s', 'realpath');
return true;
return false;
}
protected function build(): void
{
$use_libc = SPCTarget::getLibc() !== 'glibc' || version_compare(SPCTarget::getLibcVersion(), '2.30', '>=');
$use_libc = ToolchainManager::getToolchainClass() !== GccNativeToolchain::class || version_compare(SPCTarget::getLibcVersion(), '2.30', '>=');
$make = UnixAutoconfExecutor::create($this);
if (!$use_libc) {
$make->appendEnv([
'CC' => 'gcc', // libc-less version fails to compile with clang or zig
'CXX' => 'g++',
'AR' => 'ar',
'LD' => 'ld',
]);
} else {
if ($use_libc) {
$make->appendEnv([
'CFLAGS' => '-D_GNU_SOURCE',
]);
@ -51,7 +46,7 @@ class liburing extends LinuxLibraryBase
$use_libc ? '--use-libc' : '',
)
->configure()
->make('library', 'install ENABLE_SHARED=0', with_clean: false);
->make('library ENABLE_SHARED=0', 'install ENABLE_SHARED=0', with_clean: false);
$this->patchPkgconfPrefix();
}