aboutsummaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-02-23 13:25:10 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-02-23 13:25:10 -0700
commit88d1258e08e668e620d5f8f4681315e555acbcd2 (patch)
tree930e8dabe93e60af9fc4f0e54c17e07db2672aa1 /src/main.zig
parentacec06cfaf9a82ec8037a23993ff36fa72eb6e82 (diff)
downloadzig-88d1258e08e668e620d5f8f4681315e555acbcd2.tar.gz
zig-88d1258e08e668e620d5f8f4681315e555acbcd2.zip
stage2: make -lgcc_s additionally link libunwind
Previously, Zig ignored -lgcc_s with a warning that this dependency is redundant because it is satisfied by compiler-rt. However, sfackler pointed out that it also provides exception handling functions. So if Zig sees -lgcc_s on the linker line, it needs to fulfill this dependency with libunwind. I also made link_libc inferred to be on if libunwind is linked since libunwind depends on libc.
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/main.zig b/src/main.zig
index 32275c4cf3..ff78d16803 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -2048,19 +2048,24 @@ fn buildOutputType(
system_libs.orderedRemoveAt(i);
continue;
}
- if (mem.eql(u8, lib_name, "unwind")) {
- link_libunwind = true;
- system_libs.orderedRemoveAt(i);
- continue;
- }
- if (target_util.is_compiler_rt_lib_name(target_info.target, lib_name)) {
- std.log.warn("ignoring superfluous library '{s}': this dependency is fulfilled instead by compiler-rt which zig unconditionally provides", .{lib_name});
- system_libs.orderedRemoveAt(i);
- continue;
+ switch (target_util.classifyCompilerRtLibName(target_info.target, lib_name)) {
+ .none => {},
+ .only_libunwind, .both => {
+ link_libunwind = true;
+ system_libs.orderedRemoveAt(i);
+ continue;
+ },
+ .only_compiler_rt => {
+ std.log.warn("ignoring superfluous library '{s}': this dependency is fulfilled instead by compiler-rt which zig unconditionally provides", .{lib_name});
+ system_libs.orderedRemoveAt(i);
+ continue;
+ },
}
+
if (std.fs.path.isAbsolute(lib_name)) {
fatal("cannot use absolute path as a system library: {s}", .{lib_name});
}
+
if (target_info.target.os.tag == .wasi) {
if (wasi_libc.getEmulatedLibCRTFile(lib_name)) |crt_file| {
try wasi_emulated_libs.append(crt_file);