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: extract builder cargo to its own module #131728

Merged
merged 3 commits into from
Oct 21, 2024

Conversation

jieyouxu
Copy link
Member

@jieyouxu jieyouxu commented Oct 15, 2024

I was looking at our cargo rustflags/rustdocflags usages, and I found builder.rs to be a large
file which made it hard to digest. This PR tries to break out the cargo command wrapper parts to
its own submodule to make it easier to identify builder cargo-specific logic.

This PR:

  • Extracts the cargo command wrapper to its own module and also move Builder::{bare_,}cargo impl
    to the submodule.
  • Reorganizes some imports in lib.rs (no functional changes).
  • Slightly adjusts some docs in builder.rs.

This PR is basically just moving code around, and should not contain any functional changes.

Before this PR, builder.rs was 2743 lines. After this PR, builder.rs is down to a more
manageable 1386 lines and cargo.rs is 1085 lines.

@rustbot
Copy link
Collaborator

rustbot commented Oct 15, 2024

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@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 Oct 15, 2024
/// `rustc_parse::parser::Parser`. See `rustc_builtin_macros::cmdline_attrs::inject` for more
/// information.
#[derive(Debug, Clone)]
struct Rustflags(String, TargetSelection);
Copy link
Member Author

@jieyouxu jieyouxu Oct 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rustflags and HostFlags apparently are only used for builder-cargo-related purposes, so I could make it default visibility here.

@rust-log-analyzer

This comment has been minimized.

@jieyouxu jieyouxu force-pushed the boopstrap branch 2 times, most recently from 63648ac to d2ad6e6 Compare October 15, 2024 07:37
@bors
Copy link
Contributor

bors commented Oct 16, 2024

☔ The latest upstream changes (presumably #131767) made this pull request unmergeable. Please resolve the merge conflicts.

@jieyouxu
Copy link
Member Author

jieyouxu commented Oct 17, 2024

Rebased to fix merge conflicts, no functional changes.

@Mark-Simulacrum
Copy link
Member

r? @onur-ozkan

I don't have a strong opinion on this sort of refactoring (file length is not really a strong indicator IMO, and in some ways I prefer fewer files over more). But leaving it to others to do fine-grained review.

Copy link
Member

@onur-ozkan onur-ozkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, waiting for rebase

@bors
Copy link
Contributor

bors commented Oct 20, 2024

☔ The latest upstream changes (presumably #131970) made this pull request unmergeable. Please resolve the merge conflicts.

I found builder.rs to be a massive file which made it hard to digest. To
make `RUSTFLAGS` usage hardening easier later, I extracted the cargo
part in `builder.rs` into its own module.
@jieyouxu
Copy link
Member Author

jieyouxu commented Oct 21, 2024

I don't have a strong opinion on this sort of refactoring (file length is not really a strong indicator IMO, and in some ways I prefer fewer files over more). But leaving it to others to do fine-grained review.

This was specifically because I was trying to figure out and localize the cargo-specific parts of Builder because it's been a source of spurious rebuilds (in particular, I found out that the flags components are not used by other parts of Builder directly). I wouldn't do it just for file length purposes alone.

@jieyouxu
Copy link
Member Author

LGTM, waiting for rebase

Rebased, no functional changes.

@onur-ozkan
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Oct 21, 2024

📌 Commit 2b4bf2d 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 Oct 21, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 21, 2024
…iaskrgr

Rollup of 4 pull requests

Successful merges:

 - rust-lang#126588 (Added more scenarios where comma to be removed in the function arg)
 - rust-lang#131728 (bootstrap: extract builder cargo to its own module)
 - rust-lang#131968 (Rip out old effects var handling code from traits)
 - rust-lang#131981 (Remove the `BoundConstness::NotConst` variant)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 09a22b8 into rust-lang:master Oct 21, 2024
6 checks passed
@rustbot rustbot added this to the 1.84.0 milestone Oct 21, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Oct 21, 2024
Rollup merge of rust-lang#131728 - jieyouxu:boopstrap, r=onur-ozkan

bootstrap: extract builder cargo to its own module

I was looking at our cargo rustflags/rustdocflags usages, and I found `builder.rs` to be a large
file which made it hard to digest. This PR tries to break out the cargo command wrapper parts to
its own submodule to make it easier to identify builder cargo-specific logic.

This PR:

- Extracts the cargo command wrapper to its own module and also move `Builder::{bare_,}cargo` impl
  to the submodule.
- Reorganizes some imports in `lib.rs` (no functional changes).
- Slightly adjusts some docs in `builder.rs`.

This PR is basically just moving code around, and should not contain any functional changes.

Before this PR, `builder.rs` was 2743 lines. After this PR, `builder.rs` is down to a more
manageable 1386 lines and `cargo.rs` is 1085 lines.
@jieyouxu jieyouxu deleted the boopstrap branch October 21, 2024 08:40
flip1995 pushed a commit to flip1995/rust that referenced this pull request Nov 7, 2024
…iaskrgr

Rollup of 4 pull requests

Successful merges:

 - rust-lang#126588 (Added more scenarios where comma to be removed in the function arg)
 - rust-lang#131728 (bootstrap: extract builder cargo to its own module)
 - rust-lang#131968 (Rip out old effects var handling code from traits)
 - rust-lang#131981 (Remove the `BoundConstness::NotConst` variant)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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