authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2021-01-08 12:48:30+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-01-08 19:01:05-08:00
logeb696e453ff770e54188e14acb65e01e87a4eebd
tree9140cd25bdd0c2249cb518d41a26095e96b77810
parent95e66a915b24cb3763707888ffa9726c01905a37

stage2: Implicitly enable --eh_frame_hdr when compiling c/c++ files

Matches what Clang/GCC driver do. Closes #7711

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

src/main.zig+9
......@@ -1007,6 +1007,11 @@ fn buildOutputType(
10071007 ensure_libc_on_non_freestanding = true;
10081008 ensure_libcpp_on_non_freestanding = arg_mode == .cpp;
10091009 want_native_include_dirs = true;
1010 // Clang's driver enables this switch unconditionally.
1011 // Disabling the emission of .eh_frame_hdr can unexpectedly break
1012 // some functionality that depend on it, such as C++ exceptions and
1013 // DWARF-based stack traces.
1014 link_eh_frame_hdr = true;
10101015
10111016 const COutMode = enum {
10121017 link,
......@@ -1274,6 +1279,10 @@ fn buildOutputType(
12741279 image_base_override = std.fmt.parseUnsigned(u64, linker_args.items[i], 0) catch |err| {
12751280 fatal("unable to parse '{s}': {s}", .{ arg, @errorName(err) });
12761281 };
1282 } else if (mem.eql(u8, arg, "--eh-frame-hdr")) {
1283 link_eh_frame_hdr = true;
1284 } else if (mem.eql(u8, arg, "--no-eh-frame-hdr")) {
1285 link_eh_frame_hdr = false;
12771286 } else {
12781287 warn("unsupported linker arg: {s}", .{arg});
12791288 }