authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-09-19 12:54:56-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-09-19 18:20:22-07:00
logcefcf39faaa892784ed59d0960858195b0a9d367
tree2e089ed7f6cf6eccbee28ebb5a6262b44ec6d77a
parent38af1b7ed1cd6d4a71bd2f22e09b90cf186571d5

compiler_rt: strong linkage when compiling to .c

This works around a problem that started happening with LLD around version 18.1.8: ``` lld-link: error: duplicate symbol: .weak.__nexf2.default >>> defined at CMakeFiles/zig2.dir/compiler_rt.c.obj >>> defined at compiler_rt.lib(compiler_rt.lib.obj) ```

1 files changed, 8 insertions(+), 2 deletions(-)

lib/compiler_rt/common.zig+8-2
...@@ -1,8 +1,14 @@...@@ -1,8 +1,14 @@
1const std = @import("std");1const std = @import("std");
2const builtin = @import("builtin");2const builtin = @import("builtin");
3const native_endian = builtin.cpu.arch.endian();3const native_endian = builtin.cpu.arch.endian();
4const ofmt_c = builtin.object_format == .c;
45
5pub const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .internal else .weak;6pub const linkage: std.builtin.GlobalLinkage = if (builtin.is_test)
7 .internal
8else if (ofmt_c)
9 .strong
10else
11 .weak;
6/// Determines the symbol's visibility to other objects.12/// Determines the symbol's visibility to other objects.
7/// For WebAssembly this allows the symbol to be resolved to other modules, but will not13/// For WebAssembly this allows the symbol to be resolved to other modules, but will not
8/// export it to the host runtime.14/// export it to the host runtime.
...@@ -28,7 +34,7 @@ pub const want_float_exceptions = !builtin.cpu.arch.isWasm();...@@ -28,7 +34,7 @@ pub const want_float_exceptions = !builtin.cpu.arch.isWasm();
2834
29// Libcalls that involve u128 on Windows x86-64 are expected by LLVM to use the35// Libcalls that involve u128 on Windows x86-64 are expected by LLVM to use the
30// calling convention of @Vector(2, u64), rather than what's standard.36// calling convention of @Vector(2, u64), rather than what's standard.
31pub const want_windows_v2u64_abi = builtin.os.tag == .windows and builtin.cpu.arch == .x86_64 and @import("builtin").object_format != .c;37pub const want_windows_v2u64_abi = builtin.os.tag == .windows and builtin.cpu.arch == .x86_64 and !ofmt_c;
3238
33/// This governs whether to use these symbol names for f16/f32 conversions39/// This governs whether to use these symbol names for f16/f32 conversions
34/// rather than the standard names:40/// rather than the standard names: