diff options
| author | Rémy Rakic <remy.rakic+github@gmail.com> | 2023-06-21 21:46:36 +0000 |
|---|---|---|
| committer | Rémy Rakic <remy.rakic+github@gmail.com> | 2023-06-30 21:01:38 +0000 |
| commit | 0fb80715bbf2ee63e17f3cf65fc60a3db8768e18 (patch) | |
| tree | ef51665fc8710855640230c9ceccc988bf2057b9 /compiler/rustc_session/src/options.rs | |
| parent | 5d91c1ced4d09472b7d355cb075495e38727f26b (diff) | |
| download | rust-0fb80715bbf2ee63e17f3cf65fc60a3db8768e18.tar.gz rust-0fb80715bbf2ee63e17f3cf65fc60a3db8768e18.zip | |
use `LinkSelfContained` for `-C link-self-contained`
Diffstat (limited to 'compiler/rustc_session/src/options.rs')
| -rw-r--r-- | compiler/rustc_session/src/options.rs | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index e5063eef47a..65cb94a9ab8 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -410,6 +410,8 @@ mod desc { pub const parse_split_dwarf_kind: &str = "one of supported split dwarf modes (`split` or `single`)"; pub const parse_gcc_ld: &str = "one of: no value, `lld`"; + pub const parse_link_self_contained: &str = "one of: `y`, `yes`, `on`, `n`, `no`, `off`, or a list of enabled (`+` prefix) and disabled (`-` prefix) \ + components: `crto`, `libc`, `unwind`, `linker`, `sanitizers`, `mingw`"; pub const parse_stack_protector: &str = "one of (`none` (default), `basic`, `strong`, or `all`)"; pub const parse_branch_protection: &str = @@ -1122,6 +1124,34 @@ mod parse { } } + pub(crate) fn parse_link_self_contained(slot: &mut LinkSelfContained, v: Option<&str>) -> bool { + // Whenever `-C link-self-contained` is passed without a value, it's an opt-in + // just like `parse_opt_bool`, the historical value of this flag. + // + // 1. Parse historical single bool values + let s = v.unwrap_or("y"); + match s { + "y" | "yes" | "on" => { + slot.set_all_explicitly(true); + return true; + } + "n" | "no" | "off" => { + slot.set_all_explicitly(false); + return true; + } + _ => {} + } + + // 2. Parse a list of enabled and disabled components. + for comp in s.split(",") { + if slot.handle_cli_component(comp).is_err() { + return false; + } + } + + true + } + pub(crate) fn parse_wasi_exec_model(slot: &mut Option<WasiExecModel>, v: Option<&str>) -> bool { match v { Some("command") => *slot = Some(WasiExecModel::Command), @@ -1265,9 +1295,9 @@ options! { #[rustc_lint_opt_deny_field_access("use `Session::link_dead_code` instead of this field")] link_dead_code: Option<bool> = (None, parse_opt_bool, [TRACKED], "keep dead code at link time (useful for code coverage) (default: no)"), - link_self_contained: Option<bool> = (None, parse_opt_bool, [UNTRACKED], + link_self_contained: LinkSelfContained = (LinkSelfContained::default(), parse_link_self_contained, [UNTRACKED], "control whether to link Rust provided C objects/libraries or rely - on C toolchain installed in the system"), + on a C toolchain or linker installed in the system"), linker: Option<PathBuf> = (None, parse_opt_pathbuf, [UNTRACKED], "system linker to link outputs with"), linker_flavor: Option<LinkerFlavorCli> = (None, parse_linker_flavor, [UNTRACKED], |
