Skip to content

bootstrap: Handle dotted table keys when parsing bootstrap.toml#157335

Open
Dnreikronos wants to merge 2 commits into
rust-lang:mainfrom
Dnreikronos:bootstrap/dotted_toml_keys
Open

bootstrap: Handle dotted table keys when parsing bootstrap.toml#157335
Dnreikronos wants to merge 2 commits into
rust-lang:mainfrom
Dnreikronos:bootstrap/dotted_toml_keys

Conversation

@Dnreikronos
Copy link
Copy Markdown
Contributor

@Dnreikronos Dnreikronos commented Jun 2, 2026

Fixes #156948

bootstrap.py has a small hand-rolled reader that pulls the stage0 cargo and rustc out of bootstrap.toml before the real TOML parser is built. It only understood [table] headers, so the dotted form that bootstrap.example.toml now uses (build.cargo = "...") was silently dropped, and the cargo/rustc lookup matched those keys in any table rather than only [build].

Teach the reader to strip an optional dotted prefix and treat it as the key's table, the same way configure.py does when it writes the file, and scope the cargo/rustc lookup to [build]. New tests cover the dotted form, equivalence with the section form, wrong-table rejection, and dotted target keys.

Disclosure: the code was written by AI (Claude); reviewed and tested by me.

bootstrap.py uses a small hand-written reader to find the stage0 cargo
and rustc in bootstrap.toml before the real TOML parser is available. It
only recognized `[table]` headers, so dotted keys such as
`build.cargo = "..."` -- the form now used in bootstrap.example.toml --
were silently ignored.

Match an optional dotted prefix on each key and treat that prefix as the
table the key belongs to, mirroring how configure.py strips the
`section.` part when writing the config.
program_config searched every table for the `cargo` and `rustc` keys, so
a key placed in an unrelated table was picked up while the real config
parser only reads them from `[build]`. Scope the lookup to the build
table so the Python and Rust sides agree.
@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 Jun 2, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Jun 2, 2026

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

Copy link
Copy Markdown
Contributor

@clubby789 clubby789 left a comment

Choose a reason for hiding this comment

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

I notice you've been using LLMs to make a lot of contributions quickly; I'd suggest slowing down and doing some more careful review to avoid saturating our capacity. For future LLM changes, we'd appreciate coming to Zulip to discuss them in advance

View changes since this review

Comment on lines +961 to +963
line_section = (
match.group(1) if match.group(1) is not None else cur_section
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This doesn't account for a dotted key within a section:

[target]
x86_64-unknown-linux-gnu.cc = "gcc"

build.get_toml("cc", "target.x86_64-unknown-linux-gnu") returns None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This also means that

[foo]
build.cargo = "false"

build.cargo() returns "false", despite that being in the wrong section

@rustbot rustbot 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 Jun 3, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Jun 3, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@Dnreikronos
Copy link
Copy Markdown
Contributor Author

I notice you've been using LLMs to make a lot of contributions quickly; I'd suggest slowing down and doing some more careful review to avoid saturating our capacity. For future LLM changes, we'd appreciate coming to Zulip to discuss them in advance

View changes since this review

Ofc, thanks for sending me the Zulip URL.
I will definitely invest more time on the issues to don't saturate the capacity of the team.
I just have one question...does you guys(maintainers) are using LLM?

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

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

bootstrap parsing of bootstrap.toml doesn't handle dotted table names in some cases

3 participants