rust
rust copied to clipboard
Copy stage0 binaries into stage0-sysroot
Currently, the beta binaries are only present in build/stage0/bin; build/stage0-sysroot has only the standard library, not any binaries. That causes two issues:
rustup toolchain linkdoesn't work with stage0-sysroot, meaning there's no way to change the standard library and use those changes at runtime without doing a full stage 1 buildx dist --stage 0doesn't work:
thread 'main' panicked at 'could not read dir "/home/dawn/projects/rust/build/x86_64-unknown-linux-gnu/stage0-sysroot/bin": Os { code: 2, kind: NotFound, message: "No such file or directory" }', lib.rs:1573:25
This is very rare to want to do, but can be useful when modifying the dist process itself, to avoid long compile times.
Copying the binaries into stage0-sysroot is an easy way to fix both problems at once.
Mentoring instructions: Add a builder.copy call in impl Step for Sysroot https://github.com/rust-lang/rust/blob/6f0c4a6c5c36f1f8f433a12e10a29918f3d40a31/src/bootstrap/compile.rs#L1146 which copies the whole bin directory from build/stage0.
We should also consider renaming stage0-sysroot to something else; the name is very confusing.
@rustbot claim
We should also consider renaming stage0-sysroot to something else; the name is very confusing.
The name is correct though. It is a directory you can pass in as --sysroot argument to rustc.
@bjorn3 so is stage0. I'm not saying the name is wrong, just that it's ambiguous and not intuitive.
Honestly I would rather rename all the stageN directories to stageN-sysroot and change stage0-sysroot to stage0-sysroot-with-libstd or something.
stage0-sysroot-with-libstd is confusing too as stage0 already has a libstd. Just one from the bootstrap compiler rather than compiled from the current source.
Ok, then maybe stage0-sysroot-with-recompiled-libstd :shrug: nearly anything would be less confusing than just appending -sysroot IMO
Maybe rename stage0 to bootstrap and stage0-sysroot to stage0, matching stage1-...?
bootstrap is confusing with the artifacts for src/bootstrap, but maybe bootstrap-sysroot would work, keeping stage0-sysroot as is and renaming stage1 to stage1-sysroot
Reverted in https://github.com/rust-lang/rust/pull/101942
This is very rare to want to do
I actually wanted to recommend something like this as an alternative std benchmarking workflow. Currently I have to suggest a stage1 build.
@the8472 I meant dist --stage 0 is very rare. I agree wanting to use a stage 0 toolchain with just the libstd changes is common :)
@chenyukang do you know when you'll have a chance to follow up here? If you're not planning to follow up, can you please release your assignment on the issue?
@chenyukang do you know when you'll have a chance to follow up here? If you're not planning to follow up, can you please release your assignment on the issue?
Sorry, I didn't follow this item recently. Ok, release it now.
@rustbot claim I would like to take this issue up [with a bit of mentoring :)] if that's alright. It's my first time contributing!
@KittyBorgX thanks for looking at it :) the first step is to cherry-pick the changes in https://github.com/rust-lang/rust/pull/101711 to the latest master commit. Then you'll need to fix the bug Mark mentioned in https://github.com/rust-lang/rust/pull/101942, which I believe has some more details in https://rust-lang.zulipchat.com/#narrow/stream/247081-t-compiler.2Fperformance/topic/rustc.20benchmark. I think it's enough to copy the user-provided rustc over to stage0-sysroot.
Feel free to ask questions here or in https://rust-lang.zulipchat.com/#narrow/stream/326414-t-infra.2Fbootstrap.
It was mentioned that https://github.com/rust-lang/rust/pull/108302 reverted this so I am reopening this unless someone can point me to the, er, revert of the revert?
Useful Links and Points for anyone who wants to work on this: Initial PR : https://github.com/rust-lang/rust/pull/101711 Revert of the Initial PR : https://github.com/rust-lang/rust/pull/101942 Attempt 2 : https://github.com/rust-lang/rust/pull/107956 Revert of attempt 2 : https://github.com/rust-lang/rust/pull/108302
If I am to understand correctly, the revert of the revert was rejected mainly because rust perf (https://perf.rust-lang.org/status.html) broke. For anyone working on this issue again, here's a point to note:
Just copying the entire parent bin to stage0-sysroot will not work as pointed out by bjorn3 in zulip as, suppose the rustc is installed in /usr/bin/rustc and you try and copy the underlying parent dir which would be /usr/bin. That time, stage0-sysroot/bin will get all the binaries in /usr/bin. This will however work when the installation is in something like : ~/.rustup/toolchains/stable-aarch64-apple-darwin/bin
My suggestion would be to re-land #107956 almost as-is, except with this feature disabled when a custom build.rustc is set.
@rustbot claim I'll give this another shot then ❤️