Skip to content

Commit 08ca5d9

Browse files
committed
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.
1 parent ec666a5 commit 08ca5d9

File tree

3 files changed

+36
-12
lines changed

3 files changed

+36
-12
lines changed

src/bootstrap/build/mod.rs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,13 @@ impl Build {
312312
if !target.contains("msvc") {
313313
cargo.env(format!("CC_{}", target), self.cc(target))
314314
.env(format!("AR_{}", target), self.ar(target))
315-
.env(format!("CFLAGS_{}", target), self.cflags(target));
315+
.env(format!("CFLAGS_{}", target), self.cflags(target).join(" "));
316+
}
317+
318+
// If we're building for OSX, inform the compiler and the linker that
319+
// we want to build a compiler runnable on 10.7
320+
if target.contains("apple-darwin") {
321+
cargo.env("MACOSX_DEPLOYMENT_TARGET", "10.7");
316322
}
317323

318324
// Environment variables *required* needed throughout the build
@@ -481,11 +487,20 @@ impl Build {
481487
self.cc[target].0.path()
482488
}
483489

484-
fn cflags(&self, target: &str) -> String {
485-
self.cc[target].0.args().iter()
486-
.map(|s| s.to_string_lossy())
487-
.collect::<Vec<_>>()
488-
.join(" ")
490+
fn cflags(&self, target: &str) -> Vec<String> {
491+
let mut base = self.cc[target].0.args().iter()
492+
.map(|s| s.to_string_lossy().into_owned())
493+
.collect::<Vec<_>>();
494+
495+
// If we're compiling on OSX then we add a few unconditional flags
496+
// indicating that we want libc++ (more filled out than libstdc++) and
497+
// we want to compile for 10.7. This way we can ensure that
498+
// LLVM/jemalloc/etc are all properly compiled.
499+
if target.contains("apple-darwin") {
500+
base.push("-stdlib=libc++".into());
501+
base.push("-mmacosx-version-min=10.7".into());
502+
}
503+
return base
489504
}
490505

491506
fn ar(&self, target: &str) -> &Path {

src/bootstrap/build/native.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ pub fn llvm(build: &Build, target: &str) {
8686
.define("CMAKE_CXX_COMPILER", build.cxx(target));
8787
}
8888
cfg.build_arg("-j").build_arg(build.jobs().to_string());
89+
90+
cfg.define("CMAKE_C_FLAGS", build.cflags(target).join(" "));
91+
cfg.define("CMAKE_CXX_FLAGS", build.cflags(target).join(" "));
8992
}
9093

9194
// FIXME: we don't actually need to build all LLVM tools and all LLVM

src/rustc/Cargo.lock

Lines changed: 12 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)