Overhaul the -l
option parser (for linking to native libs) by Zalathar · Pull Request #132934 · rust-lang/rust (original) (raw)
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request
Rollup merge of rust-lang#132934 - Zalathar:native-libs, r=jieyouxu
Overhaul the -l
option parser (for linking to native libs)
The current parser for -l
options has accumulated over time, making it hard to follow. This PR tries to clean it up in several ways.
Key changes:
- This code now gets its own submodule, to slightly reduce clutter in
rustc_session::config
. - Cleaner division between iterating over multiple
-l
options, and processing each individual one. - Separate “split” step that breaks up the value string into
[KIND[:MODIFIERS]=]NAME[:NEW_NAME]
, but leaves parsing/validating those parts to later steps.- This step also gets its own (disposable) unit test, to make sure it works as expected.
- A context struct reduces the burden of parameter passing, and makes it easier to write error messages that adapt to nightly/stable compilers.
- Fewer calls to
nightly_options
helper functions, because at this point we can get the same information fromUnstableOptions
andUnstableFeatures
(which are downstream of earlier calls to those helper functions).
There should be no overall change in compiler behaviour.