Skip to content

Commit 9df994c

Browse files
authored
Rollup merge of rust-lang#65972 - braiins:vkr-arm-panicking, r=alexcrichton
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.
2 parents 71bba23 + e9e4836 commit 9df994c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/libunwind/build.rs

+6
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,18 @@ mod llvm_libunwind {
5656
pub fn compile() {
5757
let target_env = env::var("CARGO_CFG_TARGET_ENV").unwrap();
5858
let target_vendor = env::var("CARGO_CFG_TARGET_VENDOR").unwrap();
59+
let target_endian_little = env::var("CARGO_CFG_TARGET_ENDIAN").unwrap() != "big";
5960
let cfg = &mut cc::Build::new();
6061

6162
cfg.cpp(true);
6263
cfg.cpp_set_stdlib(None);
6364
cfg.warnings(false);
6465

66+
// libunwind expects a __LITTLE_ENDIAN__ macro to be set for LE archs, cf. #65765
67+
if target_endian_little {
68+
cfg.define("__LITTLE_ENDIAN__", Some("1"));
69+
}
70+
6571
if target_env == "msvc" {
6672
// Don't pull in extra libraries on MSVC
6773
cfg.flag("/Zl");

0 commit comments

Comments
 (0)