zig hasn't released 0.16 yet

This commit is contained in:
henderkes 2026-02-21 10:20:00 +07:00
parent 74906b89a2
commit 3d4b87b107
2 changed files with 11 additions and 4 deletions

View File

@ -384,11 +384,13 @@ abstract class LibraryBase
} }
return true; // allow using system dependencies if pkg_config_path is explicitly defined return true; // allow using system dependencies if pkg_config_path is explicitly defined
} }
if (getenv('SPC_LINK_STATIC')) { foreach (Config::getLib(static::NAME, 'static-libs', []) as $name) {
foreach (Config::getLib(static::NAME, 'static-libs', []) as $name) { if (!file_exists(BUILD_LIB_PATH . "/{$name}")) {
if (!file_exists(BUILD_LIB_PATH . "/{$name}")) { $sharedLib = str_replace('.a', '.so', $name);
return false; if (!getenv('SPC_LINK_STATIC') && file_exists(BUILD_LIB_PATH . "/{$sharedLib}")) {
continue;
} }
return false;
} }
} }
foreach (Config::getLib(static::NAME, 'headers', []) as $name) { foreach (Config::getLib(static::NAME, 'headers', []) as $name) {

View File

@ -7,6 +7,7 @@ namespace SPC\builder\traits;
use SPC\exception\ExecutionException; use SPC\exception\ExecutionException;
use SPC\exception\SPCInternalException; use SPC\exception\SPCInternalException;
use SPC\exception\WrongUsageException; use SPC\exception\WrongUsageException;
use SPC\store\pkg\Zig;
use SPC\toolchain\ToolchainManager; use SPC\toolchain\ToolchainManager;
use SPC\toolchain\ZigToolchain; use SPC\toolchain\ZigToolchain;
use SPC\util\SPCTarget; use SPC\util\SPCTarget;
@ -73,6 +74,10 @@ trait UnixSystemUtilTrait
throw new SPCInternalException("The symbol file {$symbol_file} does not exist, please check if nm command is available."); throw new SPCInternalException("The symbol file {$symbol_file} does not exist, please check if nm command is available.");
} }
// macOS/zig // macOS/zig
// https://github.com/ziglang/zig/issues/24662
if (ToolchainManager::getToolchainClass() === ZigToolchain::class) {
return '-Wl,--export-dynamic'; // needs release 0.16, can be removed then
}
if (SPCTarget::getTargetOS() !== 'Linux' || ToolchainManager::getToolchainClass() === ZigToolchain::class) { if (SPCTarget::getTargetOS() !== 'Linux' || ToolchainManager::getToolchainClass() === ZigToolchain::class) {
return "-Wl,-exported_symbols_list,{$symbol_file}"; return "-Wl,-exported_symbols_list,{$symbol_file}";
} }