about summary refs log tree commit diff
path: root/src/test/codegen
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-05-08 08:26:48 +0000
committerbors <bors@rust-lang.org>2019-05-08 08:26:48 +0000
commitb92d360c6cf029bd98c154cb510ec9e11b39bad6 (patch)
tree4c3a4bbca11c0bfc68e57e27b5831e436bc9bb01 /src/test/codegen
parent33cde4aac2ec1b0a493d0acaa4c4fb45de0c6e94 (diff)
parent97ba4c95d00108ac79c86d2bbc6834b1fef008a2 (diff)
downloadrust-b92d360c6cf029bd98c154cb510ec9e11b39bad6.tar.gz
rust-b92d360c6cf029bd98c154cb510ec9e11b39bad6.zip
Auto merge of #60378 - froydnj:apple-target-modifications, r=michaelwoerister
conditionally modify darwin targets to macosx targets with versions

We need this behavior so that Rust LLVM IR objects match the target triple for Clang LLVM IR objects.  This matching then convinces the linker that yes, you really can do cross-language LTO with objects from different compilers.

The newly-added tests seem to pass locally on x86_64-unknown-linux-gnu.  I haven't done a full test run or tried the new compiler in an cross-language LTO setup yet.
Diffstat (limited to 'src/test/codegen')
-rw-r--r--src/test/codegen/i686-macosx-deployment-target.rs26
-rw-r--r--src/test/codegen/i686-no-macosx-deployment-target.rs26
-rw-r--r--src/test/codegen/x86_64-macosx-deployment-target.rs26
-rw-r--r--src/test/codegen/x86_64-no-macosx-deployment-target.rs26
4 files changed, 104 insertions, 0 deletions
diff --git a/src/test/codegen/i686-macosx-deployment-target.rs b/src/test/codegen/i686-macosx-deployment-target.rs
new file mode 100644
index 00000000000..dad376d6677
--- /dev/null
+++ b/src/test/codegen/i686-macosx-deployment-target.rs
@@ -0,0 +1,26 @@
+//
+// Checks that we correctly modify the target when MACOSX_DEPLOYMENT_TARGET is set.
+// See issue #60235.
+
+// compile-flags: -O --target=i686-apple-darwin --crate-type=rlib
+// rustc-env:MACOSX_DEPLOYMENT_TARGET=10.9
+#![feature(no_core, lang_items)]
+#![no_core]
+
+#[lang="sized"]
+trait Sized { }
+#[lang="freeze"]
+trait Freeze { }
+#[lang="copy"]
+trait Copy { }
+
+#[repr(C)]
+pub struct Bool {
+    b: bool,
+}
+
+// CHECK: target triple = "i686-apple-macosx10.9.0"
+#[no_mangle]
+pub extern "C" fn structbool() -> Bool {
+    Bool { b: true }
+}
diff --git a/src/test/codegen/i686-no-macosx-deployment-target.rs b/src/test/codegen/i686-no-macosx-deployment-target.rs
new file mode 100644
index 00000000000..eb826590523
--- /dev/null
+++ b/src/test/codegen/i686-no-macosx-deployment-target.rs
@@ -0,0 +1,26 @@
+//
+// Checks that we leave the target alone MACOSX_DEPLOYMENT_TARGET is unset.
+// See issue #60235.
+
+// compile-flags: -O --target=i686-apple-darwin --crate-type=rlib
+// unset-rustc-env:MACOSX_DEPLOYMENT_TARGET
+#![feature(no_core, lang_items)]
+#![no_core]
+
+#[lang="sized"]
+trait Sized { }
+#[lang="freeze"]
+trait Freeze { }
+#[lang="copy"]
+trait Copy { }
+
+#[repr(C)]
+pub struct Bool {
+    b: bool,
+}
+
+// CHECK: target triple = "i686-apple-darwin"
+#[no_mangle]
+pub extern "C" fn structbool() -> Bool {
+    Bool { b: true }
+}
diff --git a/src/test/codegen/x86_64-macosx-deployment-target.rs b/src/test/codegen/x86_64-macosx-deployment-target.rs
new file mode 100644
index 00000000000..8e291b7b298
--- /dev/null
+++ b/src/test/codegen/x86_64-macosx-deployment-target.rs
@@ -0,0 +1,26 @@
+//
+// Checks that we correctly modify the target when MACOSX_DEPLOYMENT_TARGET is set.
+// See issue #60235.
+
+// compile-flags: -O --target=x86_64-apple-darwin --crate-type=rlib
+// rustc-env:MACOSX_DEPLOYMENT_TARGET=10.9
+#![feature(no_core, lang_items)]
+#![no_core]
+
+#[lang="sized"]
+trait Sized { }
+#[lang="freeze"]
+trait Freeze { }
+#[lang="copy"]
+trait Copy { }
+
+#[repr(C)]
+pub struct Bool {
+    b: bool,
+}
+
+// CHECK: target triple = "x86_64-apple-macosx10.9.0"
+#[no_mangle]
+pub extern "C" fn structbool() -> Bool {
+    Bool { b: true }
+}
diff --git a/src/test/codegen/x86_64-no-macosx-deployment-target.rs b/src/test/codegen/x86_64-no-macosx-deployment-target.rs
new file mode 100644
index 00000000000..58a11d1095b
--- /dev/null
+++ b/src/test/codegen/x86_64-no-macosx-deployment-target.rs
@@ -0,0 +1,26 @@
+//
+// Checks that we leave the target alone when MACOSX_DEPLOYMENT_TARGET is unset.
+// See issue #60235.
+
+// compile-flags: -O --target=x86_64-apple-darwin --crate-type=rlib
+// unset-rustc-env:MACOSX_DEPLOYMENT_TARGET
+#![feature(no_core, lang_items)]
+#![no_core]
+
+#[lang="sized"]
+trait Sized { }
+#[lang="freeze"]
+trait Freeze { }
+#[lang="copy"]
+trait Copy { }
+
+#[repr(C)]
+pub struct Bool {
+    b: bool,
+}
+
+// CHECK: target triple = "x86_64-apple-darwin"
+#[no_mangle]
+pub extern "C" fn structbool() -> Bool {
+    Bool { b: true }
+}