From 358ee859bae5baa87bcff1fabfde87fe2aa1ab52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Thu, 29 May 2025 15:32:32 +0200 Subject: [PATCH] compiler-rt: Fix some exports for *-windows-none. --- lib/compiler_rt.zig | 2 +- lib/compiler_rt/aulldiv.zig | 2 +- lib/compiler_rt/aullrem.zig | 2 +- lib/compiler_rt/common.zig | 5 +++++ 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/compiler_rt.zig b/lib/compiler_rt.zig index c8da59eb5f..e8fd982f55 100644 --- a/lib/compiler_rt.zig +++ b/lib/compiler_rt.zig @@ -260,7 +260,7 @@ comptime { _ = @import("compiler_rt/ssp.zig"); } - if (!builtin.link_libc and builtin.abi == .msvc) { + if (!builtin.link_libc and builtin.os.tag == .windows and (builtin.abi == .none or builtin.abi == .msvc)) { @export(&_fltused, .{ .name = "_fltused", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/aulldiv.zig b/lib/compiler_rt/aulldiv.zig index 6832b66d01..2f57ab1687 100644 --- a/lib/compiler_rt/aulldiv.zig +++ b/lib/compiler_rt/aulldiv.zig @@ -8,7 +8,7 @@ const common = @import("common.zig"); pub const panic = common.panic; comptime { - if (arch == .x86 and os == .windows and (abi == .msvc or abi == .itanium) and !builtin.link_libc) { + if (arch == .x86 and common.want_windows_msvc_or_itanium_abi and !builtin.link_libc) { // Don't let LLVM apply the stdcall name mangling on those MSVC builtins @export(&_alldiv, .{ .name = "\x01__alldiv", .linkage = common.linkage, .visibility = common.visibility }); @export(&_aulldiv, .{ .name = "\x01__aulldiv", .linkage = common.linkage, .visibility = common.visibility }); diff --git a/lib/compiler_rt/aullrem.zig b/lib/compiler_rt/aullrem.zig index 3934225c8c..df50ef7381 100644 --- a/lib/compiler_rt/aullrem.zig +++ b/lib/compiler_rt/aullrem.zig @@ -8,7 +8,7 @@ const common = @import("common.zig"); pub const panic = common.panic; comptime { - if (arch == .x86 and os == .windows and (abi == .msvc or abi == .itanium) and !builtin.link_libc) { + if (arch == .x86 and common.want_windows_msvc_or_itanium_abi and !builtin.link_libc) { // Don't let LLVM apply the stdcall name mangling on those MSVC builtins @export(&_allrem, .{ .name = "\x01__allrem", .linkage = common.linkage, .visibility = common.visibility }); @export(&_aullrem, .{ .name = "\x01__aullrem", .linkage = common.linkage, .visibility = common.visibility }); diff --git a/lib/compiler_rt/common.zig b/lib/compiler_rt/common.zig index a5b9166630..1962296706 100644 --- a/lib/compiler_rt/common.zig +++ b/lib/compiler_rt/common.zig @@ -52,6 +52,11 @@ pub const want_aeabi = switch (builtin.abi) { // Temporarily used for thumb-uefi until https://github.com/ziglang/zig/issues/21630 is addressed. pub const want_windows_arm_abi = builtin.cpu.arch.isArm() and (builtin.os.tag == .windows or builtin.os.tag == .uefi) and (builtin.abi.isGnu() or !builtin.link_libc); +pub const want_windows_msvc_or_itanium_abi = switch (builtin.abi) { + .none, .msvc, .itanium => builtin.os.tag == .windows, + else => false, +}; + pub const want_ppc_abi = builtin.cpu.arch.isPowerPC(); pub const want_float_exceptions = !builtin.cpu.arch.isWasm();