aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLemonBoy <thatlemon@gmail.com>2021-01-08 12:48:30 +0100
committerAndrew Kelley <andrew@ziglang.org>2021-01-08 19:01:05 -0800
commiteb696e453ff770e54188e14acb65e01e87a4eebd (patch)
tree9140cd25bdd0c2249cb518d41a26095e96b77810 /src
parent95e66a915b24cb3763707888ffa9726c01905a37 (diff)
downloadzig-eb696e453ff770e54188e14acb65e01e87a4eebd.tar.gz
zig-eb696e453ff770e54188e14acb65e01e87a4eebd.zip
stage2: Implicitly enable --eh_frame_hdr when compiling c/c++ files
Matches what Clang/GCC driver do. Closes #7711
Diffstat (limited to 'src')
-rw-r--r--src/main.zig9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/main.zig b/src/main.zig
index 7829901acc..668e601475 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -1007,6 +1007,11 @@ fn buildOutputType(
ensure_libc_on_non_freestanding = true;
ensure_libcpp_on_non_freestanding = arg_mode == .cpp;
want_native_include_dirs = true;
+ // Clang's driver enables this switch unconditionally.
+ // Disabling the emission of .eh_frame_hdr can unexpectedly break
+ // some functionality that depend on it, such as C++ exceptions and
+ // DWARF-based stack traces.
+ link_eh_frame_hdr = true;
const COutMode = enum {
link,
@@ -1274,6 +1279,10 @@ fn buildOutputType(
image_base_override = std.fmt.parseUnsigned(u64, linker_args.items[i], 0) catch |err| {
fatal("unable to parse '{s}': {s}", .{ arg, @errorName(err) });
};
+ } else if (mem.eql(u8, arg, "--eh-frame-hdr")) {
+ link_eh_frame_hdr = true;
+ } else if (mem.eql(u8, arg, "--no-eh-frame-hdr")) {
+ link_eh_frame_hdr = false;
} else {
warn("unsupported linker arg: {s}", .{arg});
}