Skip to content

bootstrap: Make main.rs a stub that calls into the library crate - #160829

Open
Zalathar wants to merge 3 commits into
rust-lang:mainfrom
Zalathar:bootstrap-main
Open

bootstrap: Make main.rs a stub that calls into the library crate#160829
Zalathar wants to merge 3 commits into
rust-lang:mainfrom
Zalathar:bootstrap-main

Conversation

@Zalathar

Copy link
Copy Markdown
Member

As with some other bootstrap tools (e.g. compiletest), bootstrap itself is built as a small binary crate (executable) that links to a larger library crate.

If there is non-trivial code in main.rs, then any items it touches need to be publicly exported from the library crate. Those public exports make it harder to identify unused code within bootstrap.

As far as I can tell, there is no compelling rule or principle that determines whether code should be in the entry point or in the library crate, other than historical inertia.

This PR therefore takes all of the code from main.rs, and moves it into a new file cli_main.rs within the bootstrap library crate. That avoids the need for any public exports other than cli_main::main itself.

There should be no change to bootstrap behaviour.


This change makes it possible to change all of bootstrap's pub items to pub(crate). That migration is left to a future PR, as it involves a fair bit of churn, and requires decisions on how to deal with pub items that are currently unused.

Prior art:

This intermediate commit helps to preserve line history.
If there is non-trivial code in `main.rs`, then any items it touches need to be
publicly exported from the library crate. Those public exports make it harder
to identify unused code within bootstrap.
There is no need to re-export anything, so all `pub use` imports can be
simplified to `use` and merged with their siblings.
@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 Aug 10, 2026
@rustbot

rustbot commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

r? @clubby789

rustbot has assigned @clubby789.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: bootstrap
  • bootstrap expanded to 6 candidates
  • Random selection from Mark-Simulacrum, clubby789, jieyouxu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants