Skip to content

Commit c36e6f2

Browse files
authored
fix: remove unnecessary workaround in standard_lib test (#15522)
### What does this PR try to resolve? - As issue rust-lang/rust#125246 has already been fixed, there must be no need for commenting out `--sysroot` anymore in the tests. - The bug mentioned in `shared_std_dependency_rebuild()` looks to be already solved and does not reproduce. So I guess it's safe to un-comment those lines.
2 parents a466cc5 + ff1849f commit c36e6f2

File tree

1 file changed

+24
-30
lines changed

1 file changed

+24
-30
lines changed

tests/testsuite/standard_lib.rs

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ fn setup() -> Setup {
8787
let p = ProjectBuilder::new(paths::root().join("rustc-wrapper"))
8888
.file(
8989
"src/main.rs",
90-
r#"
90+
&r#"
9191
use std::process::Command;
9292
use std::env;
9393
fn main() {
@@ -97,29 +97,27 @@ fn setup() -> Setup {
9797
if is_sysroot_crate {
9898
args.push("--sysroot".to_string());
9999
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") {
101101
// 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+
}
115112
} else {
116113
// host unit, do not use sysroot
117114
}
118115
119116
let ret = Command::new(&args[0]).args(&args[1..]).status().unwrap();
120117
std::process::exit(ret.code().unwrap_or(1));
121118
}
122-
"#,
119+
"#
120+
.replace("__HOST_TARGET__", rustc_host()),
123121
)
124122
.build();
125123
p.cargo("build").run();
@@ -298,20 +296,16 @@ fn shared_std_dependency_rebuild() {
298296
"#]])
299297
.run();
300298

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();
315309
}
316310

317311
#[cargo_test(build_std_mock)]

0 commit comments

Comments
 (0)