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 16
16
//! never get replaced.
17
17
18
18
use std:: env;
19
- use std:: ffi:: OsString ;
20
19
use std:: io;
21
20
use std:: path:: PathBuf ;
22
21
use std:: process:: Command ;
@@ -97,7 +96,7 @@ fn main() {
97
96
cmd. env ( "RUST_BACKTRACE" , "1" ) ;
98
97
}
99
98
100
- if let Some ( target) = target {
99
+ if target. is_some ( ) {
101
100
// The stage0 compiler has a special sysroot distinct from what we
102
101
// actually downloaded, so we just always pass the `--sysroot` option,
103
102
// unless one is already set.
@@ -112,23 +111,6 @@ fn main() {
112
111
cmd. arg ( "-Cprefer-dynamic" ) ;
113
112
}
114
113
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
-
132
114
// If we're compiling specifically the `panic_abort` crate then we pass
133
115
// the `-C panic=abort` option. Note that we do not do this for any
134
116
// 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 {
1375
1375
}
1376
1376
1377
1377
impl Cargo {
1378
+ pub fn rustflag ( & mut self , arg : & str ) -> & mut Cargo {
1379
+ self . rustflags . arg ( arg) ;
1380
+ self
1381
+ }
1382
+
1378
1383
pub fn arg ( & mut self , arg : impl AsRef < OsStr > ) -> & mut Cargo {
1379
1384
self . command . arg ( arg. as_ref ( ) ) ;
1380
1385
self
Original file line number Diff line number Diff line change @@ -220,15 +220,19 @@ pub fn std_cargo(builder: &Builder<'_>,
220
220
. arg ( "--manifest-path" )
221
221
. arg ( builder. src . join ( "src/libtest/Cargo.toml" ) ) ;
222
222
223
+ // Help the libc crate compile by assisting it in finding various
224
+ // sysroot native libraries.
223
225
if target. contains ( "musl" ) {
224
226
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) ;
226
229
}
227
230
}
228
231
229
232
if target. ends_with ( "-wasi" ) {
230
233
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) ;
232
236
}
233
237
}
234
238
}
You can’t perform that action at this time.
0 commit comments