Commit 358ee859ba

Alex Rønne Petersen <alex@alexrp.com>
2025-05-29 15:32:32
compiler-rt: Fix some exports for *-windows-none.
1 parent 7cae6b8
Changed files (4)
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 });
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 });
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();
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 });
     }
 }