Commit graph

7310 commits

Author SHA1 Message Date
bit-aloo
dca9fe0d94
explain reasoning behind spawn API 2025-06-17 20:49:20 +05:30
bit-aloo
2270572cb4
add created at to command execution 2025-06-17 20:49:19 +05:30
bit-aloo
0c60856ed1
remove new method from command execution 2025-06-17 20:49:19 +05:30
bit-aloo
b16ba4d3ee
remove start_porcess helper method 2025-06-17 20:49:19 +05:30
bit-aloo
2e4f2d2f3b
move from start process to new start and wait for output api's 2025-06-17 20:49:19 +05:30
bit-aloo
16bc870ee2
add start methods in exec 2025-06-17 20:49:19 +05:30
bit-aloo
7889332342
add deferred command in execution context and update run method 2025-06-17 20:49:19 +05:30
Jakub Beránek
e036a564e4
Rollup merge of #142431 - Kobzol:bootstrap-snapshot-tests, r=jieyouxu
Add initial version of snapshot tests to bootstrap

When making any changes to bootstrap (steps), it is very difficult to realize how does it affect various common bootstrap commands, and if everything still works as we expect it to. We are far away from having actual end-to-end tests, but what we could at least do is have a way of testing what steps does bootstrap execute in dry run mode. Now, we already have something like this in `src/bootstrap/src/core/builder/tests.rs`, however that is quite limited, because it only checks executed steps for a specific impl of `Step` and it does not consider step order.

Recently, when working on what I thought was one of the simplest possible step untanglings in bootstrap (https://github.com/rust-lang/rust/pull/142357), I ran into errors in tests that were quite hard to debug. Partly also because the current staging test diffs are multiline and use `Debug` output, so it's quite difficult for me to make sense of them.

In this PR, I introduce `insta`, which allows writing snapshot tests in a very simple way. With it, I want to allow writing tests that will clearly show us what is going on during bootstrap execution, and then write golden tests for `build/check/test` stage `0/1/2` for compiler/std/tools etc., to make sure that we don't regress something, and also to help with [#t-infra/bootstrap > Proposal to cleanup stages and steps after the redesign](https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Proposal.20to.20cleanup.20stages.20and.20steps.20after.20the.20redesign/with/523488806), to help avoid a situation where we would (again) have to make a flurry of staging changes because of unexpected consequences.

In the snapshot tests, we currently render the build of rustc, std and LLVM. Currently I render the executed steps using downcasting, which is not super pretty, but it allows us to make the test rendering localized in one place, and it's IMO enough for now.

I implemented only a single test using the new machinery. Maybe if you take a look at it, you will understand why 😆 Bootstrap currently does some peculiar things, such as running a stage 0 std step (even though stage 0 std no longer exists) and running the Rustc stage 0 -> 1 step twice, once with a single crates, once with all rustc crates. So I think that even with this single step, there will be a bunch of things to fix in the near future...

The way we currently prepare the Config test fixtures is far from ideal, this is something I think ``@Shourya742`` could work on as a part of their GSoC project (remove as much command execution from Config construction as possible, actually run bootstrap on a temporary directory instead of running it on the rustc checkout, create a Builder-like API for creating the Config test fixtures).

r? ``@jieyouxu``
2025-06-16 14:31:12 +02:00
Jakub Beránek
ac8a48dad2
Rollup merge of #142416 - Kobzol:bootstrap-cleanup-2, r=jieyouxu
Assorted bootstrap cleanups (step 2)

Very small improvements designed towards making bootstrap tests less hacky/special, and towards making it possible to run bootstrap tests in parallel.

Best reviewed commit by commit.

r? ``@jieyouxu``
2025-06-16 14:31:11 +02:00
bit-aloo
c9eeeb4b5f
remove check_run function from helpers 2025-06-14 18:23:35 +05:30
bit-aloo
b5db059b83
remove check_run method from config 2025-06-14 17:10:44 +05:30
bit-aloo
c67f7ae27f
replace all instances of check_run in download with execution context 2025-06-14 17:10:07 +05:30
bit-aloo
e11e640013
replace all instances of check_run in config with execution context 2025-06-14 17:09:25 +05:30
Jubilee
8b22fcbd51
Rollup merge of #142459 - Shourya742:2025-06-11-remove-output-helper, r=Kobzol
Remove output helper bootstrap

This PR removes output utility helper method.

r? `@Kobzol`
2025-06-13 20:59:21 -07:00
bit-aloo
2f7cc5a285
remove output from helpers 2025-06-13 20:03:29 +05:30
bit-aloo
66beaa6e5d
replace output usage in bootstrap/lib.rs with new execution context 2025-06-13 20:03:24 +05:30
bit-aloo
da0cceebf0
replace output usage in sanity with new execution context 2025-06-13 18:29:48 +05:30
Matthias Krüger
4838c0085c
Rollup merge of #142379 - Stypox:bootstrap-tool-config, r=Kobzol
Add bootstrap option to compile a tool with features

Add an option to specify which features to build a tool with, e.g. it will be useful to build Miri with tracing enabled:
```toml
tool-config.miri.features = ["tracing"]
```

See [this Zulip thread](https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Passing.20--features.20to.20Miri.20build.20using.20.2E.2Fx.2Epy/with/523564773) for the options considered. If the final decision will be different than what I wrote now, I will update the code as needed. The reason why the option is `tool-config.miri.features` instead of something like `tool-features.miri` is to possibly allow adding more tool-specific configurations in the future.

I didn't do any validation of the keys of the `tool-config` hashmap, since I saw that no validation is done on the `tools` hashset either.

I don't like much the fact that features can be chosen by various places of the codebase: `Step`s can have some fixed `extra_features`, `prepare_tool_cargo` will add features depending on some bootstrapping options, and the newly added option can also contribute features to tools. However I think it is out of scope of this PR to try to refactor all of that (if it even is refactorable), so I left a comment in the codebase explaining all of the sources of features I could find.
2025-06-13 05:16:59 +02:00
Jakub Beránek
6feb9b792c
Add lightweight snapshot testing for bootstrap tests 2025-06-12 19:42:03 +02:00
Jakub Beránek
983fe4f265
Simplify configure_with_args 2025-06-12 19:38:25 +02:00
Jakub Beránek
a71b463d2b
Move submodule path cache from parse_gitmodules to Builder
It would not be correct if multiple values of `target_dir` were ever passed to the function in the same process.
2025-06-12 15:48:50 +02:00
Jakub Beránek
dbe15e3e94
Remove environment variable modification in test_default_compiler_wasi 2025-06-12 15:48:50 +02:00
Jakub Beránek
85401882d2
Remove RefCell from cc/cxx/ar/ranlib
It wasn't really needed there.
2025-06-12 15:48:50 +02:00
Jakub Beránek
2591571263
Stop using Config for tempdir-as-a-service in build_stamp tests 2025-06-12 15:48:50 +02:00
Jakub Beránek
40c2ca9641
Move shared_helpers test to a dedicated module 2025-06-12 15:48:50 +02:00
Jakub Beránek
5b50e0ba54
Add support for snapshot tests with insta 2025-06-12 14:27:29 +02:00
Stypox
17f69bfda0
Rename tool-config to tool and add docs 2025-06-12 13:58:38 +02:00
Matthias Krüger
bb9dda1272
Rollup merge of #142303 - Kobzol:bootstrap-cleanup-1, r=jieyouxu
Assorted bootstrap cleanups (step 1)

Now that the stage0 redesign has landed, we can finally start cleaning up many things in bootstrap, and lord knows it deserves it! I plan to send many PRs once I figure out an incremental way forward, this is the first one of them. It doesn't actually change anything, just renames stuff and adds more documentation, but the rename is bitrotty, so I wanted to push the PR eagerly.

r? `@jieyouxu`
2025-06-12 03:14:53 +02:00
Matthias Krüger
c97dca6989
Rollup merge of #142374 - Kobzol:fix-newline, r=tmiasko
Fix missing newline trim in bootstrap

Fixes [this comment](https://github.com/rust-lang/rust/pull/141909/files#r2140632918).

Fixes: https://github.com/rust-lang/rust/issues/142350
2025-06-11 22:58:30 +02:00
Matthias Krüger
e80be0bcba
Rollup merge of #142364 - Kobzol:download-ci-incremental-warning-remove, r=RalfJung
Do not warn on `rust.incremental` when using download CI rustc

Discussed on Zulip.

r? `@RalfJung`
2025-06-11 22:58:29 +02:00
Matthias Krüger
507c57554d
Rollup merge of #142346 - Shourya742:2025-06-11-add-tracing-import-to-execution-context, r=Kobzol
Add tracing import to execution context

In https://github.com/rust-lang/rust/pull/141909, we missed adding the trace_cmd import in the execution context module. This PR fixes that. Additionally, we are updating the mingw-check-2 check command to include BOOTSTRAP_TRACING=1 to help ensure we don't miss such cases in future PRs.

r? `@Kobzol`
2025-06-11 22:58:27 +02:00
Stypox
8dac423f82
Add bootstrap option to compile a tool with features 2025-06-11 21:50:21 +02:00
bors
e703dff8fe Auto merge of #142358 - matthiaskrgr:rollup-fxe6m7k, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#141967 (Configure bootstrap backport nominations through triagebot)
 - rust-lang/rust#142042 (Make E0621 missing lifetime suggestion verbose)
 - rust-lang/rust#142272 (tests: Change ABIs in tests to more future-resilient ones)
 - rust-lang/rust#142282 (Only run `citool` tests on the `auto` branch)
 - rust-lang/rust#142297 (Implement `//@ needs-target-std` compiletest directive)
 - rust-lang/rust#142298 (Make loongarch-none target maintainers more easily pingable)
 - rust-lang/rust#142306 (Dont unwrap and re-wrap typing envs)
 - rust-lang/rust#142324 (Remove unneeded `FunctionCx` from some codegen methods)
 - rust-lang/rust#142328 (feat: Add `bit_width` for unsigned integer types)

Failed merges:

 - rust-lang/rust#141639 (Expose discriminant values in stable_mir)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-11 17:51:57 +00:00
Jakub Beránek
87b068ccb7
Fix missing newline trim in bootstrap 2025-06-11 19:05:10 +02:00
Jakub Beránek
796ee4ff6c
Do not warn on rust.incremental when using download CI rustc 2025-06-11 14:42:06 +02:00
Matthias Krüger
57bb38b836
Rollup merge of #142297 - jieyouxu:needs-target-std, r=Kobzol
Implement `//@ needs-target-std` compiletest directive

Closes rust-lang/rust#141863.
Needed to unblock rust-lang/rust#139244 and rust-lang/rust#141856.

### Summary

This PR implements a `//@ needs-target-std` compiletest directive that gates test execution based on whether the target supports std or not. For some cases, this should be preferred over e.g. some combination of `//@ ignore-none`, `//@ ignore-nvptx` and more[^none-limit].

### Implementation limitation

Unfortunately, since there is currently [no reliable way to determine from metadata whether a given target supports std or not](https://github.com/rust-lang/rust/issues/142296), we have to resort to a hack. Bootstrap currently determines whether or not a target supports std by a naive target tuple substring comparison: a target supports std if its target tuple does *not* contain one of `["-none", "nvptx", "switch"]` substrings. This PR simply pulls that hack out into `build_helpers` to avoid reimplementing the same hack in compiletest, and uses that logic to inform `//@ needs-target-std`.

### Auxiliary changes

This PR additionally changes a few run-make tests to use `//@ needs-target-std` over an inconsistent combination of target-based `ignore`s. This should help with rust-lang/rust#139244.

---

r? bootstrap

[^none-limit]: Notably, `target_os = "none"` is **not** a sufficient condition for "target does not support std"
2025-06-11 13:48:11 +02:00
Jakub Beránek
3a33dd6194
Revert "add Cargo.lock to CI-rustc allowed list for non-CI env"
This reverts commit c3de813944.
2025-06-11 10:08:45 +02:00
bit-aloo
9dd7c019fe
add trace_cmd import in tracing feature in execution context 2025-06-11 13:30:53 +05:30
Jakub Beránek
20e83257da
Improve documentation of the Rustc step and rename compiler to build_compiler in a few places 2025-06-10 19:44:06 +02:00
Jakub Beránek
f461997cff
Rename build to host_target
Host is the machine where bootstrap runs, and this field represents the target of the (host) stage0/beta compiler. This is much clearer than `build`, which also conflicts with the `Build` struct, which is stored under the name `build` inside `Builder` (lol).
2025-06-10 19:44:06 +02:00
León Orell Valerian Liehr
b9a578ea27
Rollup merge of #141909 - Shourya742:2025-06-01-add-execution-context, r=Kobzol
Add central execution context to bootstrap

This PR continues the effort toward command centralization as outlined in https://github.com/rust-lang/rust/issues/126819. It introduces a centralized execution context through which all commands will be executed. Previously, centralization was limited to build methods; this PR extends it to the `config` module and updates the remaining methods accordingly.

Best reviewed commit by commit.

r? ``@Kobzol``
2025-06-10 16:54:48 +02:00
Jieyou Xu
8ef8062d65
Extract target no-std hack to build_helpers
To centralize this hack in one place with a backlink to the issue
tracking this hack, as this logic is also needed by compiletest to
implement a `//@ needs-target-std` directive.
2025-06-10 22:10:10 +08:00
Mateusz Mikuła
4f0b60aa71 Don't create .msi installer for gnullvm hosts
WIX toolset works only on Windows hosts and we need to boostrap this
host.
2025-06-09 23:54:04 +02:00
bit-aloo
51fbd145f9
Initialize the execution context in parse_inner, start using dry run from the execution context, add getters and setters in the config, and update the tests and other relevant areas accordingly. 2025-06-09 21:11:45 +05:30
bit-aloo
e9ced508f4
remove execution context from flag module and correct the command invocation according to suggestions 2025-06-09 20:39:48 +05:30
bit-aloo
f3e1eb1dca
update dry_run value in exec_ctx and start forwarding exec_ctx verbose methods via config 2025-06-09 20:39:45 +05:30
bit-aloo
50725f325b
move all commands to new execution context 2025-06-09 20:39:15 +05:30
bit-aloo
98be2a0498
move all config command invocation to new execution context invocation 2025-06-09 20:38:13 +05:30
bit-aloo
746276cfb2
moved git command to new exec context 2025-06-09 20:38:13 +05:30
bit-aloo
bae39b8f10
move all download.rs method to new execution context command invocation 2025-06-09 20:38:12 +05:30