Move handling of {MUSL,WASI}_ROOT
to compile.rs
No longer any need for them to live in `rustc.rs`!
This commit is contained in:
parent
0b6766d8d7
commit
3d13f46304
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user