about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNathan Froyd <froydnj@gmail.com>2019-04-29 16:57:29 -0400
committerNathan Froyd <froydnj@gmail.com>2019-05-07 11:09:39 -0400
commit1516087ca91f0aa8c9f4f8cb0aa6ff48862043c4 (patch)
treed69fa2c6a07f398c7b0a8de1a1ecca752db1c765
parent758dc9af504e2fe75813bd362619231ecc727898 (diff)
downloadrust-1516087ca91f0aa8c9f4f8cb0aa6ff48862043c4.tar.gz
rust-1516087ca91f0aa8c9f4f8cb0aa6ff48862043c4.zip
add negative tests for OS X LLVM target changes
-rw-r--r--src/test/codegen/i686-no-macosx-deployment-target.rs26
-rw-r--r--src/test/codegen/x86_64-no-macosx-deployment-target.rs26
-rw-r--r--src/tools/compiletest/src/header.rs8
-rw-r--r--src/tools/compiletest/src/runtest.rs3
4 files changed, 63 insertions, 0 deletions
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-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 }
+}
diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs
index fb6ada89171..54e9b76a21e 100644
--- a/src/tools/compiletest/src/header.rs
+++ b/src/tools/compiletest/src/header.rs
@@ -305,6 +305,9 @@ pub struct TestProps {
     pub extern_private: Vec<String>,
     // Environment settings to use for compiling
     pub rustc_env: Vec<(String, String)>,
+    // Environment variables to unset prior to compiling.
+    // Variables are unset before applying 'rustc_env'.
+    pub unset_rustc_env: Vec<String>,
     // Environment settings to use during execution
     pub exec_env: Vec<(String, String)>,
     // Lines to check if they appear in the expected debugger output
@@ -373,6 +376,7 @@ impl TestProps {
             extern_private: vec![],
             revisions: vec![],
             rustc_env: vec![],
+            unset_rustc_env: vec![],
             exec_env: vec![],
             check_lines: vec![],
             build_aux_docs: false,
@@ -499,6 +503,10 @@ impl TestProps {
                 self.rustc_env.push(ee);
             }
 
+            if let Some(ev) = config.parse_name_value_directive(ln, "unset-rustc-env") {
+                self.unset_rustc_env.push(ev);
+            }
+
             if let Some(cl) = config.parse_check_line(ln) {
                 self.check_lines.push(cl);
             }
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
index 42f9cdb7886..d3e39867a31 100644
--- a/src/tools/compiletest/src/runtest.rs
+++ b/src/tools/compiletest/src/runtest.rs
@@ -1692,6 +1692,9 @@ impl<'test> TestCx<'test> {
             add_extern_priv(&private_lib, true);
         }
 
+        self.props.unset_rustc_env.clone()
+            .iter()
+            .fold(&mut rustc, |rustc, v| rustc.env_remove(v));
         rustc.envs(self.props.rustc_env.clone());
         self.compose_and_run(
             rustc,