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.
This commit is contained in:
bors 2016-04-02 10:30:03 -07:00
commit 3ec71b033a
3 changed files with 24 additions and 12 deletions

View File

@ -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 {

View File

@ -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

6
src/rustc/Cargo.lock generated
View File

@ -76,7 +76,6 @@ dependencies = [
"rustc_const_eval 0.0.0",
"rustc_data_structures 0.0.0",
"rustc_front 0.0.0",
"rustc_llvm 0.0.0",
"serialize 0.0.0",
"syntax 0.0.0",
]
@ -87,7 +86,6 @@ version = "0.0.0"
dependencies = [
"log 0.0.0",
"rustc_front 0.0.0",
"rustc_llvm 0.0.0",
"serialize 0.0.0",
"syntax 0.0.0",
]
@ -227,10 +225,6 @@ dependencies = [
[[package]]
name = "rustc_platform_intrinsics"
version = "0.0.0"
dependencies = [
"rustc 0.0.0",
"rustc_llvm 0.0.0",
]
[[package]]
name = "rustc_plugin"