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: Overhaul and simplify the tool_check_step! macro #134950

Merged
merged 4 commits into from
Jan 1, 2025

Conversation

Zalathar
Copy link
Contributor

@Zalathar Zalathar commented Dec 31, 2024

Main changes:

  • Pull most of run out of the macro and into a regular helper function
  • Reduce the number of redundant/unnecessary macro arguments
  • Switch to struct-like syntax so that optional arguments are clearer, and so that rustfmt is happy

The one “functional” change is that the -check.stamp files now get their name from the final path segment, instead of the struct name; in practice this means that they now contain more hyphens in some cases. As far as I'm aware, the exact filename doesn't matter so this should be fine. (that change has been removed from this PR)

@rustbot
Copy link
Collaborator

rustbot commented Dec 31, 2024

r? @albertlarsan68

rustbot has assigned @albertlarsan68.
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 Dec 31, 2024
@rust-log-analyzer

This comment has been minimized.

Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

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

It looks like a nice cleanup to me. I'll wait a bit on the removal of support for out-of-tree tools to hear back from other ppl on T-bootstrap in case that somehow turns out to be relied upon.

Comment on lines +450 to +462
// Currently, all of the tools that use this macro/function are in-tree.
// If support for out-of-tree tools is re-added in the future, those
// steps should probably be marked non-default so that the default
// checks aren't affected by toolstate being broken.
SourceType::InTree,
Copy link
Member

Choose a reason for hiding this comment

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

@rust-lang/bootstrap do you know if there's a specific reason we support out-of-tree tools? Does idk distros or some other consumer rely on this support?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like the general concept of SourceType was introduced in #73297, to control whether warnings are denied by default or not.

At that time, none of the uses of tool_check_step! specified a source type other than InTree. So it's plausible that this macro has never actually been used with out-of-tree tools.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also note that this PR only removes explicit SourceType support from one particular macro. If an “out of tree” tool hypothetically needed to be added, it shouldn't be much trouble to either adjust this macro, or declare an alternative step or macro.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I'm in favor of removing this unused code. If we need support for non-InTree tools, we can add it back when the need arises.

@jieyouxu jieyouxu added S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 31, 2024
@Zalathar
Copy link
Contributor Author

Aside: I was amused to find that I'm following in the footsteps of #131597.

@jieyouxu
Copy link
Member

Aside: I was amused to find that I'm following in the footsteps of #131597.

That was a quick-and-dirty "fix", lol

Ordinary code is much easier to work with than macro-generated code.
All of the tools that use this macro are currently in-tree, so support for
specifying a `SourceType` was not meaningfully used. It can potentially be
re-added in the future if needed.
@Zalathar
Copy link
Contributor Author

Removed the stamp-name changes for being too risky for this PR (diff).

@jieyouxu jieyouxu added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). labels Dec 31, 2024
@jieyouxu

This comment was marked as resolved.

Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

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

Thanks, you can r=me after PR CI is green.

EDIT: with the stamp comment nit above addressed

This tricks rustfmt into formatting the macro arguments as expressions, instead
of giving up and ignoring them.
@Zalathar
Copy link
Contributor Author

@bors r=jieyouxu

@bors
Copy link
Contributor

bors commented Dec 31, 2024

📌 Commit 66fd534 has been approved by jieyouxu

It is now in the queue for this repository.

@bors bors removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 31, 2024
@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Dec 31, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 1, 2025
Rollup of 6 pull requests

Successful merges:

 - rust-lang#131439 (Remove allowing static_mut_refs lint)
 - rust-lang#133292 (E0277: suggest dereferencing function arguments in more cases)
 - rust-lang#134877 (add suggestion for wrongly ordered format parameters)
 - rust-lang#134945 (Some small nits to the borrowck suggestions for mutating a map through index)
 - rust-lang#134950 (bootstrap: Overhaul and simplify the `tool_check_step!` macro)
 - rust-lang#134979 (Provide structured suggestion for `impl Default` of type where all fields have defaults)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit cf7d7f5 into rust-lang:master Jan 1, 2025
6 checks passed
@rustbot rustbot added this to the 1.85.0 milestone Jan 1, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jan 1, 2025
Rollup merge of rust-lang#134950 - Zalathar:tool-check-step, r=jieyouxu

bootstrap: Overhaul and simplify the `tool_check_step!` macro

Main changes:

- Pull most of `run` out of the macro and into a regular helper function
- Reduce the number of redundant/unnecessary macro arguments
- Switch to struct-like syntax so that optional arguments are clearer, and so that rustfmt is happy

~~The one “functional” change is that the `-check.stamp` files now get their name from the final path segment, instead of the struct name; in practice this means that they now contain more hyphens in some cases. As far as I'm aware, the exact filename doesn't matter so this should be fine.~~ (that change has been removed from this PR)
@Zalathar Zalathar deleted the tool-check-step branch January 1, 2025 11:24
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 2, 2025
bootstrap: Overhaul and simplify the `tool_extended!` macro

Similar to rust-lang#134950, but for the macro that declares build steps for some tools.

The main changes are:
- Removing some functionality that isn't needed by any of the tools currently using the macro
- Moving some code out of the macro and into ordinary helper functions
- Switching to one macro invocation per tool, and struct-like syntax so that rustfmt will format them

There should be no functional change.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 2, 2025
bootstrap: Overhaul and simplify the `tool_extended!` macro

Similar to rust-lang#134950, but for the macro that declares build steps for some tools.

The main changes are:
- Removing some functionality that isn't needed by any of the tools currently using the macro
- Moving some code out of the macro and into ordinary helper functions
- Switching to one macro invocation per tool, and struct-like syntax so that rustfmt will format them

There should be no functional change.
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.

7 participants