Skip to content

Commit dea2019

Browse files
lqdKobzol
authored andcommitted
Add test for unstable values of -Clink-self-contained
1 parent 42a5264 commit dea2019

11 files changed

+44
-8
lines changed

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

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// Test linking using `cc` with `rust-lld`, using the unstable CLI described in MCP 510
2-
// see https://github.com/rust-lang/compiler-team/issues/510 for more info
1+
// Test linking using `cc` with `rust-lld`, using the `-Clinker-features` and
2+
// `-Clink-self-contained` CLI flags.
33

44
//@ needs-rust-lld
55
//@ ignore-s390x lld does not yet support s390x as target
@@ -19,7 +19,9 @@ fn main() {
1919
);
2020

2121
// It should not be used when we explicitly opt out of lld.
22-
assert_rustc_doesnt_use_lld(rustc().arg("-Clinker-features=-lld").input("main.rs"));
22+
assert_rustc_doesnt_use_lld(
23+
rustc().arg("-Clinker-features=-lld").arg("-Zunstable-options").input("main.rs"),
24+
);
2325

2426
// While we're here, also check that the last linker feature flag "wins" when passed multiple
2527
// times to rustc.

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

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Checks that self-contained linking components cannot be both enabled and disabled at the same
22
// time on the CLI.
33

4-
//@ check-fail
54
//@ revisions: one many
65
//@ [one] compile-flags: -Clink-self-contained=-linker -Clink-self-contained=+linker
76
//@ [many] compile-flags: -Clink-self-contained=+linker,+crto -Clink-self-contained=-linker,-crto -Zunstable-options
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error: only `-C link-self-contained` values `y`/`yes`/`on`/`n`/`no`/`off`/`-linker`/`+linker` are stable, the `-Z unstable-options` flag must also be passed to use the unstable values
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error: only `-C link-self-contained` values `y`/`yes`/`on`/`n`/`no`/`off`/`-linker`/`+linker` are stable, the `-Z unstable-options` flag must also be passed to use the unstable values
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error: only `-C link-self-contained` values `y`/`yes`/`on`/`n`/`no`/`off`/`-linker`/`+linker` are stable, the `-Z unstable-options` flag must also be passed to use the unstable values
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Checks that values for `-Clink-self-contained` other than the blanket enable/disable and
2+
// `+/-linker` require `-Zunstable-options`.
3+
4+
//@ revisions: crto libc unwind sanitizers mingw
5+
//@ [crto] compile-flags: -Clink-self-contained=+crto
6+
//@ [libc] compile-flags: -Clink-self-contained=-libc
7+
//@ [unwind] compile-flags: -Clink-self-contained=+unwind
8+
//@ [sanitizers] compile-flags: -Clink-self-contained=-sanitizers
9+
//@ [mingw] compile-flags: -Clink-self-contained=+mingw
10+
11+
fn main() {}
12+
13+
//[crto]~? ERROR only `-C link-self-contained` values `y`/`yes`/`on`/`n`/`no`/`off`/`-linker`/`+linker` are stable, the `-Z unstable-options` flag must also be passed to use the unstable values
14+
//[libc]~? ERROR only `-C link-self-contained` values `y`/`yes`/`on`/`n`/`no`/`off`/`-linker`/`+linker` are stable, the `-Z unstable-options` flag must also be passed to use the unstable values
15+
//[unwind]~? ERROR only `-C link-self-contained` values `y`/`yes`/`on`/`n`/`no`/`off`/`-linker`/`+linker` are stable, the `-Z unstable-options` flag must also be passed to use the unstable values
16+
//[sanitizers]~? ERROR only `-C link-self-contained` values `y`/`yes`/`on`/`n`/`no`/`off`/`-linker`/`+linker` are stable, the `-Z unstable-options` flag must also be passed to use the unstable values
17+
//[mingw]~? ERROR only `-C link-self-contained` values `y`/`yes`/`on`/`n`/`no`/`off`/`-linker`/`+linker` are stable, the `-Z unstable-options` flag must also be passed to use the unstable values
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error: only `-C link-self-contained` values `y`/`yes`/`on`/`n`/`no`/`off`/`-linker`/`+linker` are stable, the `-Z unstable-options` flag must also be passed to use the unstable values
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error: only `-C link-self-contained` values `y`/`yes`/`on`/`n`/`no`/`off`/`-linker`/`+linker` are stable, the `-Z unstable-options` flag must also be passed to use the unstable values
2+
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
// Check that -CLinker-features=[+-]lld can only be used on x64.
1+
// Check that `-C linker-features=[+-]lld` is only stable on x64 linux, and needs `-Z
2+
// unstable-options` elsewhere.
23
//
34
//@ check-fail
45
//@ compile-flags: --target=x86_64-unknown-linux-musl -C linker-features=-lld --crate-type=rlib
56
//@ needs-llvm-components: x86
67

78
#![feature(no_core)]
89
#![no_core]
10+
11+
//~? ERROR `-C linker-features` with lld are unstable for the `x86_64-unknown-linux-musl` target, the `-Z unstable-options` flag must also be passed to use it on this target
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
error: `-C linker-features` with lld are unstable for the `x86_64-unknown-linux-musl target, ` the `-Z unstable-options` flag must also be passed to use it on this target
1+
error: `-C linker-features` with lld are unstable for the `x86_64-unknown-linux-musl` target, the `-Z unstable-options` flag must also be passed to use it on this target
22

Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
// Check that -CLinker-features with anything else than lld requires -Zunstable-options.
1+
// Check that only `-C linker-features=[+-]lld` is stable on x64 linux, and that other linker
2+
// features require using `-Z unstable-options`.
3+
//
4+
// Note that, currently, only `lld` is parsed on the CLI, but that other linker features can exist
5+
// internally (`cc`).
26
//
3-
//@ check-fail
47
//@ compile-flags: --target=x86_64-unknown-linux-gnu -C linker-features=+cc --crate-type=rlib
58
//@ needs-llvm-components: x86
69

710
#![feature(no_core)]
811
#![no_core]
12+
13+
//~? ERROR incorrect value `+cc` for codegen option `linker-features` - a list of enabled (`+` prefix) and disabled (`-` prefix) features: `lld` was expected

0 commit comments

Comments
 (0)