Skip to content

Commit

Permalink
Rollup merge of rust-lang#42829 - ids1024:cxx, r=alexcrichton
Browse files Browse the repository at this point in the history
Set CXX_<target> in bootstrap

I came across this trying to cross-compile rustc for Redox. It was also mentioned in a comment on rust-lang#42206, but doesn't seem to have been corrected.
  • Loading branch information
Mark-Simulacrum authored Jun 22, 2017
2 parents a199b0a + f98ffb5 commit 227536c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/bootstrap/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ pub fn compiletest(build: &Build,
let llvm_components = output(Command::new(&llvm_config).arg("--components"));
let llvm_cxxflags = output(Command::new(&llvm_config).arg("--cxxflags"));
cmd.arg("--cc").arg(build.cc(target))
.arg("--cxx").arg(build.cxx(target))
.arg("--cxx").arg(build.cxx(target).unwrap())
.arg("--cflags").arg(build.cflags(target).join(" "))
.arg("--llvm-components").arg(llvm_components.trim())
.arg("--llvm-cxxflags").arg(llvm_cxxflags.trim());
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ pub fn rustc(build: &Build, target: &str, compiler: &Compiler) {
!target.contains("windows") &&
!target.contains("apple") {
cargo.env("LLVM_STATIC_STDCPP",
compiler_file(build.cxx(target), "libstdc++.a"));
compiler_file(build.cxx(target).unwrap(), "libstdc++.a"));
}
if build.config.llvm_link_shared {
cargo.env("LLVM_LINK_SHARED", "1");
Expand Down
16 changes: 10 additions & 6 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,10 @@ impl Build {
cargo.env(format!("CC_{}", target), self.cc(target))
.env(format!("AR_{}", target), self.ar(target).unwrap()) // only msvc is None
.env(format!("CFLAGS_{}", target), self.cflags(target).join(" "));

if let Ok(cxx) = self.cxx(target) {
cargo.env(format!("CXX_{}", target), cxx);
}
}

if self.config.extended && compiler.is_final_stage(self) {
Expand Down Expand Up @@ -838,13 +842,13 @@ impl Build {
self.cc[target].1.as_ref().map(|p| &**p)
}

/// Returns the path to the C++ compiler for the target specified, may panic
/// if no C++ compiler was configured for the target.
fn cxx(&self, target: &str) -> &Path {
/// Returns the path to the C++ compiler for the target specified.
fn cxx(&self, target: &str) -> Result<&Path, String> {
match self.cxx.get(target) {
Some(p) => p.path(),
None => panic!("\n\ntarget `{}` is not configured as a host,
only as a target\n\n", target),
Some(p) => Ok(p.path()),
None => Err(format!(
"target `{}` is not configured as a host, only as a target",
target))
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ pub fn llvm(build: &Build, target: &str) {
}

let cc = build.cc(target);
let cxx = build.cxx(target);
let cxx = build.cxx(target).unwrap();

// Handle msvc + ninja + ccache specially (this is what the bots use)
if target.contains("msvc") &&
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/sanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ pub fn check(build: &mut Build) {
}
}
for host in build.config.host.iter() {
need_cmd(build.cxx(host).as_ref());
need_cmd(build.cxx(host).unwrap().as_ref());
}

// The msvc hosts don't use jemalloc, turn it off globally to
Expand Down

0 comments on commit 227536c

Please sign in to comment.