Skip to content

Commit 071297e

Browse files
Kobzollqd
authored andcommitted
Stabilize -Clink-self-contained=[+-]linker
1 parent 8bd70c5 commit 071297e

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

compiler/rustc_session/src/config.rs

+15-4
Original file line numberDiff line numberDiff line change
@@ -362,9 +362,20 @@ impl LinkSelfContained {
362362
/// components was set individually. This would also require the `-Zunstable-options` flag, to
363363
/// be allowed.
364364
fn are_unstable_variants_set(&self) -> bool {
365-
let any_component_set =
366-
!self.enabled_components.is_empty() || !self.disabled_components.is_empty();
367-
self.explicitly_set.is_none() && any_component_set
365+
if self.explicitly_set.is_some() {
366+
return false;
367+
}
368+
369+
let mentioned_components = self.enabled_components.union(self.disabled_components);
370+
for component in LinkSelfContainedComponents::all() {
371+
if mentioned_components.contains(component) {
372+
// Only the linker component is stable now
373+
if component != LinkSelfContainedComponents::LINKER {
374+
return true;
375+
}
376+
}
377+
}
378+
false
368379
}
369380

370381
/// Returns whether the self-contained linker component was enabled on the CLI, using the
@@ -2531,7 +2542,7 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
25312542
cg.link_self_contained.are_unstable_variants_set();
25322543
if uses_unstable_self_contained_option {
25332544
early_dcx.early_fatal(
2534-
"only `-C link-self-contained` values `y`/`yes`/`on`/`n`/`no`/`off` are stable, \
2545+
"only `-C link-self-contained` values `y`/`yes`/`on`/`n`/`no`/`off`/`-linker`/`+linker` are stable, \
25352546
the `-Z unstable-options` flag must also be passed to use the unstable values",
25362547
);
25372548
}

tests/run-make/compressed-debuginfo-zstd/rmake.rs

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ fn prepare_and_check<F: FnOnce(&mut Rustc) -> &mut Rustc>(to_find: &str, prepare
2828
rustc
2929
.arg("-Clinker-features=+lld")
3030
.arg("-Clink-self-contained=+linker")
31-
.arg("-Zunstable-options")
3231
.arg("-Cdebuginfo=full")
3332
.input("main.rs");
3433
prepare_rustc(&mut rustc).run();

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

+1-6
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ fn main() {
1111
// Opt-in to lld and the self-contained linker, to link with rust-lld. We'll check that by
1212
// asking the linker to display its version number with a link-arg.
1313
assert_rustc_uses_lld(
14-
rustc()
15-
.arg("-Clinker-features=+lld")
16-
.arg("-Clink-self-contained=+linker")
17-
.arg("-Zunstable-options")
18-
.input("main.rs"),
14+
rustc().arg("-Clinker-features=+lld").arg("-Clink-self-contained=+linker").input("main.rs"),
1915
);
2016

2117
// It should not be used when we explicitly opt-out of lld.
@@ -26,7 +22,6 @@ fn main() {
2622
assert_rustc_uses_lld(
2723
rustc()
2824
.arg("-Clink-self-contained=+linker")
29-
.arg("-Zunstable-options")
3025
.arg("-Clinker-features=-lld")
3126
.arg("-Clinker-features=+lld")
3227
.arg("-Clinker-features=-lld,+lld")

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

+1-1
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)