about summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authorIan Douglas Scott <ian@iandouglasscott.com>2017-06-22 11:51:32 -0700
committerIan Douglas Scott <ian@iandouglasscott.com>2017-06-22 11:51:32 -0700
commitf98ffb5bc348d1b11f10ebd5f4c5e2fe2813e167 (patch)
treecfc7e212079d0b2cf681ff3ae768cad177ad58b9 /src/bootstrap
parent526afcb0a341c6036c069e113ebecf574c861c9f (diff)
downloadrust-f98ffb5bc348d1b11f10ebd5f4c5e2fe2813e167.tar.gz
rust-f98ffb5bc348d1b11f10ebd5f4c5e2fe2813e167.zip
Make Build.cxx() return a Result instead of panicking
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/check.rs2
-rw-r--r--src/bootstrap/compile.rs2
-rw-r--r--src/bootstrap/lib.rs17
-rw-r--r--src/bootstrap/native.rs2
-rw-r--r--src/bootstrap/sanity.rs2
5 files changed, 14 insertions, 11 deletions
diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs
index 068efe18cce..277728b90b7 100644
--- a/src/bootstrap/check.rs
+++ b/src/bootstrap/check.rs
@@ -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());
diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
index f92a199fa3f..c8ab3a8fc1d 100644
--- a/src/bootstrap/compile.rs
+++ b/src/bootstrap/compile.rs
@@ -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");
diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
index 3a43cc0c29d..ce7cde8fc94 100644
--- a/src/bootstrap/lib.rs
+++ b/src/bootstrap/lib.rs
@@ -450,9 +450,12 @@ impl Build {
         // 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) {
@@ -839,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))
         }
     }
 
diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs
index a23be37b15e..f150df6cdcd 100644
--- a/src/bootstrap/native.rs
+++ b/src/bootstrap/native.rs
@@ -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") &&
diff --git a/src/bootstrap/sanity.rs b/src/bootstrap/sanity.rs
index 5ccd131b77a..46d047bb015 100644
--- a/src/bootstrap/sanity.rs
+++ b/src/bootstrap/sanity.rs
@@ -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