aboutsummaryrefslogtreecommitdiff
path: root/lib/compiler_rt
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2025-01-25 13:17:25 -0800
committerGitHub <noreply@github.com>2025-01-25 13:17:25 -0800
commit8fa47bb904c888dadf20af5eb72b9643eed2bfea (patch)
tree47fcc20146a7358b4216668d91c78d3bb712511d /lib/compiler_rt
parent015a5e198246f782415586235e0da7085867eb22 (diff)
parentb60e39fe8f50783509e3cfe7a3888e1611b063c1 (diff)
downloadzig-8fa47bb904c888dadf20af5eb72b9643eed2bfea.tar.gz
zig-8fa47bb904c888dadf20af5eb72b9643eed2bfea.zip
Merge pull request #22230 from alexrp/lto-stuff
Disable LTO by default + some LTO fixes
Diffstat (limited to 'lib/compiler_rt')
-rw-r--r--lib/compiler_rt/arm.zig36
-rw-r--r--lib/compiler_rt/aulldiv.zig2
-rw-r--r--lib/compiler_rt/aullrem.zig2
-rw-r--r--lib/compiler_rt/common.zig6
-rw-r--r--lib/compiler_rt/fixdfdi.zig6
-rw-r--r--lib/compiler_rt/fixsfdi.zig6
-rw-r--r--lib/compiler_rt/fixunsdfdi.zig6
-rw-r--r--lib/compiler_rt/fixunssfdi.zig6
-rw-r--r--lib/compiler_rt/floatdidf.zig6
-rw-r--r--lib/compiler_rt/floatdisf.zig6
-rw-r--r--lib/compiler_rt/floatundidf.zig6
-rw-r--r--lib/compiler_rt/floatundisf.zig6
12 files changed, 39 insertions, 55 deletions
diff --git a/lib/compiler_rt/arm.zig b/lib/compiler_rt/arm.zig
index b71829688a..0cc268f189 100644
--- a/lib/compiler_rt/arm.zig
+++ b/lib/compiler_rt/arm.zig
@@ -15,11 +15,11 @@ comptime {
@export(&__aeabi_unwind_cpp_pr1, .{ .name = "__aeabi_unwind_cpp_pr1", .linkage = common.linkage, .visibility = common.visibility });
@export(&__aeabi_unwind_cpp_pr2, .{ .name = "__aeabi_unwind_cpp_pr2", .linkage = common.linkage, .visibility = common.visibility });
- @export(&__aeabi_ldivmod, .{ .name = if (target.isMinGW()) "__rt_sdiv64" else "__aeabi_ldivmod", .linkage = common.linkage, .visibility = common.visibility });
- @export(&__aeabi_uldivmod, .{ .name = if (target.isMinGW()) "__rt_udiv64" else "__aeabi_uldivmod", .linkage = common.linkage, .visibility = common.visibility });
+ @export(&__aeabi_ldivmod, .{ .name = if (common.want_windows_arm_abi) "__rt_sdiv64" else "__aeabi_ldivmod", .linkage = common.linkage, .visibility = common.visibility });
+ @export(&__aeabi_uldivmod, .{ .name = if (common.want_windows_arm_abi) "__rt_udiv64" else "__aeabi_uldivmod", .linkage = common.linkage, .visibility = common.visibility });
- @export(&__aeabi_idivmod, .{ .name = if (target.isMinGW()) "__rt_sdiv" else "__aeabi_idivmod", .linkage = common.linkage, .visibility = common.visibility });
- @export(&__aeabi_uidivmod, .{ .name = if (target.isMinGW()) "__rt_udiv" else "__aeabi_uidivmod", .linkage = common.linkage, .visibility = common.visibility });
+ @export(&__aeabi_idivmod, .{ .name = if (common.want_windows_arm_abi) "__rt_sdiv" else "__aeabi_idivmod", .linkage = common.linkage, .visibility = common.visibility });
+ @export(&__aeabi_uidivmod, .{ .name = if (common.want_windows_arm_abi) "__rt_udiv" else "__aeabi_uidivmod", .linkage = common.linkage, .visibility = common.visibility });
@export(&__aeabi_memcpy, .{ .name = "__aeabi_memcpy", .linkage = common.linkage, .visibility = common.visibility });
@export(&__aeabi_memcpy4, .{ .name = "__aeabi_memcpy4", .linkage = common.linkage, .visibility = common.visibility });
@@ -136,11 +136,14 @@ pub fn __aeabi_uidivmod() callconv(.Naked) void {
\\ push {lr}
\\ sub sp, #4
\\ mov r2, sp
- \\ bl __udivmodsi4
+ \\ bl %[__udivmodsi4]
\\ ldr r1, [sp]
\\ add sp, #4
\\ pop {pc}
- ::: "memory");
+ :
+ : [__udivmodsi4] "X" (&__udivmodsi4),
+ : "memory"
+ );
unreachable;
}
@@ -152,12 +155,15 @@ pub fn __aeabi_uldivmod() callconv(.Naked) void {
\\ sub sp, #16
\\ add r4, sp, #8
\\ str r4, [sp]
- \\ bl __udivmoddi4
+ \\ bl %[__udivmoddi4]
\\ ldr r2, [sp, #8]
\\ ldr r3, [sp, #12]
\\ add sp, #16
\\ pop {r4, pc}
- ::: "memory");
+ :
+ : [__udivmoddi4] "X" (&__udivmoddi4),
+ : "memory"
+ );
unreachable;
}
@@ -168,11 +174,14 @@ pub fn __aeabi_idivmod() callconv(.Naked) void {
\\ push {lr}
\\ sub sp, #4
\\ mov r2, sp
- \\ bl __divmodsi4
+ \\ bl %[__divmodsi4]
\\ ldr r1, [sp]
\\ add sp, #4
\\ pop {pc}
- ::: "memory");
+ :
+ : [__divmodsi4] "X" (&__divmodsi4),
+ : "memory"
+ );
unreachable;
}
@@ -184,12 +193,15 @@ pub fn __aeabi_ldivmod() callconv(.Naked) void {
\\ sub sp, #16
\\ add r4, sp, #8
\\ str r4, [sp]
- \\ bl __divmoddi4
+ \\ bl %[__divmoddi4]
\\ ldr r2, [sp, #8]
\\ ldr r3, [sp, #12]
\\ add sp, #16
\\ pop {r4, pc}
- ::: "memory");
+ :
+ : [__divmoddi4] "X" (&__divmoddi4),
+ : "memory"
+ );
unreachable;
}
diff --git a/lib/compiler_rt/aulldiv.zig b/lib/compiler_rt/aulldiv.zig
index 6d822b7b86..8a7baaad3e 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.zig_backend != .stage2_c) {
+ if (arch == .x86 and os == .windows and (abi == .msvc or abi == .itanium) 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 5c4d0588f7..182ad4e1de 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.zig_backend != .stage2_c) {
+ if (arch == .x86 and os == .windows and (abi == .msvc or abi == .itanium) 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 7b35864120..d85c05ba84 100644
--- a/lib/compiler_rt/common.zig
+++ b/lib/compiler_rt/common.zig
@@ -9,11 +9,13 @@ else if (ofmt_c)
.strong
else
.weak;
+
/// Determines the symbol's visibility to other objects.
/// For WebAssembly this allows the symbol to be resolved to other modules, but will not
/// export it to the host runtime.
pub const visibility: std.builtin.SymbolVisibility =
if (builtin.target.isWasm() and linkage != .internal) .hidden else .default;
+
pub const want_aeabi = switch (builtin.abi) {
.eabi,
.eabihf,
@@ -29,7 +31,9 @@ pub const want_aeabi = switch (builtin.abi) {
},
else => false,
};
-pub const want_mingw_arm_abi = builtin.cpu.arch.isArm() and builtin.target.isMinGW();
+
+/// These functions are provided by libc when targeting MSVC, but not MinGW.
+pub const want_windows_arm_abi = builtin.cpu.arch.isArm() and builtin.os.tag == .windows and (builtin.abi.isGnu() or !builtin.link_libc);
pub const want_ppc_abi = builtin.cpu.arch.isPowerPC();
diff --git a/lib/compiler_rt/fixdfdi.zig b/lib/compiler_rt/fixdfdi.zig
index b9bc5797b9..044bc6abe1 100644
--- a/lib/compiler_rt/fixdfdi.zig
+++ b/lib/compiler_rt/fixdfdi.zig
@@ -8,11 +8,7 @@ comptime {
if (common.want_aeabi) {
@export(&__aeabi_d2lz, .{ .name = "__aeabi_d2lz", .linkage = common.linkage, .visibility = common.visibility });
} else {
- @export(&__fixdfdi, .{ .name = "__fixdfdi", .linkage = common.linkage, .visibility = common.visibility });
-
- if (common.want_mingw_arm_abi) {
- @export(&__fixdfdi, .{ .name = "__dtoi64", .linkage = common.linkage, .visibility = common.visibility });
- }
+ @export(&__fixdfdi, .{ .name = if (common.want_windows_arm_abi) "__dtoi64" else "__fixdfdi", .linkage = common.linkage, .visibility = common.visibility });
}
}
diff --git a/lib/compiler_rt/fixsfdi.zig b/lib/compiler_rt/fixsfdi.zig
index 192614bd79..bd6ba9276d 100644
--- a/lib/compiler_rt/fixsfdi.zig
+++ b/lib/compiler_rt/fixsfdi.zig
@@ -8,11 +8,7 @@ comptime {
if (common.want_aeabi) {
@export(&__aeabi_f2lz, .{ .name = "__aeabi_f2lz", .linkage = common.linkage, .visibility = common.visibility });
} else {
- @export(&__fixsfdi, .{ .name = "__fixsfdi", .linkage = common.linkage, .visibility = common.visibility });
-
- if (common.want_mingw_arm_abi) {
- @export(&__fixsfdi, .{ .name = "__stoi64", .linkage = common.linkage, .visibility = common.visibility });
- }
+ @export(&__fixsfdi, .{ .name = if (common.want_windows_arm_abi) "__stoi64" else "__fixsfdi", .linkage = common.linkage, .visibility = common.visibility });
}
}
diff --git a/lib/compiler_rt/fixunsdfdi.zig b/lib/compiler_rt/fixunsdfdi.zig
index 86a4fa9de1..b39b0538fb 100644
--- a/lib/compiler_rt/fixunsdfdi.zig
+++ b/lib/compiler_rt/fixunsdfdi.zig
@@ -8,11 +8,7 @@ comptime {
if (common.want_aeabi) {
@export(&__aeabi_d2ulz, .{ .name = "__aeabi_d2ulz", .linkage = common.linkage, .visibility = common.visibility });
} else {
- @export(&__fixunsdfdi, .{ .name = "__fixunsdfdi", .linkage = common.linkage, .visibility = common.visibility });
-
- if (common.want_mingw_arm_abi) {
- @export(&__fixunsdfdi, .{ .name = "__dtou64", .linkage = common.linkage, .visibility = common.visibility });
- }
+ @export(&__fixunsdfdi, .{ .name = if (common.want_windows_arm_abi) "__dtou64" else "__fixunsdfdi", .linkage = common.linkage, .visibility = common.visibility });
}
}
diff --git a/lib/compiler_rt/fixunssfdi.zig b/lib/compiler_rt/fixunssfdi.zig
index 81d1c77f06..7f65c6c64d 100644
--- a/lib/compiler_rt/fixunssfdi.zig
+++ b/lib/compiler_rt/fixunssfdi.zig
@@ -8,11 +8,7 @@ comptime {
if (common.want_aeabi) {
@export(&__aeabi_f2ulz, .{ .name = "__aeabi_f2ulz", .linkage = common.linkage, .visibility = common.visibility });
} else {
- @export(&__fixunssfdi, .{ .name = "__fixunssfdi", .linkage = common.linkage, .visibility = common.visibility });
-
- if (common.want_mingw_arm_abi) {
- @export(&__fixunssfdi, .{ .name = "__stou64", .linkage = common.linkage, .visibility = common.visibility });
- }
+ @export(&__fixunssfdi, .{ .name = if (common.want_windows_arm_abi) "__stou64" else "__fixunssfdi", .linkage = common.linkage, .visibility = common.visibility });
}
}
diff --git a/lib/compiler_rt/floatdidf.zig b/lib/compiler_rt/floatdidf.zig
index fc145e836d..2396624dc3 100644
--- a/lib/compiler_rt/floatdidf.zig
+++ b/lib/compiler_rt/floatdidf.zig
@@ -8,11 +8,7 @@ comptime {
if (common.want_aeabi) {
@export(&__aeabi_l2d, .{ .name = "__aeabi_l2d", .linkage = common.linkage, .visibility = common.visibility });
} else {
- @export(&__floatdidf, .{ .name = "__floatdidf", .linkage = common.linkage, .visibility = common.visibility });
-
- if (common.want_mingw_arm_abi) {
- @export(&__floatdidf, .{ .name = "__i64tod", .linkage = common.linkage, .visibility = common.visibility });
- }
+ @export(&__floatdidf, .{ .name = if (common.want_windows_arm_abi) "__i64tod" else "__floatdidf", .linkage = common.linkage, .visibility = common.visibility });
}
}
diff --git a/lib/compiler_rt/floatdisf.zig b/lib/compiler_rt/floatdisf.zig
index d1c9515f9a..1cc159ccaa 100644
--- a/lib/compiler_rt/floatdisf.zig
+++ b/lib/compiler_rt/floatdisf.zig
@@ -8,11 +8,7 @@ comptime {
if (common.want_aeabi) {
@export(&__aeabi_l2f, .{ .name = "__aeabi_l2f", .linkage = common.linkage, .visibility = common.visibility });
} else {
- @export(&__floatdisf, .{ .name = "__floatdisf", .linkage = common.linkage, .visibility = common.visibility });
-
- if (common.want_mingw_arm_abi) {
- @export(&__floatdisf, .{ .name = "__i64tos", .linkage = common.linkage, .visibility = common.visibility });
- }
+ @export(&__floatdisf, .{ .name = if (common.want_windows_arm_abi) "__i64tos" else "__floatdisf", .linkage = common.linkage, .visibility = common.visibility });
}
}
diff --git a/lib/compiler_rt/floatundidf.zig b/lib/compiler_rt/floatundidf.zig
index 3448f0cf20..159b6abd1a 100644
--- a/lib/compiler_rt/floatundidf.zig
+++ b/lib/compiler_rt/floatundidf.zig
@@ -8,11 +8,7 @@ comptime {
if (common.want_aeabi) {
@export(&__aeabi_ul2d, .{ .name = "__aeabi_ul2d", .linkage = common.linkage, .visibility = common.visibility });
} else {
- @export(&__floatundidf, .{ .name = "__floatundidf", .linkage = common.linkage, .visibility = common.visibility });
-
- if (common.want_mingw_arm_abi) {
- @export(&__floatundidf, .{ .name = "__u64tod", .linkage = common.linkage, .visibility = common.visibility });
- }
+ @export(&__floatundidf, .{ .name = if (common.want_windows_arm_abi) "__u64tod" else "__floatundidf", .linkage = common.linkage, .visibility = common.visibility });
}
}
diff --git a/lib/compiler_rt/floatundisf.zig b/lib/compiler_rt/floatundisf.zig
index 9054982b54..caecbd0cd8 100644
--- a/lib/compiler_rt/floatundisf.zig
+++ b/lib/compiler_rt/floatundisf.zig
@@ -8,11 +8,7 @@ comptime {
if (common.want_aeabi) {
@export(&__aeabi_ul2f, .{ .name = "__aeabi_ul2f", .linkage = common.linkage, .visibility = common.visibility });
} else {
- @export(&__floatundisf, .{ .name = "__floatundisf", .linkage = common.linkage, .visibility = common.visibility });
-
- if (common.want_mingw_arm_abi) {
- @export(&__floatundisf, .{ .name = "__u64tos", .linkage = common.linkage, .visibility = common.visibility });
- }
+ @export(&__floatundisf, .{ .name = if (common.want_windows_arm_abi) "__u64tos" else "__floatundisf", .linkage = common.linkage, .visibility = common.visibility });
}
}