Skip to content

Commit 4c90978

Browse files
committed
Stabilize -Clink-self-contained=[+-]linker
1 parent e7f634c commit 4c90978

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

compiler/rustc_session/src/config.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,14 @@ impl LinkSelfContained {
370370
/// components was set individually. This would also require the `-Zunstable-options` flag, to
371371
/// be allowed.
372372
fn are_unstable_variants_set(&self) -> bool {
373-
let any_component_set =
374-
!self.enabled_components.is_empty() || !self.disabled_components.is_empty();
375-
self.explicitly_set.is_none() && any_component_set
373+
if self.explicitly_set.is_some() {
374+
return false;
375+
}
376+
377+
// Only the linker component is stable, anything else is thus unstable.
378+
let mentioned_components = self.enabled_components.union(self.disabled_components);
379+
let unstable_components = mentioned_components - LinkSelfContainedComponents::LINKER;
380+
!unstable_components.is_empty()
376381
}
377382

378383
/// Returns whether the self-contained linker component was enabled on the CLI, using the
@@ -2632,7 +2637,7 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
26322637
cg.link_self_contained.are_unstable_variants_set();
26332638
if uses_unstable_self_contained_option {
26342639
early_dcx.early_fatal(
2635-
"only `-C link-self-contained` values `y`/`yes`/`on`/`n`/`no`/`off` are stable, \
2640+
"only `-C link-self-contained` values `y`/`yes`/`on`/`n`/`no`/`off`/`-linker`/`+linker` are stable, \
26362641
the `-Z unstable-options` flag must also be passed to use the unstable values",
26372642
);
26382643
}

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

tests/ui/linking/link-self-contained-consistency.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
//@ check-fail
55
//@ revisions: one many
6-
//@ [one] compile-flags: -Clink-self-contained=-linker -Clink-self-contained=+linker -Zunstable-options
6+
//@ [one] compile-flags: -Clink-self-contained=-linker -Clink-self-contained=+linker
77
//@ [many] compile-flags: -Clink-self-contained=+linker,+crto -Clink-self-contained=-linker,-crto -Zunstable-options
88
// ignore-tidy-linelength
99

0 commit comments

Comments
 (0)