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());
!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");
// FIXME: the guard against msvc shouldn't need to be here
if !target.contains("msvc") {
cargo.env(format!("CC_{}", target), self.cc(target))
- .env(format!("CXX_{}", target), self.cxx(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) {
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))
}
}