]> git.lizzy.rs Git - rust.git/blobdiff - src/libunwind/build.rs
Update option.rs
[rust.git] / src / libunwind / build.rs
index f24d957d67b7588ed323aebdc9ce123a91f6966f..a24808b32506f7d9511ae64adb170f132e3edb5b 100644 (file)
@@ -4,9 +4,9 @@ fn main() {
     println!("cargo:rerun-if-changed=build.rs");
     let target = env::var("TARGET").expect("TARGET was not set");
 
-    if cfg!(feature = "llvm-libunwind") &&
-        ((target.contains("linux") && !target.contains("musl")) ||
-         target.contains("fuchsia")) {
+    if cfg!(feature = "llvm-libunwind")
+        && ((target.contains("linux") && !target.contains("musl")) || target.contains("fuchsia"))
+    {
         // Build the unwinding from libunwind C/C++ source code.
         llvm_libunwind::compile();
     } else if target.contains("linux") {
@@ -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");