commit d2398cf009bfc2f4274f1326b0ef7dfbb1ae8d7f (tree)
parent 0d006afb23aa5d0308adb56d2578b4340f34231e
Author: Andrew Kelley <andrew@ziglang.org>
Date: Wed, 9 Feb 2022 11:36:30 -0700
CLI: ignore -lgcc_s when it is redundant with compiler-rt
For some projects, they can't help themselves, -lgcc_s ends up on the
compiler command line even though it does not belong there. In Zig we
know what -lgcc_s does. It's an alternative to compiler-rt. With this
commit we emit a warning telling that it is unnecessary to put such
thing on the command line, and happily ignore it, since we will fulfill
the dependency with compiler-rt.
Diffstat:
2 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/src/main.zig b/src/main.zig
@@ -1998,6 +1998,11 @@ fn buildOutputType(
_ = system_libs.orderedRemove(lib_name);
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.orderedRemove(lib_name);
+ continue;
+ }
if (std.fs.path.isAbsolute(lib_name)) {
fatal("cannot use absolute path as a system library: {s}", .{lib_name});
}
diff --git a/src/target.zig b/src/target.zig
@@ -427,6 +427,16 @@ pub fn is_libcpp_lib_name(target: std.Target, name: []const u8) bool {
eqlIgnoreCase(ignore_case, name, "c++abi");
}
+pub fn is_compiler_rt_lib_name(target: std.Target, name: []const u8) bool {
+ if (target.abi.isGnu() and std.mem.eql(u8, name, "gcc_s")) {
+ return true;
+ }
+ if (std.mem.eql(u8, name, "compiler_rt")) {
+ return true;
+ }
+ return false;
+}
+
pub fn hasDebugInfo(target: std.Target) bool {
return !target.cpu.arch.isWasm();
}