File tree Expand file tree Collapse file tree 3 files changed +12
-21
lines changed Expand file tree Collapse file tree 3 files changed +12
-21
lines changed Original file line number Diff line number Diff line change 1616//! never get replaced.
1717
1818use std:: env;
19- use std:: ffi:: OsString ;
2019use std:: io;
2120use std:: path:: PathBuf ;
2221use std:: process:: Command ;
@@ -97,7 +96,7 @@ fn main() {
9796 cmd. env ( "RUST_BACKTRACE" , "1" ) ;
9897 }
9998
100- if let Some ( target) = target {
99+ if target. is_some ( ) {
101100 // The stage0 compiler has a special sysroot distinct from what we
102101 // actually downloaded, so we just always pass the `--sysroot` option,
103102 // unless one is already set.
@@ -112,23 +111,6 @@ fn main() {
112111 cmd. arg ( "-Cprefer-dynamic" ) ;
113112 }
114113
115- // Help the libc crate compile by assisting it in finding various
116- // sysroot native libraries.
117- if let Some ( s) = env:: var_os ( "MUSL_ROOT" ) {
118- if target. contains ( "musl" ) {
119- let mut root = OsString :: from ( "native=" ) ;
120- root. push ( & s) ;
121- root. push ( "/lib" ) ;
122- cmd. arg ( "-L" ) . arg ( & root) ;
123- }
124- }
125- if let Some ( s) = env:: var_os ( "WASI_ROOT" ) {
126- let mut root = OsString :: from ( "native=" ) ;
127- root. push ( & s) ;
128- root. push ( "/lib/wasm32-wasi" ) ;
129- cmd. arg ( "-L" ) . arg ( & root) ;
130- }
131-
132114 // If we're compiling specifically the `panic_abort` crate then we pass
133115 // the `-C panic=abort` option. Note that we do not do this for any
134116 // other crate intentionally as this is the only crate for now that we
Original file line number Diff line number Diff line change @@ -1375,6 +1375,11 @@ pub struct Cargo {
13751375}
13761376
13771377impl Cargo {
1378+ pub fn rustflag ( & mut self , arg : & str ) -> & mut Cargo {
1379+ self . rustflags . arg ( arg) ;
1380+ self
1381+ }
1382+
13781383 pub fn arg ( & mut self , arg : impl AsRef < OsStr > ) -> & mut Cargo {
13791384 self . command . arg ( arg. as_ref ( ) ) ;
13801385 self
Original file line number Diff line number Diff line change @@ -220,15 +220,19 @@ pub fn std_cargo(builder: &Builder<'_>,
220220 . arg ( "--manifest-path" )
221221 . arg ( builder. src . join ( "src/libtest/Cargo.toml" ) ) ;
222222
223+ // Help the libc crate compile by assisting it in finding various
224+ // sysroot native libraries.
223225 if target. contains ( "musl" ) {
224226 if let Some ( p) = builder. musl_root ( target) {
225- cargo. env ( "MUSL_ROOT" , p) ;
227+ let root = format ! ( "native={}/lib" , p. to_str( ) . unwrap( ) ) ;
228+ cargo. rustflag ( "-L" ) . rustflag ( & root) ;
226229 }
227230 }
228231
229232 if target. ends_with ( "-wasi" ) {
230233 if let Some ( p) = builder. wasi_root ( target) {
231- cargo. env ( "WASI_ROOT" , p) ;
234+ let root = format ! ( "native={}/lib/wasm32-wasi" , p. to_str( ) . unwrap( ) ) ;
235+ cargo. rustflag ( "-L" ) . rustflag ( & root) ;
232236 }
233237 }
234238 }
You can’t perform that action at this time.
0 commit comments