about summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-04-02 10:30:03 -0700
committerbors <bors@rust-lang.org>2016-04-02 10:30:03 -0700
commit3ec71b033a81f2a7d7c24db265d1e1c2c437339a (patch)
tree4b14c3469710215dff674b17c33b1518c84c6b04 /src/bootstrap
parent1af79cf34e1fd6f38ba256631e2997ca650e490b (diff)
parent08ca5d955832ee412250a776ce811c9d6abf2100 (diff)
downloadrust-3ec71b033a81f2a7d7c24db265d1e1c2c437339a.tar.gz
rust-3ec71b033a81f2a7d7c24db265d1e1c2c437339a.zip
Auto merge of #32598 - alexcrichton:rustbuild-osx, r=aturon
rustbuild: Fix compile on OSX for 10.7

This commit should help configure our OSX rustbuild builder for targeting 10.7.
A key part of this is using `libc++` instead of `libstdc++` as apparently it's
more filled out and otherwise LLVM's cmake configuration would fail.
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/build/mod.rs27
-rw-r--r--src/bootstrap/build/native.rs3
2 files changed, 24 insertions, 6 deletions
diff --git a/src/bootstrap/build/mod.rs b/src/bootstrap/build/mod.rs
index bd217940bfb..248bf6cb4ea 100644
--- a/src/bootstrap/build/mod.rs
+++ b/src/bootstrap/build/mod.rs
@@ -326,7 +326,13 @@ impl Build {
         if !target.contains("msvc") {
             cargo.env(format!("CC_{}", target), self.cc(target))
                  .env(format!("AR_{}", target), self.ar(target))
-                 .env(format!("CFLAGS_{}", target), self.cflags(target));
+                 .env(format!("CFLAGS_{}", target), self.cflags(target).join(" "));
+        }
+
+        // If we're building for OSX, inform the compiler and the linker that
+        // we want to build a compiler runnable on 10.7
+        if target.contains("apple-darwin") {
+            cargo.env("MACOSX_DEPLOYMENT_TARGET", "10.7");
         }
 
         // Environment variables *required* needed throughout the build
@@ -497,11 +503,20 @@ impl Build {
         self.cc[target].0.path()
     }
 
-    fn cflags(&self, target: &str) -> String {
-        self.cc[target].0.args().iter()
-            .map(|s| s.to_string_lossy())
-            .collect::<Vec<_>>()
-            .join(" ")
+    fn cflags(&self, target: &str) -> Vec<String> {
+        let mut base = self.cc[target].0.args().iter()
+                           .map(|s| s.to_string_lossy().into_owned())
+                           .collect::<Vec<_>>();
+
+        // If we're compiling on OSX then we add a few unconditional flags
+        // indicating that we want libc++ (more filled out than libstdc++) and
+        // we want to compile for 10.7. This way we can ensure that
+        // LLVM/jemalloc/etc are all properly compiled.
+        if target.contains("apple-darwin") {
+            base.push("-stdlib=libc++".into());
+            base.push("-mmacosx-version-min=10.7".into());
+        }
+        return base
     }
 
     fn ar(&self, target: &str) -> &Path {
diff --git a/src/bootstrap/build/native.rs b/src/bootstrap/build/native.rs
index b3bd6b92299..bf0494bcd8c 100644
--- a/src/bootstrap/build/native.rs
+++ b/src/bootstrap/build/native.rs
@@ -86,6 +86,9 @@ pub fn llvm(build: &Build, target: &str) {
               .define("CMAKE_CXX_COMPILER", build.cxx(target));
         }
         cfg.build_arg("-j").build_arg(build.jobs().to_string());
+
+        cfg.define("CMAKE_C_FLAGS", build.cflags(target).join(" "));
+        cfg.define("CMAKE_CXX_FLAGS", build.cflags(target).join(" "));
     }
 
     // FIXME: we don't actually need to build all LLVM tools and all LLVM