Skip to content

Commit 7261bfc

Browse files
committed
bootstrap: don't symlink source dir into stage0 sysroot
In StdLink::run we subsequently recursively copy the initial sysroot lib directory into the stage0-sysroot lib directory. If the initial sysroot is a toolchain that includes the `rust-src` component (in lib/rustlib/src/rust), if we add this symlink, that recursive copy we will overwrite the repo sources with the toolchain's sources. Fixes rust-lang#141991
1 parent 792fc2b commit 7261bfc

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

src/bootstrap/src/core/build_steps/compile.rs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1878,23 +1878,27 @@ impl Step for Sysroot {
18781878
// so that any tools relying on `rust-src` also work for local builds,
18791879
// and also for translating the virtual `/rustc/$hash` back to the real
18801880
// directory (for running tests with `rust.remap-debuginfo = true`).
1881-
let sysroot_lib_rustlib_src = sysroot.join("lib/rustlib/src");
1882-
t!(fs::create_dir_all(&sysroot_lib_rustlib_src));
1883-
let sysroot_lib_rustlib_src_rust = sysroot_lib_rustlib_src.join("rust");
1884-
if let Err(e) = symlink_dir(&builder.config, &builder.src, &sysroot_lib_rustlib_src_rust) {
1885-
eprintln!(
1886-
"ERROR: creating symbolic link `{}` to `{}` failed with {}",
1887-
sysroot_lib_rustlib_src_rust.display(),
1888-
builder.src.display(),
1889-
e,
1890-
);
1891-
if builder.config.rust_remap_debuginfo {
1881+
if compiler.stage != 0 {
1882+
let sysroot_lib_rustlib_src = sysroot.join("lib/rustlib/src");
1883+
t!(fs::create_dir_all(&sysroot_lib_rustlib_src));
1884+
let sysroot_lib_rustlib_src_rust = sysroot_lib_rustlib_src.join("rust");
1885+
if let Err(e) =
1886+
symlink_dir(&builder.config, &builder.src, &sysroot_lib_rustlib_src_rust)
1887+
{
18921888
eprintln!(
1893-
"ERROR: some `tests/ui` tests will fail when lacking `{}`",
1889+
"ERROR: creating symbolic link `{}` to `{}` failed with {}",
18941890
sysroot_lib_rustlib_src_rust.display(),
1891+
builder.src.display(),
1892+
e,
18951893
);
1894+
if builder.config.rust_remap_debuginfo {
1895+
eprintln!(
1896+
"ERROR: some `tests/ui` tests will fail when lacking `{}`",
1897+
sysroot_lib_rustlib_src_rust.display(),
1898+
);
1899+
}
1900+
build_helper::exit!(1);
18961901
}
1897-
build_helper::exit!(1);
18981902
}
18991903

19001904
// rustc-src component is already part of CI rustc's sysroot

0 commit comments

Comments
 (0)