authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-01-08 18:11:07+01:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-01-18 13:15:58+01:00
log332add7a65003a700c5513f153d8e1362009e35c
tree37e4c580ea8af190e8dc5f270df0326b418fa9a6
parentf38d7a92cc1ca8059ba909a82f2f944966b52296
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

libunwind: Build C files with -fexceptions.

See: https://github.com/llvm/llvm-project/pull/121819 This fixes LTO for libunwind, so also re-enable support for that. Closes #12828.

1 files changed, 8 insertions(+), 9 deletions(-)

src/libunwind.zig+8-9
...@@ -36,8 +36,7 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildErr...@@ -36,8 +36,7 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildErr
36 .root_optimize_mode = comp.compilerRtOptMode(),36 .root_optimize_mode = comp.compilerRtOptMode(),
37 .root_strip = comp.compilerRtStrip(),37 .root_strip = comp.compilerRtStrip(),
38 .link_libc = true,38 .link_libc = true,
39 // Disable LTO to avoid https://github.com/llvm/llvm-project/issues/5682539 .lto = comp.config.lto,
40 .lto = .none,
41 }) catch |err| {40 }) catch |err| {
42 comp.setMiscFailure(41 comp.setMiscFailure(
43 .libunwind,42 .libunwind,
...@@ -102,18 +101,18 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildErr...@@ -102,18 +101,18 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildErr
102101
103 switch (Compilation.classifyFileExt(unwind_src)) {102 switch (Compilation.classifyFileExt(unwind_src)) {
104 .c => {103 .c => {
105 try cflags.append("-std=c17");104 try cflags.appendSlice(&.{
105 "-std=c99",
106 "-fexceptions",
107 });
106 },108 },
107 .cpp => {109 .cpp => {
108 try cflags.appendSlice(&[_][]const u8{110 try cflags.append("-fno-exceptions");
109 "-std=c++17",111 try cflags.append("-fno-rtti");
110 "-fno-rtti",
111 });
112 },112 },
113 .assembly_with_cpp => {},113 .assembly_with_cpp => {},
114 else => unreachable, // You can see the entire list of files just above.114 else => unreachable, // See `unwind_src_list`.
115 }115 }
116 try cflags.append("-fno-exceptions");
117 try cflags.append("-I");116 try cflags.append("-I");
118 try cflags.append(try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libunwind", "include" }));117 try cflags.append(try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libunwind", "include" }));
119 try cflags.append("-D_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS");118 try cflags.append("-D_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS");