diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-02-09 11:36:30 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-02-09 11:38:33 -0700 |
| commit | 2836cd5fbdcbb22b1e03c01005e0e09777c5475f (patch) | |
| tree | e0410656d83b3ed802211e201902e4f0d08f917a /src | |
| parent | db56d74a3bc9c6240d24838753a7042ba91501a1 (diff) | |
| download | zig-2836cd5fbdcbb22b1e03c01005e0e09777c5475f.tar.gz zig-2836cd5fbdcbb22b1e03c01005e0e09777c5475f.zip | |
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 (limited to 'src')
| -rw-r--r-- | src/main.zig | 5 | ||||
| -rw-r--r-- | src/target.zig | 10 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/main.zig b/src/main.zig index 3f38fd1f78..75655d6a2a 100644 --- a/src/main.zig +++ b/src/main.zig @@ -2010,6 +2010,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 index 2c21fb5c61..63bd1db0b5 100644 --- 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(); } |
