Skip to content

Commit

Permalink
Use --eh-frame-hdr on linux-musl target & ld.lld linker flavour
Browse files Browse the repository at this point in the history
The --eh-frame-hdr is necessary for unwinding but not enabled by default
when using ld.lld linker flavour. Enable it to match existing behaviour
for gcc linker flavour.
  • Loading branch information
tmiasko committed Jun 18, 2020
1 parent e55d3f9 commit 64a18a8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/librustc_target/spec/linux_musl_base.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::spec::crt_objects::{self, CrtObjectsFallback};
use crate::spec::{LinkerFlavor, TargetOptions};
use crate::spec::{LinkerFlavor, LldFlavor, TargetOptions};

pub fn opts() -> TargetOptions {
let mut base = super::linux_base::opts();
Expand All @@ -8,7 +8,11 @@ pub fn opts() -> TargetOptions {
// `GNU_EH_FRAME` program header to executables generated, which is required
// when unwinding to locate the unwinding information. I'm not sure why this
// argument is *not* necessary for normal builds, but it can't hurt!
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,--eh-frame-hdr".to_string());
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-Wl,--eh-frame-hdr".to_string());
base.pre_link_args
.entry(LinkerFlavor::Lld(LldFlavor::Ld))
.or_default()
.push("--eh-frame-hdr".to_string());

base.pre_link_objects_fallback = crt_objects::pre_musl_fallback();
base.post_link_objects_fallback = crt_objects::post_musl_fallback();
Expand Down

0 comments on commit 64a18a8

Please sign in to comment.