From a97fe362f6ce2392683aade69504b139e716ebf6 Mon Sep 17 00:00:00 2001 From: "Eddy (Eduard) Stefes" Date: Thu, 23 Apr 2026 15:42:44 +0200 Subject: [PATCH 1/2] Add `--print=backend-has-mnemonic` and `needs-asm-mnemonic` directive Add infrastructure to query LLVM backend for specific assembly mnemonics and use it in compiletest to conditionally run tests based on instruction availability. This fixes test failures with naked-dead-code-elimination which requires the `RET` mnemonic. Co-authored-by: Folkert de Vries --- src/tests/compiletest.md | 11 +++++++++++ src/tests/directives.md | 3 +++ 2 files changed, 14 insertions(+) diff --git a/src/tests/compiletest.md b/src/tests/compiletest.md index 4c534e9ae..53a6c0cb5 100644 --- a/src/tests/compiletest.md +++ b/src/tests/compiletest.md @@ -346,6 +346,17 @@ See also the [codegen tests](#codegen-tests) for a similar set of tests. If you need to work with `#![no_std]` cross-compiling tests, consult the [`minicore` test auxiliary](./minicore.md) chapter. +#### Conditional assembly tests based on instruction support + +Tests that depend on specific assembly instructions being available can use the +`//@ needs-asm-mnemonic: ` directive. This will skip the test if the +target backend does not support the specified instruction mnemonic. + +For example, a test that requires the `RET` instruction: +```rust,ignore +//@ needs-asm-mnemonic: RET +``` + [`tests/assembly-llvm`]: https://github.com/rust-lang/rust/tree/HEAD/tests/assembly-llvm diff --git a/src/tests/directives.md b/src/tests/directives.md index 76bf2cdbe..9498f7953 100644 --- a/src/tests/directives.md +++ b/src/tests/directives.md @@ -163,6 +163,9 @@ The following directives will check rustc build settings and target settings: For tests that cross-compile to explicit targets via `--target`, use `needs-llvm-components` instead to ensure the appropriate backend is available. +- `needs-asm-mnemonic: ` — ignores if the target backend does not + support the specified assembly mnemonic (e.g., `RET`, `NOP`). + Only supported with the LLVM backend. - `needs-profiler-runtime` — ignores the test if the profiler runtime was not enabled for the target (`build.profiler = true` in `bootstrap.toml`) - `needs-sanitizer-support` — ignores if the sanitizer support was not enabled From 9a4f64b3ee095ac43589b25b32014182698e819b Mon Sep 17 00:00:00 2001 From: The rustc-josh-sync Cronjob Bot Date: Thu, 30 Apr 2026 16:20:30 +0000 Subject: [PATCH 2/2] Prepare for merging from rust-lang/rust This updates the rust-version file to f53b654a8882fd5fc036c4ca7a4ff41ce32497a6. --- rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-version b/rust-version index 2d5b9a994..ea416dc27 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -ca9a134e0985765ded9cfdde4030a5df4db7e2bd +f53b654a8882fd5fc036c4ca7a4ff41ce32497a6