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 @@
11const std = @import("std");
22const builtin = @import("builtin");
33const 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;
612/// Determines the symbol's visibility to other objects.
713/// For WebAssembly this allows the symbol to be resolved to other modules, but will not
814/// export it to the host runtime.
......@@ -28,7 +34,7 @@ pub const want_float_exceptions = !builtin.cpu.arch.isWasm();
2834
2935// Libcalls that involve u128 on Windows x86-64 are expected by LLVM to use the
3036// 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
3339/// This governs whether to use these symbol names for f16/f32 conversions
3440/// rather than the standard names: