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.
This commit is contained in:
Andrew Kelley 2022-02-09 11:36:30 -07:00
parent 0d006afb23
commit d2398cf009
2 changed files with 15 additions and 0 deletions

View File

@ -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});
}

View File

@ -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();
}