Skip to content

Commit

Permalink
Merge pull request #22524 from alexrp/libunwind-exceptions
Browse files Browse the repository at this point in the history
`libunwind`: Build C files with `-fexceptions`.
  • Loading branch information
alexrp authored Jan 19, 2025
2 parents 8ee80d6 + 332add7 commit 0ead0be
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/libunwind.zig
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildErr
.root_optimize_mode = comp.compilerRtOptMode(),
.root_strip = comp.compilerRtStrip(),
.link_libc = true,
// Disable LTO to avoid https://github.com/llvm/llvm-project/issues/56825
.lto = .none,
.lto = comp.config.lto,
}) catch |err| {
comp.setMiscFailure(
.libunwind,
Expand Down Expand Up @@ -102,18 +101,18 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildErr

switch (Compilation.classifyFileExt(unwind_src)) {
.c => {
try cflags.append("-std=c17");
try cflags.appendSlice(&.{
"-std=c99",
"-fexceptions",
});
},
.cpp => {
try cflags.appendSlice(&[_][]const u8{
"-std=c++17",
"-fno-rtti",
});
try cflags.append("-fno-exceptions");
try cflags.append("-fno-rtti");
},
.assembly_with_cpp => {},
else => unreachable, // You can see the entire list of files just above.
else => unreachable, // See `unwind_src_list`.
}
try cflags.append("-fno-exceptions");
try cflags.append("-I");
try cflags.append(try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libunwind", "include" }));
try cflags.append("-D_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS");
Expand Down

0 comments on commit 0ead0be

Please sign in to comment.