@@ -87,7 +87,7 @@ fn setup() -> Setup {
87
87
let p = ProjectBuilder :: new ( paths:: root ( ) . join ( "rustc-wrapper" ) )
88
88
. file (
89
89
"src/main.rs" ,
90
- r#"
90
+ & r#"
91
91
use std::process::Command;
92
92
use std::env;
93
93
fn main() {
@@ -97,29 +97,27 @@ fn setup() -> Setup {
97
97
if is_sysroot_crate {
98
98
args.push("--sysroot".to_string());
99
99
args.push(env::var("REAL_SYSROOT").unwrap());
100
- } else if args.iter().any (|arg| arg == "--target") {
100
+ } else if let Some(pos) = args.iter().position (|arg| arg == "--target") {
101
101
// build-std target unit
102
- //
103
- // This `--sysroot` is here to disable the sysroot lookup,
104
- // to ensure nothing is required.
105
- // See https://github.com/rust-lang/wg-cargo-std-aware/issues/31
106
- // for more information on this.
107
- //
108
- // FIXME: this is broken on x86_64-unknown-linux-gnu
109
- // due to https://github.com/rust-lang/rust/pull/124129,
110
- // because it requires lld in the sysroot. See
111
- // https://github.com/rust-lang/rust/issues/125246 for
112
- // more information.
113
- // args.push("--sysroot".to_string());
114
- // args.push("/path/to/nowhere".to_string());
102
+
103
+ // Set --sysroot only when the target is host
104
+ if args.iter().nth(pos + 1) == Some(&"__HOST_TARGET__".to_string()) {
105
+ // This `--sysroot` is here to disable the sysroot lookup,
106
+ // to ensure nothing is required.
107
+ // See https://github.com/rust-lang/wg-cargo-std-aware/issues/31
108
+ // for more information on this.
109
+ args.push("--sysroot".to_string());
110
+ args.push("/path/to/nowhere".to_string());
111
+ }
115
112
} else {
116
113
// host unit, do not use sysroot
117
114
}
118
115
119
116
let ret = Command::new(&args[0]).args(&args[1..]).status().unwrap();
120
117
std::process::exit(ret.code().unwrap_or(1));
121
118
}
122
- "# ,
119
+ "#
120
+ . replace ( "__HOST_TARGET__" , rustc_host ( ) ) ,
123
121
)
124
122
. build ( ) ;
125
123
p. cargo ( "build" ) . run ( ) ;
@@ -298,20 +296,16 @@ fn shared_std_dependency_rebuild() {
298
296
"# ] ] )
299
297
. run ( ) ;
300
298
301
- // TODO: Because of the way in which std is resolved, it's mandatory that this is left commented
302
- // out as it will fail. This case should result in `dep_test` only being built once, however
303
- // it's still being built twice. This is a bug.
304
- //
305
- // p.cargo("build -v")
306
- // .build_std(&setup)
307
- // .with_stderr_does_not_contain(str![[r#"
308
- //...
309
- //[RUNNING] `[..] rustc --crate-name dep_test [..]`
310
- //...
311
- //[RUNNING] `[..] rustc --crate-name dep_test [..]`
312
- //...
313
- //"#]])
314
- // .run();
299
+ p. cargo ( "build -v" )
300
+ . build_std ( & setup)
301
+ . with_stderr_does_not_contain ( str![ [ r#"
302
+ ...
303
+ [RUNNING] `[..] rustc --crate-name dep_test [..]`
304
+ ...
305
+ [RUNNING] `[..] rustc --crate-name dep_test [..]`
306
+ ...
307
+ "# ] ] )
308
+ . run ( ) ;
315
309
}
316
310
317
311
#[ cargo_test( build_std_mock) ]
0 commit comments