bootstrap: Handle dotted table keys when parsing bootstrap.toml#157335
bootstrap: Handle dotted table keys when parsing bootstrap.toml#157335Dnreikronos wants to merge 2 commits into
Conversation
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.
|
r? @clubby789 rustbot has assigned @clubby789. Use Why was this reviewer chosen?The reviewer was selected based on:
|
There was a problem hiding this comment.
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
| line_section = ( | ||
| match.group(1) if match.group(1) is not None else cur_section | ||
| ) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
This also means that
[foo]
build.cargo = "false"build.cargo() returns "false", despite that being in the wrong section
|
Reminder, once the PR becomes ready for a review, use |
Ofc, thanks for sending me the Zulip URL. |
Fixes #156948
bootstrap.pyhas a small hand-rolled reader that pulls the stage0 cargo and rustc out ofbootstrap.tomlbefore the real TOML parser is built. It only understood[table]headers, so the dotted form thatbootstrap.example.tomlnow 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.pydoes 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.