about summary refs log tree commit diff
path: root/src/bootstrap
AgeCommit message (Collapse)AuthorLines
2025-08-20Split compiletest `--codegen-backend` into two options ↵Guillaume Gomez-4/+7
`--default-codegen-backend` and `--override-codegen-backend`
2025-08-20Add new `--test-codegen-backend` bootstrap optionGuillaume Gomez-6/+54
2025-08-20Disable rustc uplifting during cross-compilationJakub Beránek-9/+6
2025-08-19Auto merge of #145601 - jieyouxu:rollup-t5mbqhc, r=jieyouxubors-34/+39
Rollup of 10 pull requests Successful merges: - rust-lang/rust#145538 (bufreader::Buffer::backshift: don't move the uninit bytes) - rust-lang/rust#145542 (triagebot: Don't warn no-mentions on subtree updates) - rust-lang/rust#145549 (Update rust maintainers in openharmony.md) - rust-lang/rust#145550 (Avoid using `()` in `derive(From)` output.) - rust-lang/rust#145556 (Allow stability attributes on extern crates) - rust-lang/rust#145560 (Remove unused `PartialOrd`/`Ord` from bootstrap) - rust-lang/rust#145568 (ignore frontmatters in `TokenStream::new`) - rust-lang/rust#145571 (remove myself from some adhoc-groups and pings) - rust-lang/rust#145576 (Add change tracker entry for `--timings`) - rust-lang/rust#145578 (Add VEXos "linked files" support to `armv7a-vex-v5`) r? `@ghost` `@rustbot` modify labels: rollup
2025-08-19Add snapshot tests for stage 3 compiler buildsJakub Beránek-0/+76
2025-08-19Rollup merge of #145576 - jieyouxu:bootstrap-timings, r=Kobzol许杰友 Jieyou Xu (Joe)-0/+5
Add change tracker entry for `--timings` Follow-up to rust-lang/rust#145379. Forgor when reviewing. r? `@Kobzol`
2025-08-19Rollup merge of #145560 - Kobzol:bootstrap-remove-ord, r=jieyouxu许杰友 Jieyou Xu (Joe)-34/+34
Remove unused `PartialOrd`/`Ord` from bootstrap It was just wasting compile-time. There is one remaining "old" bootstrap test that uses the `Ord` impl on one test step, I'll remove that later.
2025-08-19Rollup merge of #145490 - Kobzol:bootstrap-io-tracing, r=jieyouxu许杰友 Jieyou Xu (Joe)-27/+86
Trace some basic I/O operations in bootstrap When working on removing the rmeta sysroot copies, it is quite difficult to figure out *why* was did a certain file appear in a given directory. This should help with that a bit. r? `@jieyouxu`
2025-08-19Rollup merge of #145452 - Kobzol:bootstrap-strip, r=jieyouxu许杰友 Jieyou Xu (Joe)-1/+12
Do not strip binaries in bootstrap everytime if they are unchanged I was profiling bootstrap to figure out why a no-op build takes upward of two seconds on my machine. I found that half of that is Cargo (which is mostly unavoidable) and the rest (~900ms) is running strip. We don't need to restrip already stripped binaries all the time. r? `@jieyouxu`
2025-08-19Rollup merge of #145565 - Kobzol:bootstrap-ci-print-error, r=jieyouxuStuart Cook-0/+4
Improve context of bootstrap errors in CI Inspired by https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/printing.20test.20suite.20name.20by.20default/with/534920583, this PR attempts to improve the context displayed when a bootstrap invocation fails in CI. Since https://github.com/rust-lang/rust/pull/145261, we now see the latest started step when a failure occurs. However, we can go further. 1) The first commit prints the actual executed bootstrap invocation command arguments when bootstrap ends. Since CI jobs often run multiple bootstrap commands, this makes it easier to figure out which one of them failed (before it was annoying having to search for that in CI logs). Because bootstrap doesn't really use `Result`s much, and most of them time it ends with the `detail_exit` function, which YOLOs `std::process::exit(...)`, I added the print there. 2) Adds `#[track_caller]` to a few bootstrap Cargo builder functions. This makes the log that we print when a command fails more accurate: ``` 2025-08-16T18:18:51.6998201Z Command ... failed ... 2025-08-16T18:18:51.7003653Z Created at: src/bootstrap/src/core/builder/cargo.rs:423:33 2025-08-16T18:18:51.7004032Z Executed at: src/bootstrap/src/core/build_steps/doc.rs:933:26 ``` Before, the `cargo.rs:XYZ` location wasn't very useful. 3) Is the most wild thing (I'll revert if you find it too magical). We store the step stack of the currently active `Builder` instance in a global variable, and when bootstrap exits with a failure, we print the stack, to make it easier to find out what was happening when a failure occurred. We could print an actual captured `Backtrace`, but I think that would be too much information in the common case. We now pass `RUST_BACKTRACE=1` on CI, so if bootstrap actually crashes unexpectedly, we would see the stacktrace. The end of the bootsrap failure log in CI now looks like this now: ``` Bootstrap failed while executing `x build library` ---BOOTSTRAP step stack start--- Assemble { target_compiler: Compiler { stage: 1, host: x86_64-unknown-linux-gnu, forced_compiler: false } } Rustc { target: x86_64-unknown-linux-gnu, build_compiler: Compiler { stage: 0, host: x86_64-unknown-linux-gnu, forced_compiler: false }, crates: [] } ---BOOTSTRAP step stack end--- ``` r? `@jieyouxu`
2025-08-19Rollup merge of #145557 - Kobzol:rustc-link-fix, r=jieyouxuStuart Cook-34/+78
Fix uplifting in `Assemble` step In https://github.com/rust-lang/rust/pull/145310, I removed [this line](https://github.com/rust-lang/rust/pull/145310/files#diff-5a1e05f2688d271039171a547d407d0c8a96715ee64d35562fc76b4c9a874303L2109), which adjusted the stage of the build compiler if an uplift has happened. This broke stage3+ uplifted rustc builds (https://github.com/rust-lang/rust/issues/145534). I could swear I tested this in the PR, but somehow I missed it. Instead of keeping the original returned stage, I made it more explicit by returning the actually used `build_compiler` from the `Rustc` step, and then use that in the `Assemble` step. The changes to `RustcLink` were needed to fix `ui-fulldeps`, which apparently build a stage3 rustc, because I haven't fixed the test steps yet :sweat_smile: Hopefully we might be able to remove `RustcLink` if the approach from https://github.com/rust-lang/rust/pull/144252 will work. Should fix https://github.com/rust-lang/rust/issues/145534. r? ``@jieyouxu``
2025-08-19Rollup merge of #144252 - Kobzol:rmeta-sysroot, r=jieyouxuStuart Cook-88/+335
Do not copy .rmeta files into the sysroot of the build compiler during check of rustc/std Before, when bootstrap did a check build of rustc stage N (with a build compiler that was stage N-1), it automatically copied the resulting `.rmeta` artifacts into the sysroot of the stage N-1 build compiler, so that stage N `rustc_private` tools such as `miri` could be compiled using the stage N-1 build compiler. This has a number of issues: - It was done unconditionally, even if no `rustc_private` tools were actually built. - If we did a check and a build of the same stage compiler in the same bootstrap invocation, the generated rmeta and rlib files could clash. This is also why you can see that `check::Std` actually doesn't copy the artifacts anymore (which forced us to build std instead of just checking it in a bunch of `Check` steps). - It was polluting the sysroot of the build compiler. This is especially annoying for the stage 0 compiler, because we are forced to create an artificial sysroot for it, so that we can copy new stuff into it. - It was very implicit in bootstrap. Based on suggestions by ```@cuviper``` and ```@bjorn3,``` I tried to change how this behaves. Instead of copying the rmeta artifacts into the sysroot of the build compiler (from where they would be loaded implicitly), they are now stored in a separate transient bootstrap build directory, and they are then explicitly passed *only* when checking `rustc_private` tools using the `-L` flag. The flags are passed out-of-band through our rustc wrapper, to avoid invalidating the build cache. This is the first commit. The second commit does the same for std. For a few months, we used to build std instead of just checking it when doing a cross-compile check of something that required std, this now fixes it. There is still the previous ordering requirement though, that `check::Std` has to be executed as the last check step, or rather nothing that requires checked std should be executed *after* it, because it will run into rmeta/rlib duplications (https://github.com/rust-lang/rust/blob/4fa90ef7996f891f7f1e126411e5d75afe64accf/src/bootstrap/src/core/builder/mod.rs#L1066). I tried to fix in this PR, but it quickly runs into the fact that building things currently copies *rlib* artifacts into the build compiler sysroot. I want to fix that as one of the next steps. After we get rid of all the copies (or rather, we only do the copies for dist/stage2+ and do not copy anything into the stage0 compiler's sysroot), we could hopefully finally get rid of `stage0-sysroot`. Based on my local tests, this seems to be working fine. If it works on CI, and we don't run into other issues after merging it, I'd like to do the same also for rlib artifacts generated during `x build`. r? ```@jieyouxu```
2025-08-18Assume UTF-8 in sysroot pathsJakub Beránek-1/+1
2025-08-18Fix uplifting in `Assemble` stepJakub Beránek-34/+78
2025-08-18remove downstream new methodbit-aloo-51/+12
2025-08-18Add change tracker entry for `--timings`Jieyou Xu-0/+5
2025-08-18Provide more useful command creation spansJakub Beránek-0/+4
2025-08-18Remove unused `PartialOrd`/`Ord` from bootstrapJakub Beránek-34/+34
2025-08-18Do not overwrite the value of `RUSTC_ADDITIONAL_SYSROOT_PATHS`Jakub Beránek-1/+28
2025-08-18Trace some basic I/O operations in bootstrapJakub Beránek-27/+86
2025-08-18clippy'edbit-aloo-1/+1
2025-08-18remove default configbit-aloo-582/+563
2025-08-16Only check std in cross-compilation instead of building itJakub Beránek-57/+153
2025-08-16Avoid copying rustc rmeta artifacts into the build compiler sysrootJakub Beránek-65/+189
This helps to avoid polluting the sysroot of the build compiler.
2025-08-16Optimize `copy_src_dirs`Jakub Beránek-39/+42
2025-08-16Do not call `fs::remove_file` in `cp_link_filtered_recurse`Jakub Beránek-1/+0
The target is removed by `copy_link` too, so no need to duplicate the syscall.
2025-08-15Rollup merge of #145455 - Kobzol:bootstrap-copy-src-dirs-dry-run, r=jieyouxuJacob Pratt-0/+6
Do not copy files in `copy_src_dirs` in dry run This reduces the time to run the current 9 dist snapshot tests from ~24s to ~2s on my PC. r? `@jieyouxu`
2025-08-15Rollup merge of #145454 - Kobzol:bootstrap-fix-step-debug-repr, r=jieyouxuJacob Pratt-3/+8
Fix tracing debug representation of steps without arguments in bootstrap I was wondering why I see `lainSourceTarbal` in tracing logs... r? `@jieyouxu`
2025-08-15Rollup merge of #145453 - Kobzol:bootstrap-cmd-span, r=jieyouxuJacob Pratt-3/+0
Remove duplicated tracing span in bootstrap `trace_cmd` is now called also in the `stream` method, so including it also here was duplicating command spans. r? `@jieyouxu`
2025-08-15Do not copy files in `copy_src_dirs` in dry runJakub Beránek-0/+6
2025-08-15Fix tracing debug representation of steps without arguments in bootstrapJakub Beránek-3/+8
2025-08-15Remove duplicated tracing span in bootstrapJakub Beránek-3/+0
2025-08-15Do not strip binaries in bootstrap everytime if they are unchangedJakub Beránek-1/+12
2025-08-15Rollup merge of #145413 - joshtriplett:bootstrap-reduce-deps, r=clubby789Jakub Beránek-52/+24
bootstrap: Reduce dependencies Eliminate the `fd-lock` dependency by using the new native locking in std. Eliminate the `xattr` dependency by turning off a feature flag in `tar`, since the tarballs that we extract with bootstrap don't need it.
2025-08-15Rollup merge of #145340 - Kobzol:bootstrap-codegen-backend-check-split, ↵Jakub Beránek-170/+91
r=jieyouxu Split codegen backend check step into two and don't run it with `x check compiler` This reduces the amount of work that is done during `x check compiler`. We still check both backends during `x check` by defaut, even if they are not in `rust.codegen-backends`, as just checking them shouldn't require expensive preparations, like building GCC. r? `@jieyouxu`
2025-08-15Remove usage of `compiler_for` from the `compile::Rustc` stepJakub Beránek-51/+43
2025-08-15Remove usage of `compiler_for` from the `compile::Std` stepJakub Beránek-28/+27
2025-08-15Rename `compiler` to `build_compiler` in the `compile::Std` stepJakub Beránek-11/+13
2025-08-15Split codegen backend check step into two and don't run it with `x check ↵Jakub Beránek-170/+91
compiler`
2025-08-14bootstrap: Remove dependency on xattrJosh Triplett-14/+3
Extracting the Rust tarballs doesn't require this.
2025-08-14bootstrap: Switch from fd-lock to native locking in stdJosh Triplett-38/+21
In the process, fix a race condition, by never truncating or writing to the file unless we currently hold the lock.
2025-08-14Rollup merge of #145379 - joshtriplett:bootstrap-timings, r=jieyouxuJakub Beránek-8/+31
bootstrap: Support passing `--timings` to cargo Useful for optimizing the sequencing of the compiler's own build.
2025-08-14Rollup merge of #145353 - CathalMullan:jemalloc-tools, r=KobzolJakub Beránek-0/+9
bootstrap: Fix jemalloc 64K page support for aarch64 tools Resolves rust-lang/rust#133748 The prior page size fix only targeted the compile build step, not the tools step: https://github.com/rust-lang/rust/pull/135081 Also note that since `miri` always uses jemalloc, I didn't copy the `builder.config.jemalloc(target)` check to the tools section. Tested by running `strings` on the compiled `miri` binary to see the LG_PAGE value. Before: ``` > strings miri | grep '^LG_PAGE' LG_PAGE 14 ``` After: ``` > strings miri | grep '^LG_PAGE' LG_PAGE 16 ``` May also need a separate fix for the standalone miri repository: https://github.com/rust-lang/miri/issues/4514 (likely a change needed in miri-script?)
2025-08-14Rollup merge of #145324 - Kobzol:bootstrap-host-only, r=jieyouxuJakub Beránek-119/+119
Rename and document `ONLY_HOSTS` in bootstrap Everytime I examined the `ONLY_HOSTS` flag of bootstrap steps, I was utterly confused. Why is it called ONLY_HOSTS? How does the fact that it is skipped if `--target` is passed, but `--host` is not (which was not accurate) help me? The reality of the flag is that if it is true, the targets for which the given Step will be built is determined based on the `--host` flag, while if it is false, it is determined based on the `--target` flag, that's pretty much it. The previous comment was just a (not very helpful and not even accurate) corollary of that. I clarified the comment, and also renamed the flag to `IS_HOST` (happy to brainstorm better names, but the doc. comment change is IMO the main improvement). r? ``@jieyouxu``
2025-08-14Rollup merge of #145261 - Kobzol:bootstrap-tracing, r=jieyouxuJakub Beránek-313/+511
Improve tracing in bootstrap I was annoyed that bootstrap had like 5 separate ways of debugging/tracing/profiling, and it was hard for me to understand how are individual steps executed. This PR tries to unify severla things behind `BOOTSTRAP_TRACING`, and improve tracing/profiling in general: - All generated tracing outputs are now stored in a single directory to make it easier to examine them, plus bootstrap prepares a `latest` symlink to the latest generated tracing output directory for convenience. - All executed spans are now logged automatically (without requiring usage of `#[tracing::instrument]`). - A custom span/event formatter was implemented, to provide domain-specific output (like location of executed commands or spans) and hopefully also to reduce visual clutter. - `tracing_forest` was removed. While it did some useful postprocessing, it didn't expose enough information for making the dynamic step spans work. - You can now explicitly log steps (`STEP=info`) and/or commands (`COMMAND=info`), to have more granular control over what gets logged. - `print-step-timings` also show when a step starts its execution (not just when it ends it), so that when some step fails in CI, we can actually see what step it was (before we would only see the end of the previous step). - The rustc-dev-guide page on debugging/profiling bootstrap was updated. There are still some things that work outside of tracing (`print-step-timings` and `dump-bootstrap-shims`), but I think that for now this improvement is good enough. I removed the `> step`, `< step` verbose output, because I found it unusable, as verbose bootstrap output also enables verbose Cargo output, and then you simply drown in too much data, and because I think that the new tracing system makes it obsolete (although it does require recompilation with the `tracing` feature). If you want to keep it, happy to revert 690c781475acb890f33d928186bdaea9ef179330. And the information about cached steps is now also shown in the Graphviz step dependency graph. We can modify the tracing output however we want, as we now implement it ourselves. Notably, we could also show exit logs for step spans, currently I only show enter spans. Maybe creating indents for each executed nested command is also not needed. Happy to hear feedback! Some further improvements could be to print step durations, if we decide to also log step exit events. We could also try to enable tracing in CI logs, but it might be too verbose. Best reviewed commit-by-commit. r? ``@jieyouxu`` CC ``@Shourya742``
2025-08-14Rename and document `ONLY_HOSTS` in bootstrapJakub Beránek-114/+119
2025-08-14Remove `ONLY_HOSTS` value overrides that just set the default value and had ↵Jakub Beránek-5/+0
no comment
2025-08-13bootstrap: Support passing `--timings` to cargoJosh Triplett-8/+31
Useful for optimizing the sequencing of the compiler's own build.
2025-08-14Auto merge of #145131 - Kobzol:bootstrap-clippy, r=jieyouxubors-143/+430
Enforce in bootstrap that clippy must have stage at least 1 This mostly piggybacks on the previous `x check` [rework](https://github.com/rust-lang/rust/pull/143048). The new "rules" follow the new staging logic. So `x clippy <foo>` lints `foo` using stage0 Clippy. `x clippy --stage 2 <foo>` lints `foo` using stage1 Clippy (which is built from in-tree sources). I had to fix some latent issues with `prepare_compiler_for_check` along the way. Checking `rustc_private` tools should now check less compiler crates (or rather not check compiler examples/tests/etc.), potentially speeding it up slightly. I also had to make some manual adjustments to `x clippy ci` so that it doesn't do needless work. r? `@jieyouxu`
2025-08-13Rollup merge of #145341 - Kobzol:codegen-backend-gcc, r=jieyouxuGuillaume Gomez-67/+98
Install libgccjit into the compiler's sysroot when cg_gcc is enabled This PR installs the `libgccjit.so` library (which is essentially GCC) into the rustc sysroot (`stageN/lib` on Linux) when the GCC codegen backend is enabled. This allows using the GCC codegen backend "out of the box" with the resulting rustc. It would be nice to get rid of the `libgccjit.so.0` alias (https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Forcing.20unversioned.20dylib.20dependencies.20on.20Linux/with/534180740), but it's not blocking for this change. You can try running `x build std --set 'rust.codegen-backends=["llvm", "gcc"]'` and then compiling a hello world with `rustc +stage1 -Zcodegen-backend=gcc main.rs`. It is now also possible to build stage2 rustc when the GCC is configured to be the default codegen backend, without any further `LD_LIBRARY_PATH` hacks: `./x build compiler --stage 2 --set 'rust.codegen-backends=["gcc"]'`. After this change, it should be pretty simple to add a dist/rustup step for actually shipping cg_gcc to end users. CC ```@GuillaumeGomez``` r? ```@jieyouxu```