about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2016-07-25 10:21:31 -0700
committerJan-Erik Rediger <janerik@fnordig.de>2016-07-29 10:29:44 +0200
commite8f76661f13620f075626d27f94750ea94d6cf2e (patch)
tree02e5152efa17e6049a17e5e42f3a0d22a494d6d4
parentd851428cc352254aed0dd894d1a9970a228ec9ed (diff)
downloadrust-e8f76661f13620f075626d27f94750ea94d6cf2e.tar.gz
rust-e8f76661f13620f075626d27f94750ea94d6cf2e.zip
rustc: Fix data-layout for AArch64 targets
Also relax the assertion whenever we have a custom LLVM root as LLVM may
disagree about exact specifics.
-rw-r--r--src/librustc_back/target/aarch64_linux_android.rs2
-rw-r--r--src/librustc_back/target/aarch64_unknown_linux_gnu.rs2
-rw-r--r--src/librustc_trans/context.rs20
3 files changed, 21 insertions, 3 deletions
diff --git a/src/librustc_back/target/aarch64_linux_android.rs b/src/librustc_back/target/aarch64_linux_android.rs
index 81be546e0c8..a5be1a227f1 100644
--- a/src/librustc_back/target/aarch64_linux_android.rs
+++ b/src/librustc_back/target/aarch64_linux_android.rs
@@ -20,7 +20,7 @@ pub fn target() -> Target {
         llvm_target: "aarch64-linux-android".to_string(),
         target_endian: "little".to_string(),
         target_pointer_width: "64".to_string(),
-        data_layout: "e-m:e-i64:64-i128:128-n32:64-S128".to_string(),
+        data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(),
         arch: "aarch64".to_string(),
         target_os: "android".to_string(),
         target_env: "".to_string(),
diff --git a/src/librustc_back/target/aarch64_unknown_linux_gnu.rs b/src/librustc_back/target/aarch64_unknown_linux_gnu.rs
index aec1bae60c8..2dc9355e22f 100644
--- a/src/librustc_back/target/aarch64_unknown_linux_gnu.rs
+++ b/src/librustc_back/target/aarch64_unknown_linux_gnu.rs
@@ -18,7 +18,7 @@ pub fn target() -> Target {
         target_endian: "little".to_string(),
         target_pointer_width: "64".to_string(),
         target_env: "gnu".to_string(),
-        data_layout: "e-m:e-i64:64-i128:128-n32:64-S128".to_string(),
+        data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(),
         arch: "aarch64".to_string(),
         target_os: "linux".to_string(),
         target_vendor: "unknown".to_string(),
diff --git a/src/librustc_trans/context.rs b/src/librustc_trans/context.rs
index d8b3089bc99..792169b08a4 100644
--- a/src/librustc_trans/context.rs
+++ b/src/librustc_trans/context.rs
@@ -370,7 +370,25 @@ unsafe fn create_context_and_module(sess: &Session, mod_name: &str) -> (ContextR
         let data_layout = str::from_utf8(CStr::from_ptr(data_layout).to_bytes())
             .ok().expect("got a non-UTF8 data-layout from LLVM");
 
-        if sess.target.target.data_layout != data_layout {
+        // Unfortunately LLVM target specs change over time, and right now we
+        // don't have proper support to work with any more than one
+        // `data_layout` than the one that is in the rust-lang/rust repo. If
+        // this compiler is configured against a custom LLVM, we may have a
+        // differing data layout, even though we should update our own to use
+        // that one.
+        //
+        // As an interim hack, if CFG_LLVM_ROOT is not an empty string then we
+        // disable this check entirely as we may be configured with something
+        // that has a different target layout.
+        //
+        // Unsure if this will actually cause breakage when rustc is configured
+        // as such.
+        //
+        // FIXME(#34960)
+        let cfg_llvm_root = option_env!("CFG_LLVM_ROOT").unwrap_or("");
+        let custom_llvm_used = cfg_llvm_root.trim() != "";
+
+        if !custom_llvm_used && sess.target.target.data_layout != data_layout {
             bug!("data-layout for builtin `{}` target, `{}`, \
                   differs from LLVM default, `{}`",
                  sess.target.target.llvm_target,