authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-12-06 14:07:15+01:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-12-06 14:57:19+01:00
log37a34b54afee183f397cf708ac8d074fa7cc92d6
tree87343a9fd1de152ca6448f6a09ea0eb71e5331d2
parentf8372d030e50b6eec50fd21a387b4d875f81a178
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

compiler: Recognize libgcc_s regardless of target ABI.

The real libgcc_s is a compiler-provided library; it works just fine with both glibc and musl. There's no reason that I can see for this check to be limited to glibc-based targets.

2 files changed, 3 insertions(+), 3 deletions(-)

src/main.zig+1-1
...@@ -3832,7 +3832,7 @@ fn createModule(...@@ -3832,7 +3832,7 @@ fn createModule(
3832 create_module.opts.link_libcpp = true;3832 create_module.opts.link_libcpp = true;
3833 continue;3833 continue;
3834 }3834 }
3835 switch (target_util.classifyCompilerRtLibName(target, lib_name)) {3835 switch (target_util.classifyCompilerRtLibName(lib_name)) {
3836 .none => {},3836 .none => {},
3837 .only_libunwind, .both => {3837 .only_libunwind, .both => {
3838 create_module.opts.link_libunwind = true;3838 create_module.opts.link_libunwind = true;
src/target.zig+2-2
...@@ -260,8 +260,8 @@ pub fn supportsReturnAddress(target: std.Target) bool {...@@ -260,8 +260,8 @@ pub fn supportsReturnAddress(target: std.Target) bool {
260260
261pub const CompilerRtClassification = enum { none, only_compiler_rt, only_libunwind, both };261pub const CompilerRtClassification = enum { none, only_compiler_rt, only_libunwind, both };
262262
263pub fn classifyCompilerRtLibName(target: std.Target, name: []const u8) CompilerRtClassification {263pub fn classifyCompilerRtLibName(name: []const u8) CompilerRtClassification {
264 if (target.abi.isGnu() and std.mem.eql(u8, name, "gcc_s")) {264 if (std.mem.eql(u8, name, "gcc_s")) {
265 // libgcc_s includes exception handling functions, so if linking this library265 // libgcc_s includes exception handling functions, so if linking this library
266 // is requested, zig needs to instead link libunwind. Otherwise we end up with266 // is requested, zig needs to instead link libunwind. Otherwise we end up with
267 // the linker unable to find `_Unwind_RaiseException` and other related symbols.267 // the linker unable to find `_Unwind_RaiseException` and other related symbols.