summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2019-09-09 10:21:15 -0700
committerAlex Crichton <alex@alexcrichton.com>2019-09-23 09:34:44 -0700
commit3d13f463045417903364c44a67b0963ececde79f (patch)
tree4d9b26497fdd16a7a1b1208cdb784e9d98dd9c6f /src/bootstrap
parent0b6766d8d7461a1a8d632ff62ba2024be87fed76 (diff)
downloadrust-3d13f463045417903364c44a67b0963ececde79f.tar.gz
rust-3d13f463045417903364c44a67b0963ececde79f.zip
Move handling of `{MUSL,WASI}_ROOT` to `compile.rs`
No longer any need for them to live in `rustc.rs`!
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/bin/rustc.rs20
-rw-r--r--src/bootstrap/builder.rs5
-rw-r--r--src/bootstrap/compile.rs8
3 files changed, 12 insertions, 21 deletions
diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs
index df7ed48c186..8c460c59f07 100644
--- a/src/bootstrap/bin/rustc.rs
+++ b/src/bootstrap/bin/rustc.rs
@@ -16,7 +16,6 @@
 //! never get replaced.
 
 use std::env;
-use std::ffi::OsString;
 use std::io;
 use std::path::PathBuf;
 use std::process::Command;
@@ -97,7 +96,7 @@ fn main() {
         cmd.env("RUST_BACKTRACE", "1");
     }
 
-    if let Some(target) = target {
+    if target.is_some() {
         // The stage0 compiler has a special sysroot distinct from what we
         // actually downloaded, so we just always pass the `--sysroot` option,
         // unless one is already set.
@@ -112,23 +111,6 @@ fn main() {
             cmd.arg("-Cprefer-dynamic");
         }
 
-        // Help the libc crate compile by assisting it in finding various
-        // sysroot native libraries.
-        if let Some(s) = env::var_os("MUSL_ROOT") {
-            if target.contains("musl") {
-                let mut root = OsString::from("native=");
-                root.push(&s);
-                root.push("/lib");
-                cmd.arg("-L").arg(&root);
-            }
-        }
-        if let Some(s) = env::var_os("WASI_ROOT") {
-            let mut root = OsString::from("native=");
-            root.push(&s);
-            root.push("/lib/wasm32-wasi");
-            cmd.arg("-L").arg(&root);
-        }
-
         // If we're compiling specifically the `panic_abort` crate then we pass
         // the `-C panic=abort` option. Note that we do not do this for any
         // other crate intentionally as this is the only crate for now that we
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
index a039f7b8c85..6a483c1fafd 100644
--- a/src/bootstrap/builder.rs
+++ b/src/bootstrap/builder.rs
@@ -1375,6 +1375,11 @@ pub struct Cargo {
 }
 
 impl Cargo {
+    pub fn rustflag(&mut self, arg: &str) -> &mut Cargo {
+        self.rustflags.arg(arg);
+        self
+    }
+
     pub fn arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Cargo {
         self.command.arg(arg.as_ref());
         self
diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
index c63856b6f6e..dc0961d16e8 100644
--- a/src/bootstrap/compile.rs
+++ b/src/bootstrap/compile.rs
@@ -220,15 +220,19 @@ pub fn std_cargo(builder: &Builder<'_>,
             .arg("--manifest-path")
             .arg(builder.src.join("src/libtest/Cargo.toml"));
 
+        // Help the libc crate compile by assisting it in finding various
+        // sysroot native libraries.
         if target.contains("musl") {
             if let Some(p) = builder.musl_root(target) {
-                cargo.env("MUSL_ROOT", p);
+                let root = format!("native={}/lib", p.to_str().unwrap());
+                cargo.rustflag("-L").rustflag(&root);
             }
         }
 
         if target.ends_with("-wasi") {
             if let Some(p) = builder.wasi_root(target) {
-                cargo.env("WASI_ROOT", p);
+                let root = format!("native={}/lib/wasm32-wasi", p.to_str().unwrap());
+                cargo.rustflag("-L").rustflag(&root);
             }
         }
     }