Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bootstrap command refactoring: quality-of-life improvements (step 4) #127321

Merged
merged 3 commits into from
Jul 7, 2024

Conversation

Kobzol
Copy link
Contributor

@Kobzol Kobzol commented Jul 4, 2024

Continuation of #127120.

This PR simply introduce two new functions (BootstrapCommand:run and command) that make it a bit easier to use commands in bootstrap. It also adds several #[must_use] annotations. This shouldn't (hopefully) have any effect on behavior.

Especially the first commit IMO makes any code that runs commands more readable, and allows using the API in a fluent way, without needing to jump back and forth between the command and the Build(er).

Tracking issue: #126819

r? @onur-ozkan

This makes it easier to use commands in a "Fluent-API" style, and also removes the need for the `AsMut` trait hack that
was used before to allow passing both `BootstrapCommand` and `&mut BootstrapCommand` to `Builder::run`.
The `Builder::run` method was still kept and can be used explicitly, if needed for some reason.
This is simply a quality-of-life improvement to make command creation in bootstrap a bit shorter and more discoverable.
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jul 4, 2024
@rustbot
Copy link
Collaborator

rustbot commented Jul 4, 2024

This PR changes how LLVM is built. Consider updating src/bootstrap/download-ci-llvm-stamp.

@rust-log-analyzer

This comment has been minimized.

@onur-ozkan onur-ozkan added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 6, 2024
This should make it harder to accidentally forget to use results of methods on `BootstrapCommand` and `CommandStatus`.
@Kobzol
Copy link
Contributor Author

Kobzol commented Jul 6, 2024

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 6, 2024
@onur-ozkan
Copy link
Member

@bors r+ rollup=iffy

@bors
Copy link
Contributor

bors commented Jul 7, 2024

📌 Commit 061edfe has been approved by onur-ozkan

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 7, 2024
@bors
Copy link
Contributor

bors commented Jul 7, 2024

⌛ Testing commit 061edfe with merge 35e6e4c...

@bors
Copy link
Contributor

bors commented Jul 7, 2024

☀️ Test successful - checks-actions
Approved by: onur-ozkan
Pushing 35e6e4c to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 7, 2024
@bors bors merged commit 35e6e4c into rust-lang:master Jul 7, 2024
7 checks passed
@rustbot rustbot added this to the 1.81.0 milestone Jul 7, 2024
@Kobzol Kobzol deleted the bootstrap-cmd-refactor-4 branch July 7, 2024 08:17
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (35e6e4c): comparison URL.

Overall result: ❌ regressions - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.3% [0.3%, 0.3%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (secondary -1.5%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.5% [0.5%, 0.5%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.8% [-2.7%, -0.9%] 6
All ❌✅ (primary) - - 0

Cycles

Results (secondary 0.7%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.7% [0.7%, 0.7%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 699.372s -> 700.365s (0.14%)
Artifact size: 328.43 MiB -> 328.48 MiB (0.01%)

bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 13, 2024
…nur-ozkan

Bootstrap command refactoring: improve debuggability (step 5)

Continuation of rust-lang#127321.

This PR improves the debuggability of command execution, by improving the output logged when a command fails (it now includes the exact location where the command was created and where it was executed), and also by adding a "drop bomb", which will panic if a command was created, but not executed (which is probably a bug).

Here is how the output of a failed command looks like:
```
Command "git" "foo" "[bar]" (failure_mode=Exit, stdout_mode=Capture, stderr_mode=Capture) did not execute successfully.
Expected success, got exit status: 1
Created at: src/core/build_steps/compile.rs:1699:9
Executed at: src/core/build_steps/compile.rs:1699:58

STDOUT ----

STDERR ----
git: 'foo' is not a git command. See 'git --help'.
```

And this is what is printed if you forget to execute a command:
```
thread 'main' panicked at /projects/personal/rust/rust/src/tools/build_helper/src/drop_bomb/mod.rs:42:13:
command constructed at `src/core/build_steps/compile.rs:1699:9` was dropped without being executed: `git`
```

Best reviewed commit by commit.

Tracking issue: rust-lang#126819

r? `@onur-ozkan`
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 13, 2024
…nur-ozkan

Bootstrap command refactoring: improve debuggability (step 5)

Continuation of rust-lang#127321.

This PR improves the debuggability of command execution, by improving the output logged when a command fails (it now includes the exact location where the command was created and where it was executed), and also by adding a "drop bomb", which will panic if a command was created, but not executed (which is probably a bug).

Here is how the output of a failed command looks like:
```
Command "git" "foo" "[bar]" (failure_mode=Exit, stdout_mode=Capture, stderr_mode=Capture) did not execute successfully.
Expected success, got exit status: 1
Created at: src/core/build_steps/compile.rs:1699:9
Executed at: src/core/build_steps/compile.rs:1699:58

STDOUT ----

STDERR ----
git: 'foo' is not a git command. See 'git --help'.
```

And this is what is printed if you forget to execute a command:
```
thread 'main' panicked at /projects/personal/rust/rust/src/tools/build_helper/src/drop_bomb/mod.rs:42:13:
command constructed at `src/core/build_steps/compile.rs:1699:9` was dropped without being executed: `git`
```

Best reviewed commit by commit.

Tracking issue: rust-lang#126819

r? `@onur-ozkan`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants