Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit cb81d0d

Browse files
authoredJul 1, 2024
Rollup merge of #127188 - onur-ozkan:rustc-src-fix, r=Kobzol
improve the way bootstrap handles rustlib components When CI rustc is enabled, bootstrap tries to symlink the rust source (project root) into target sysroot right before copying it from the CI rustc's sysroot. This becomes a problem in CI builders (which we currently don't see because they don't use CI rustc) because the copying part will fail as [they run on read-only mode](https://github.com/rust-lang/rust/blob/ef3d6fd7002500af0a985f70d3ac5152623c1396/src/ci/docker/run.sh#L233). This change fixes the problem by copying `rustc-src` from the CI rustc sysroot and only symlinking `rustc-src` from the rust source when download-rustc is not enabled. r? ``@Kobzol`` (we talked about this already on Zulip, he knows the context) Blocker for #122709
2 parents 61fe6b6 + 97415ce commit cb81d0d

File tree

1 file changed

+31
-28
lines changed

1 file changed

+31
-28
lines changed
 

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

+31-28
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,10 @@ impl Step for Std {
161161
// This check is specific to testing std itself; see `test::Std` for more details.
162162
&& !self.force_recompile
163163
{
164+
let sysroot = builder.ensure(Sysroot { compiler, force_recompile: false });
164165
cp_rustc_component_to_ci_sysroot(
165166
builder,
166-
compiler,
167+
&sysroot,
167168
builder.config.ci_rust_std_contents(),
168169
);
169170
return;
@@ -797,12 +798,7 @@ impl Step for StartupObjects {
797798
}
798799
}
799800

800-
fn cp_rustc_component_to_ci_sysroot(
801-
builder: &Builder<'_>,
802-
compiler: Compiler,
803-
contents: Vec<String>,
804-
) {
805-
let sysroot = builder.ensure(Sysroot { compiler, force_recompile: false });
801+
fn cp_rustc_component_to_ci_sysroot(builder: &Builder<'_>, sysroot: &Path, contents: Vec<String>) {
806802
let ci_rustc_dir = builder.config.ci_rustc_dir();
807803

808804
for file in contents {
@@ -881,13 +877,7 @@ impl Step for Rustc {
881877
// NOTE: the ABI of the beta compiler is different from the ABI of the downloaded compiler,
882878
// so its artifacts can't be reused.
883879
if builder.download_rustc() && compiler.stage != 0 {
884-
// Copy the existing artifacts instead of rebuilding them.
885-
// NOTE: this path is only taken for tools linking to rustc-dev (including ui-fulldeps tests).
886-
cp_rustc_component_to_ci_sysroot(
887-
builder,
888-
compiler,
889-
builder.config.ci_rustc_dev_contents(),
890-
);
880+
builder.ensure(Sysroot { compiler, force_recompile: false });
891881
return compiler.stage;
892882
}
893883

@@ -1634,31 +1624,44 @@ impl Step for Sysroot {
16341624
let sysroot_lib_rustlib_src_rust = sysroot_lib_rustlib_src.join("rust");
16351625
if let Err(e) = symlink_dir(&builder.config, &builder.src, &sysroot_lib_rustlib_src_rust) {
16361626
eprintln!(
1637-
"WARNING: creating symbolic link `{}` to `{}` failed with {}",
1627+
"ERROR: creating symbolic link `{}` to `{}` failed with {}",
16381628
sysroot_lib_rustlib_src_rust.display(),
16391629
builder.src.display(),
16401630
e,
16411631
);
16421632
if builder.config.rust_remap_debuginfo {
16431633
eprintln!(
1644-
"WARNING: some `tests/ui` tests will fail when lacking `{}`",
1634+
"ERROR: some `tests/ui` tests will fail when lacking `{}`",
16451635
sysroot_lib_rustlib_src_rust.display(),
16461636
);
16471637
}
1638+
build_helper::exit!(1);
16481639
}
1649-
// Same for the rustc-src component.
1650-
let sysroot_lib_rustlib_rustcsrc = sysroot.join("lib/rustlib/rustc-src");
1651-
t!(fs::create_dir_all(&sysroot_lib_rustlib_rustcsrc));
1652-
let sysroot_lib_rustlib_rustcsrc_rust = sysroot_lib_rustlib_rustcsrc.join("rust");
1653-
if let Err(e) =
1654-
symlink_dir(&builder.config, &builder.src, &sysroot_lib_rustlib_rustcsrc_rust)
1655-
{
1656-
eprintln!(
1657-
"WARNING: creating symbolic link `{}` to `{}` failed with {}",
1658-
sysroot_lib_rustlib_rustcsrc_rust.display(),
1659-
builder.src.display(),
1660-
e,
1640+
1641+
// Unlike rust-src component, we have to handle rustc-src a bit differently.
1642+
// When using CI rustc, we copy rustc-src component from its sysroot,
1643+
// otherwise we handle it in a similar way what we do for rust-src above.
1644+
if builder.download_rustc() {
1645+
cp_rustc_component_to_ci_sysroot(
1646+
builder,
1647+
&sysroot,
1648+
builder.config.ci_rustc_dev_contents(),
16611649
);
1650+
} else {
1651+
let sysroot_lib_rustlib_rustcsrc = sysroot.join("lib/rustlib/rustc-src");
1652+
t!(fs::create_dir_all(&sysroot_lib_rustlib_rustcsrc));
1653+
let sysroot_lib_rustlib_rustcsrc_rust = sysroot_lib_rustlib_rustcsrc.join("rust");
1654+
if let Err(e) =
1655+
symlink_dir(&builder.config, &builder.src, &sysroot_lib_rustlib_rustcsrc_rust)
1656+
{
1657+
eprintln!(
1658+
"ERROR: creating symbolic link `{}` to `{}` failed with {}",
1659+
sysroot_lib_rustlib_rustcsrc_rust.display(),
1660+
builder.src.display(),
1661+
e,
1662+
);
1663+
build_helper::exit!(1);
1664+
}
16621665
}
16631666

16641667
sysroot

0 commit comments

Comments
 (0)
Failed to load comments.