Skip to content

Commit

Permalink
Rollup merge of rust-lang#65972 - braiins:vkr-arm-panicking, r=alexcr…
Browse files Browse the repository at this point in the history
…ichton

Fix libunwind build: Define __LITTLE_ENDIAN__ for LE targets

If `__LITTLE_ENDIAN__` is missing, libunwind assumes big endian
and reads unwinding instructions wrong on ARM EHABI.

Fix rust-lang#65765

Technical background in referenced bug.

I didn't run any automated tests, just built a simple panicking program using the fixed toolchain and panicking started to work. Tried with `catch_unwind()` and that seems to work now too. libunwind's log seems ok now, I can paste it if needed.
  • Loading branch information
tmandry committed Nov 1, 2019
2 parents 9bf1613 e9e4836 commit 05de0d7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/libunwind/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 56,18 @@ mod llvm_libunwind {
pub fn compile() {
let target_env = env::var("CARGO_CFG_TARGET_ENV").unwrap();
let target_vendor = env::var("CARGO_CFG_TARGET_VENDOR").unwrap();
let target_endian_little = env::var("CARGO_CFG_TARGET_ENDIAN").unwrap() != "big";
let cfg = &mut cc::Build::new();

cfg.cpp(true);
cfg.cpp_set_stdlib(None);
cfg.warnings(false);

// libunwind expects a __LITTLE_ENDIAN__ macro to be set for LE archs, cf. #65765
if target_endian_little {
cfg.define("__LITTLE_ENDIAN__", Some("1"));
}

if target_env == "msvc" {
// Don't pull in extra libraries on MSVC
cfg.flag("/Zl");
Expand Down

0 comments on commit 05de0d7

Please sign in to comment.