Skip to content

Commit 8c62531

Browse files
committed
stabilize -Clink-self-contained=[+-]linker
1 parent 5968d86 commit 8c62531

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
@@ -371,9 +371,14 @@ impl LinkSelfContained {
371371
/// components was set individually. This would also require the `-Zunstable-options` flag, to
372372
/// be allowed.
373373
fn are_unstable_variants_set(&self) -> bool {
374-
let any_component_set =
375-
!self.enabled_components.is_empty() || !self.disabled_components.is_empty();
376-
self.explicitly_set.is_none() && any_component_set
374+
if self.explicitly_set.is_some() {
375+
return false;
376+
}
377+
378+
// Only the linker component is stable, anything else is thus unstable.
379+
let mentioned_components = self.enabled_components.union(self.disabled_components);
380+
let unstable_components = mentioned_components - LinkSelfContainedComponents::LINKER;
381+
!unstable_components.is_empty()
377382
}
378383

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

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)