about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-06-25 12:07:19 +0000
committerbors <bors@rust-lang.org>2019-06-25 12:07:19 +0000
commit40ab9d2bd57a2203131abd723f7120e960299fae (patch)
tree81c9c4ea94173e8fa7fb31b9d9fd6ba7f55fc62d /src
parent10deeae3263301f1d337721ed55c14637b70c3c7 (diff)
parent087cd77d969d9c3cf80f47d4fd8a4379aa48f224 (diff)
downloadrust-40ab9d2bd57a2203131abd723f7120e960299fae.tar.gz
rust-40ab9d2bd57a2203131abd723f7120e960299fae.zip
Auto merge of #61765 - Keruspe:rustbuild-cxx, r=alexcrichton
rustbuild: detect cxx for all targets

Replaces #61544
Fixes #59917

We need CXX to build llvm-libunwind which can be enabled for alltargets.
As we needed it for all hosts anyways, just move the detection so that it is ran for all targets (which contains all hosts) instead.
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap/cc_detect.rs44
1 files changed, 27 insertions, 17 deletions
diff --git a/src/bootstrap/cc_detect.rs b/src/bootstrap/cc_detect.rs
index dfc243b7054..400375cd201 100644
--- a/src/bootstrap/cc_detect.rs
+++ b/src/bootstrap/cc_detect.rs
@@ -95,29 +95,39 @@ pub fn find(build: &mut Build) {
         };
 
         build.cc.insert(target, compiler);
-        build.verbose(&format!("CC_{} = {:?}", &target, build.cc(target)));
-        build.verbose(&format!("CFLAGS_{} = {:?}", &target, build.cflags(target, GitRepo::Rustc)));
-        if let Some(ar) = ar {
-            build.verbose(&format!("AR_{} = {:?}", &target, ar));
-            build.ar.insert(target, ar);
-        }
-    }
+        let cflags = build.cflags(target, GitRepo::Rustc);
 
-    // For all host triples we need to find a C++ compiler as well
-    let hosts = build.hosts.iter().cloned().chain(iter::once(build.build)).collect::<HashSet<_>>();
-    for host in hosts.into_iter() {
+        // If we use llvm-libunwind, we will need a C++ compiler as well for all targets
+        // We'll need one anyways if the target triple is also a host triple
         let mut cfg = cc::Build::new();
         cfg.cargo_metadata(false).opt_level(2).warnings(false).debug(false).cpp(true)
-           .target(&host).host(&build.build);
-        let config = build.config.target_config.get(&host);
-        if let Some(cxx) = config.and_then(|c| c.cxx.as_ref()) {
+            .target(&target).host(&build.build);
+
+        let cxx_configured = if let Some(cxx) = config.and_then(|c| c.cxx.as_ref()) {
             cfg.compiler(cxx);
+            true
+        } else if build.hosts.contains(&target) || build.build == target {
+            set_compiler(&mut cfg, Language::CPlusPlus, target, config, build);
+            true
         } else {
-            set_compiler(&mut cfg, Language::CPlusPlus, host, config, build);
+            false
+        };
+
+        if cxx_configured {
+            let compiler = cfg.get_compiler();
+            build.cxx.insert(target, compiler);
+        }
+
+        build.verbose(&format!("CC_{} = {:?}", &target, build.cc(target)));
+        build.verbose(&format!("CFLAGS_{} = {:?}", &target, cflags));
+        if let Ok(cxx) = build.cxx(target) {
+            build.verbose(&format!("CXX_{} = {:?}", &target, cxx));
+            build.verbose(&format!("CXXFLAGS_{} = {:?}", &target, cflags));
+        }
+        if let Some(ar) = ar {
+            build.verbose(&format!("AR_{} = {:?}", &target, ar));
+            build.ar.insert(target, ar);
         }
-        let compiler = cfg.get_compiler();
-        build.verbose(&format!("CXX_{} = {:?}", host, compiler.path()));
-        build.cxx.insert(host, compiler);
     }
 }