Skip to content

Commit c14f8b5

Browse files
committed
Remap paths for ~/.cargo in UI tests
Users won't have the original cargo registry from the CI builder available, even if they have `rust-src` installed. Don't show their sources in UI tests even if they're available. As a happy side-effect, this fixes a few UI tests when download-rustc is enabled.
1 parent 0828c15 commit c14f8b5

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/bootstrap/src/core/builder.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,6 +1779,18 @@ impl<'a> Builder<'a> {
17791779
hostflags.arg(format!("-Ctarget-feature={sign}crt-static"));
17801780
}
17811781

1782+
// Users won't have the original cargo registry from the CI builder available, even if they have `rust-src` installed.
1783+
// Don't show their sources in UI tests even if they're available.
1784+
// As a happy side-effect, this fixes a few UI tests when download-rustc is enabled.
1785+
// NOTE: only set this when building std so the error messages are better for rustc itself.
1786+
if mode == Mode::Std {
1787+
let cargo_home = env::var("CARGO_HOME").unwrap_or_else(|_| {
1788+
let home_var = if cfg!(windows) { "USERPROFILE" } else { "HOME" };
1789+
env::var(home_var).unwrap()
1790+
});
1791+
rustflags.arg(&format!("--remap-path-prefix={cargo_home}=/cargo/FAKE_PREFIX"));
1792+
}
1793+
17821794
if let Some(map_to) = self.build.debuginfo_map_to(GitRepo::Rustc) {
17831795
let map = format!("{}={}", self.build.src.display(), map_to);
17841796
cargo.env("RUSTC_DEBUGINFO_MAP", map);

0 commit comments

Comments
 (0)