diff options
| author | bors <bors@rust-lang.org> | 2023-07-02 02:25:01 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-07-02 02:25:01 +0000 |
| commit | 8e2d5e3a584b15ffee14984cb0b0986f00754b3d (patch) | |
| tree | 66ce348487ffec3e36e9379451d509ecdb8b09e8 /tests | |
| parent | ba76096bf10b66d222868ca26437ba38c24c7783 (diff) | |
| parent | 38f5a9964ba7e1eeeffc7783d4cf2e4032ca0f31 (diff) | |
| download | rust-8e2d5e3a584b15ffee14984cb0b0986f00754b3d.tar.gz rust-8e2d5e3a584b15ffee14984cb0b0986f00754b3d.zip | |
Auto merge of #112910 - lqd:mcp510, r=petrochenkov
Implement most of MCP510 This implements most of what remains to be done for MCP510: - turns `-C link-self-contained` into a `+`/`-` list of components, like `-C link-self-contained=+linker,+crto,+libc,+unwind,+sanitizers,+mingw`. The scaffolding is present for all these expected components to be implemented and stabilized in the future on their own time. This PR only handles the `-Zgcc-ld=lld` subset of these link-self-contained components as `-Clink-self-contained=+linker` - handles `-C link-self-contained=y|n` as-is today, for compatibility with `rustc_codegen_ssa::back::link::self_contained`'s [explicit opt-in and opt-out](https://github.com/lqd/rust/blob/9eee230cd0a56bfba3ce65121798d9f9f4341cdd/compiler/rustc_codegen_ssa/src/back/link.rs#L1671-L1676). - therefore supports our plan to opt out of `rust-lld` (when it's enabled by default) even for current `-Clink-self-contained` users, with e.g. `-Clink-self-contained -Clink-self-contained=-linker` - turns `add_gcc_ld_path` into its expected final form, by using the `-C link-self-contained=+linker` CLI flag, and whether the `LinkerFlavor` has the expected `Cc::Yes` and `Lld::Yes` shape (this is not yet the case in practice for any CLI linker flavor) - makes the [new clean linker flavors](https://github.com/rust-lang/rust/pull/96827#issuecomment-1208441595) selectable in the CLI in addition to the legacy ones, in order to opt-in to using `cc` and `lld` to emulate `-Zgcc-ld=lld` - ensure the new `-C link-self-contained` components, and `-C linker-flavor`s are unstable, and require `-Z unstable-options` to be used The up-to-date set of flags for the future stable CLI version of `-Zgcc-ld=lld` is currently: `-Clink-self-contained=+linker -Clinker-flavor=gnu-lld-cc -Zunstable-options`. It's possible we'll also need to do something for distros that don't ship `rust-lld`, but maybe there are already no tool search paths to be added to `cc` in this situation anyways. r? `@petrochenkov`
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/run-make/rust-lld/Makefile | 8 | ||||
| -rw-r--r-- | tests/run-make/rust-lld/main.rs | 4 | ||||
| -rw-r--r-- | tests/ui/linkage-attr/incompatible-flavor.stderr | 2 | ||||
| -rw-r--r-- | tests/ui/linkage-attr/unstable-flavor.bpf.stderr | 2 | ||||
| -rw-r--r-- | tests/ui/linkage-attr/unstable-flavor.ptx.stderr | 2 | ||||
| -rw-r--r-- | tests/ui/linkage-attr/unstable-flavor.rs | 8 |
6 files changed, 21 insertions, 5 deletions
diff --git a/tests/run-make/rust-lld/Makefile b/tests/run-make/rust-lld/Makefile new file mode 100644 index 00000000000..f8526530d4d --- /dev/null +++ b/tests/run-make/rust-lld/Makefile @@ -0,0 +1,8 @@ +include ../tools.mk + +# ignore-msvc +# needs-rust-lld +# ignore-s390x lld does not yet support s390x as target +all: + RUSTC_LOG=rustc_codegen_ssa::back::link=info $(RUSTC) -Clink-self-contained=+linker -Clinker-flavor=gnu-lld-cc -Zunstable-options -Clink-args=-Wl,-v main.rs 2> $(TMPDIR)/output.txt + $(CGREP) -e "^LLD [0-9]+\.[0-9]+\.[0-9]+" < $(TMPDIR)/output.txt diff --git a/tests/run-make/rust-lld/main.rs b/tests/run-make/rust-lld/main.rs new file mode 100644 index 00000000000..bf159cd941c --- /dev/null +++ b/tests/run-make/rust-lld/main.rs @@ -0,0 +1,4 @@ +// Test linking using `cc` with `rust-lld`, using the unstable CLI described in MCP 510 +// see https://github.com/rust-lang/compiler-team/issues/510 for more info + +fn main() {} diff --git a/tests/ui/linkage-attr/incompatible-flavor.stderr b/tests/ui/linkage-attr/incompatible-flavor.stderr index e07e778521c..aabdd14b69b 100644 --- a/tests/ui/linkage-attr/incompatible-flavor.stderr +++ b/tests/ui/linkage-attr/incompatible-flavor.stderr @@ -1,6 +1,6 @@ error: linker flavor `msvc` is incompatible with the current target | - = note: compatible flavors are: gcc, ld, ld.lld + = note: compatible flavors are: gnu, gnu-lld, gnu-cc, gnu-lld-cc, gcc, ld, ld.lld error: aborting due to previous error diff --git a/tests/ui/linkage-attr/unstable-flavor.bpf.stderr b/tests/ui/linkage-attr/unstable-flavor.bpf.stderr index 3346d12c20e..594a461769b 100644 --- a/tests/ui/linkage-attr/unstable-flavor.bpf.stderr +++ b/tests/ui/linkage-attr/unstable-flavor.bpf.stderr @@ -1,2 +1,2 @@ -error: linker flavor `bpf-linker` is unstable, `-Z unstable-options` flag must also be passed to explicitly use it +error: the linker flavor `bpf-linker` is unstable, the `-Z unstable-options` flag must also be passed to use the unstable values diff --git a/tests/ui/linkage-attr/unstable-flavor.ptx.stderr b/tests/ui/linkage-attr/unstable-flavor.ptx.stderr index 03ca2a01246..714c09df53f 100644 --- a/tests/ui/linkage-attr/unstable-flavor.ptx.stderr +++ b/tests/ui/linkage-attr/unstable-flavor.ptx.stderr @@ -1,2 +1,2 @@ -error: linker flavor `ptx-linker` is unstable, `-Z unstable-options` flag must also be passed to explicitly use it +error: the linker flavor `ptx-linker` is unstable, the `-Z unstable-options` flag must also be passed to use the unstable values diff --git a/tests/ui/linkage-attr/unstable-flavor.rs b/tests/ui/linkage-attr/unstable-flavor.rs index 5487882dc24..b58fd055fdc 100644 --- a/tests/ui/linkage-attr/unstable-flavor.rs +++ b/tests/ui/linkage-attr/unstable-flavor.rs @@ -1,9 +1,13 @@ +// Even though this test only checks 2 of the 10 or so unstable linker flavors, it exercizes the +// unique codepath checking all unstable options (see `LinkerFlavorCli::is_unstable` and its +// caller). If it passes, all the other unstable options are rejected as well. +// // revisions: bpf ptx // [bpf] compile-flags: --target=bpfel-unknown-none -C linker-flavor=bpf-linker --crate-type=rlib -// [bpf] error-pattern: linker flavor `bpf-linker` is unstable, `-Z unstable-options` flag +// [bpf] error-pattern: linker flavor `bpf-linker` is unstable, the `-Z unstable-options` flag // [bpf] needs-llvm-components: // [ptx] compile-flags: --target=nvptx64-nvidia-cuda -C linker-flavor=ptx-linker --crate-type=rlib -// [ptx] error-pattern: linker flavor `ptx-linker` is unstable, `-Z unstable-options` flag +// [ptx] error-pattern: linker flavor `ptx-linker` is unstable, the `-Z unstable-options` flag // [ptx] needs-llvm-components: #![feature(no_core)] |
