rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
96.58k stars 12.48k forks source link

complicated build stages #119946

Open onur-ozkan opened 7 months ago

onur-ozkan commented 7 months ago

Current approach on bootstrap stages adds too much complexity on the bootstrap codebase; the complexity continues to grow with the additional changes made on bootstrap and it's not even functioning correctly (like writing incorrect stages to stdout on certain commands).

One possible solution could be to handle stage behaviours as part of the Step trait individually on Step implementation.

Some references to why current implementation of step calculations is making things so difficult/complicated:

https://github.com/rust-lang/rust/blob/ef324565d071c6d7e2477a195648549e33d6a465/src/bootstrap/src/core/build_steps/compile.rs#L839-L847

https://github.com/rust-lang/rust/blob/ef324565d071c6d7e2477a195648549e33d6a465/src/bootstrap/src/core/build_steps/compile.rs#L905-L926

Particularly, the behaviors of the force_use_stage function are not really useful for all use cases (for instance, see https://github.com/rust-lang/rust/issues/118233 and https://github.com/rust-lang/rust/issues/118918)

https://github.com/rust-lang/rust/blob/ef324565d071c6d7e2477a195648549e33d6a465/src/bootstrap/src/lib.rs#L1403-L1417

@rustbot label +T-bootstrap

RalfJung commented 5 months ago

Note that there's been lots of prior discussion on this:

RalfJung commented 5 months ago

I think some of this logic is also just wrong. For instance:

https://github.com/rust-lang/rust/blob/288daeb14f70192d53d2331b4c43a8c6d90d9d7e/src/bootstrap/src/core/build_steps/tool.rs#L822-L840

This copies the clippy/miri built with the stage N compiler into the stage N sysroot. But that makes no sense: for rustc we copy the rustc built with the stage N compiler into the stage N+1 sysroot. The same should happen here.

Currently, miri.exe that is copied to the stage 1 sysroot needs to be loaded with the libraries that are in the stage 2 sysroot. Clearly that makes no sense.

RalfJung commented 5 months ago

So specifically, currently we're copying from stage1-tools-bin to stage1/bin. But we're also copying from stage1-rustc to stage2/bin. One of these has to be wrong, I think -- and I think it's the tools that are wrong.

onur-ozkan commented 5 months ago

Some references to why current implementation of step calculations is making things so difficult/complicated:

Additional ref. to this issue: https://rust-lang.zulipchat.com/#narrow/stream/326414-t-infra.2Fbootstrap/topic/Stage.20for.20copying.20tools.20into.20the.20sysroot