Skip to content

Commit 9719e33

Browse files
committed
stabilize -Clink-self-contained=[+-]linker
1 parent 068d157 commit 9719e33

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

compiler/rustc_session/src/config.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,14 @@ impl LinkSelfContained {
376376
/// components was set individually. This would also require the `-Zunstable-options` flag, to
377377
/// be allowed.
378378
fn are_unstable_variants_set(&self) -> bool {
379-
let any_component_set =
380-
!self.enabled_components.is_empty() || !self.disabled_components.is_empty();
381-
self.explicitly_set.is_none() && any_component_set
379+
if self.explicitly_set.is_some() {
380+
return false;
381+
}
382+
383+
// Only the linker component is stable, anything else is thus unstable.
384+
let mentioned_components = self.enabled_components.union(self.disabled_components);
385+
let unstable_components = mentioned_components - LinkSelfContainedComponents::LINKER;
386+
!unstable_components.is_empty()
382387
}
383388

384389
/// Returns whether the self-contained linker component was enabled on the CLI, using the
@@ -2651,7 +2656,7 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
26512656
cg.link_self_contained.are_unstable_variants_set();
26522657
if uses_unstable_self_contained_option {
26532658
early_dcx.early_fatal(
2654-
"only `-C link-self-contained` values `y`/`yes`/`on`/`n`/`no`/`off` are stable, \
2659+
"only `-C link-self-contained` values `y`/`yes`/`on`/`n`/`no`/`off`/`-linker`/`+linker` are stable, \
26552660
the `-Z unstable-options` flag must also be passed to use the unstable values",
26562661
);
26572662
}

tests/run-make/rust-lld/rmake.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn main() {
1414
rustc()
1515
.arg("-Clinker-features=+lld")
1616
.arg("-Clink-self-contained=+linker")
17-
.arg("-Zunstable-options")
17+
.arg("-Zunstable-options") // needed for targets other than `x86_64-unknown-linux-gnu`
1818
.input("main.rs"),
1919
);
2020

0 commit comments

Comments
 (0)