Skip to content

Commit 3ec71b0

Browse files
committed
Auto merge of rust-lang#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.
2 parents 1af79cf + 08ca5d9 commit 3ec71b0

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

src/bootstrap/build/mod.rs

+21-6
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,13 @@ impl Build {
326326
if !target.contains("msvc") {
327327
cargo.env(format!("CC_{}", target), self.cc(target))
328328
.env(format!("AR_{}", target), self.ar(target))
329-
.env(format!("CFLAGS_{}", target), self.cflags(target));
329+
.env(format!("CFLAGS_{}", target), self.cflags(target).join(" "));
330+
}
331+
332+
// If we're building for OSX, inform the compiler and the linker that
333+
// we want to build a compiler runnable on 10.7
334+
if target.contains("apple-darwin") {
335+
cargo.env("MACOSX_DEPLOYMENT_TARGET", "10.7");
330336
}
331337

332338
// Environment variables *required* needed throughout the build
@@ -497,11 +503,20 @@ impl Build {
497503
self.cc[target].0.path()
498504
}
499505

500-
fn cflags(&self, target: &str) -> String {
501-
self.cc[target].0.args().iter()
502-
.map(|s| s.to_string_lossy())
503-
.collect::<Vec<_>>()
504-
.join(" ")
506+
fn cflags(&self, target: &str) -> Vec<String> {
507+
let mut base = self.cc[target].0.args().iter()
508+
.map(|s| s.to_string_lossy().into_owned())
509+
.collect::<Vec<_>>();
510+
511+
// If we're compiling on OSX then we add a few unconditional flags
512+
// indicating that we want libc++ (more filled out than libstdc++) and
513+
// we want to compile for 10.7. This way we can ensure that
514+
// LLVM/jemalloc/etc are all properly compiled.
515+
if target.contains("apple-darwin") {
516+
base.push("-stdlib=libc++".into());
517+
base.push("-mmacosx-version-min=10.7".into());
518+
}
519+
return base
505520
}
506521

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

src/bootstrap/build/native.rs

+3
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

-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)