Commit Graph

234 Commits

Author SHA1 Message Date
Marius Melzer
5bb8d31122 Add aarch64 architecture for L4Re target 2026-08-06 11:47:29 +02:00
Jonathan Brouwer
9e57983bb9 Rollup merge of #160566 - amirHdev:reenable-bool-indexing-llvm23, r=ZuseZ4
Re-enable bool indexing assembly test for LLVM 23

fixes rust-lang/rust#160521

Follow-up rust-lang/rust#159977
2026-08-05 21:55:49 +02:00
Amirhossein Akhlaghpour
ef599d1a3d re-enable bool indexing assembly test for LLVM 23
Signed-off-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
2026-08-05 16:52:31 +03:30
Jonathan Brouwer
8c6b914cec Rollup merge of #158762 - vexide:feat/vex-v5-thumb2, r=jieyouxu
Emit thumb code on VEX V5

This PR switches the default codegen for the VEX V5 target to emit Thumb-2 instructions, allowing for smaller binary sizes (on the programs I tested this change on, I saw a ~20% size decrease on average). The target is renamed to have the `thumb` prefix instead of the `arm` prefix because of the updated instruction set.

Since VEXos starts all programs in Arm32 mode, the program entrypoint is explicitly compiled as ARM code and now transitions to Thumb mode when calling `_start`.

Users can still use the updated target in Arm32 mode by specifying `-Ctarget-feature=-thumb-mode`.

cc @tropicaaal @Gavin-Niederman
2026-08-05 13:36:10 +02:00
Manuel Drehwald
c375a3f106 Gate failing test on LLVM-22 2026-08-04 10:26:27 -04:00
Trevor Gross
2c089a6e58 x86_64-win: Return f128 on the stack, matching LLVM
We can start matching the codegen introduced by LLVM at [1]. This alone
isn't enough to make f128 functional on the platform because libcalls
use the LLVM ABI.

Current behavior originally introduced in RUST-128388.

[1]: aa47e59245
2026-08-04 10:22:35 -04:00
Jakub Beránek
3fd8b4f7a0 Rollup merge of #159977 - amirHdev:test-123216-bool-indexing, r=petrochenkov
Add regression test for bool indexing codegen

Fixes rust-lang/rust#123216
2026-08-04 11:10:19 +02:00
Amirhossein Akhlaghpour
ad2ca88d8d fix: restrict bool indexing assembly test from Windows
Signed-off-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
2026-08-02 20:34:25 +03:30
Jonathan Brouwer
8b35b28188 Rollup merge of #159499 - AayushMainali-Github:main, r=jieyouxu
tests: prefer max-llvm-major-version over open LLVM ranges

Per review, take option 3: replace open `ignore-llvm-version` ranges with `max-llvm-major-version`. Left gdb `X - 99.0` ranges alone so CI's older gdb still runs those tests.

Fixes rust-lang/rust#159338.
2026-08-02 16:19:30 +02:00
AayushMainali-Github
20ac2125a2 tests: prefer max-llvm-major-version over open LLVM ranges 2026-07-29 05:24:17 +00:00
bors
4fefe36567 Auto merge of #160003 - JonathanBrouwer:rollup-FL8k6B6, r=JonathanBrouwer
Rollup of 14 pull requests

Successful merges:

 - rust-lang/rust#158417 (Avoid ICE when cfg_eval recovers no item from derive input)
 - rust-lang/rust#159085 (Fix decoding attributes of `SyntheticCoroutineBody`)
 - rust-lang/rust#159554 (feat: Update method signature of int_from_ascii)
 - rust-lang/rust#159637 (Some place analysis tweaks)
 - rust-lang/rust#159649 (Normalize region obligations before regionck)
 - rust-lang/rust#159961 (sanitize_standard_fds: Miri supports poll now)
 - rust-lang/rust#159967 (rustc_target: callconv: mips64: Return structs with single f128 in FPRs)
 - rust-lang/rust#159253 (Add suggestions for using `#[export_name]` instead of `#[link_name]` on static)
 - rust-lang/rust#159804 (Expand docs for fs::metadata and fs::symlink_metadata)
 - rust-lang/rust#159821 (Update expect message using the recommended style in binary_heap module)
 - rust-lang/rust#159840 (Fix opaque type ICE in late lints under the next-generation trait solver)
 - rust-lang/rust#159956 (Fix observable intermediate state in `thread::add_spawn_hook`)
 - rust-lang/rust#159991 (std: make send_process_group_signal unsupported on VxWorks)
 - rust-lang/rust#159996 (Detect when a macro without exclamation mark uses square brackets)
2026-07-27 13:05:45 +00:00
Jonathan Brouwer
8ee7903a20 Rollup merge of #159967 - Gelbpunkt:mips64-struct-return-single-f128, r=folkertdev
rustc_target: callconv: mips64: Return structs with single f128 in FPRs

The MIPS n64 ABI returns structs that meet the following requirements:

- Up to 128 bits large
- Only one or two fields, all of which are floating point
- Offset of the first field is zero

in floating point registers. This was already accounted for, but the edge case of a struct with a single `f128` field was not handled correctly and would always be returned in integer registers.

If we tell the backend to use a `f128` register here, LLVM will return the value in two of the 64-bit FPRs, `$f0` and `$f2`. That is equivalent to how Clang, GCC and also Rustc today would return a `long double` / `f128`.

However, both Clang and GCC return a struct with a single long double field in `$f0` and `$f1`. In order to achieve the same result in Rustc, we need to set the `InReg` attribute on the return value.

With this, we now match Clang and GCC.

Clang: https://godbolt.org/z/za8qv9P4n
GCC: https://godbolt.org/z/9qcdGsce6
Rustc currently: https://godbolt.org/z/8sP5G4ash
LLVM IR comparisons: https://godbolt.org/z/ojaTTY9hW

---

I'm not sure if it is acceptable to use `Reg::f128` since MIPS has no 128-bit floating point registers unless MSA is present. LLVM lowers it correctly to use two FPRs, not sure if this would cause issues with GCC.

`f16` probably also needs some changes here, but I'll do that as a follow-up.

---

r? @folkertdev

and Folkert also told me to cc @tgross35 :)
2026-07-27 11:58:09 +02:00
bors
ad0c9dce27 Auto merge of #159317 - workingjubilee:aarch64-bool-callconv, r=davidtwco
Fix `bool` calling convention for aarch64, etc.



We have been making a broad assumption about the way `bool` should be handled that *may* be correct for Rust calling Rust but is wildly incorrect for cross-language FFI calls. The ABI of `bool` is generally poorly-specified in any C psABI, and often deliberately allows for deviation after the first 8 bits.

This has surfaced as a bug that can corrupt Rust programs on aarch64, but it is a potential latent bug when it comes to every ABI. The simplest solution is to simply stop applying the special case when generating `bool`'s ArgAttributes. This yields control to the later ABI implementations, which may then sign or zero extend the `bool` (or not) according to their needs.
2026-07-27 09:35:03 +00:00
Amirhossein Akhlaghpour
ad3ce248b6 test: add regression test for bool indexing codegen
Signed-off-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
2026-07-26 21:29:02 +03:30
Aelin Reidel
b0bc5a0d6d rustc_target: callconv: mips64: Return structs with single f128 in FPRs
The MIPS n64 ABI returns structs that meet the following requirements:

- Up to 128 bits large
- Only one or two fields, all of which are floating point
- Offset of the first field is zero

in floating point registers. This was already accounted for, but the
edge case of a struct with a single f128 field was not handled correctly
and would always be returned in integer registers.

If we tell the backend to use a f128 register here, LLVM will return the
value in two of the 64-bit FPRs, $f0 and $f2. That is equivalent to
how Clang, GCC and also Rustc today would return a long double / f128.

However, both Clang and GCC return a struct with a single long double
field in $f0 and $f1. In order to achieve the same result in Rustc, we
need to set the InReg attribute on the return value.

With this, we now match Clang and GCC.

Clang: https://godbolt.org/z/za8qv9P4n
GCC: https://godbolt.org/z/9qcdGsce6
Rustc currently: https://godbolt.org/z/8sP5G4ash
LLVM IR comparisons: https://godbolt.org/z/ojaTTY9hW
2026-07-26 18:33:17 +02:00
Jacob Pratt
0e238fd6c3 Rollup merge of #138618 - nbdd0121:asm_const_ptr, r=bjorn3
Support using const pointers in asm `const` operand

Implements [RFC#3848](https://github.com/rust-lang/rfcs/pull/3848) with tracking issue rust-lang/rust#128464

This adds support of const pointers for asm `const` in addition to plain integers.

The inline `asm!` support is implemented using `i` constraint, and the `global_asm!` and `naked_asm!` support is implemented by inserting `symbol + offset` and make `symbol` compiler-used. For unnamed consts, it will create additional internal & hidden symbols so that they can be referenced by global_asm.

~~The feature is also implemented for GCC backend but it's untested.~~ Tested now.
2026-07-26 00:21:39 -04:00
Jacob Pratt
087a886f57 Rollup merge of #159653 - folkertdev:aarch64_be-asm-types, r=davidtwco
run `tests/assembly-llvm/asm/aarch64-types.rs` for `aarch64_be`

We may as well, tangentially related to https://github.com/rust-lang/rust/pull/154342.

r? davidtwco
2026-07-23 19:18:43 -04:00
Gary Guo
73ff59fce9 Implement asm_const_ptr feature
The backend now fully supports codegen of const pointers, remove the
block inside typeck behind a new feature gate. Tests are also added.
2026-07-23 18:51:29 +01:00
Folkert de Vries
7460074ff2 clear the variant-dependent padding 2026-07-23 12:53:00 +02:00
Folkert de Vries
ff3b1814d6 the tag is not padding 2026-07-23 12:53:00 +02:00
Folkert de Vries
0d2986aaa0 add LLVM baseline test 2026-07-23 12:53:00 +02:00
Folkert de Vries
7490d8ef3a add difference method to range_set 2026-07-23 12:52:59 +02:00
Folkert de Vries
d7ea382797 Stabilize c_variadic 2026-07-22 11:42:09 +02:00
Folkert de Vries
3feb78f7ba define a Simd type in minicore 2026-07-21 14:09:56 +02:00
Folkert de Vries
7ff730b2ce run tests/assembly-llvm/asm/aarch64-types.rs for aarch64_be 2026-07-21 13:12:25 +02:00
Jonathan Brouwer
8e9fb78173 Rollup merge of #150732 - kulst:cpu_is_target_modifier, r=bjorn3
Convert `-Ctarget-cpu` into a target-modifier for AVR, AMDGCN and NVPTX

Crates built for AVR, AMDGCN and NVPTX that specify different values for `-Ctarget-cpu` cannot be soundly linked together.
This PR attempts to make `rustc` ensure that no crates with disagreeing values for `-Ctarget-cpu` are linked together. This is achieved by converting `-Ctarget-cpu` into a target-modifier depending on `--target`.
To do this, the consistency check for `-Ctarget-cpu` considers mismatching values as inconsistent only for targets for which the new flag `requires_consistent_cpu` is set in their target spec.

**Why should `-Ctarget-cpu` be a target-modifier for `nvptx`?**
<details><summary>PTX is a single-module contract</summary>
<p>
PTX requires a binary to start with .version (`ptx$$`) then .target (`sm_$$`). If the ptx contains instructions that are not supported by either .version or .target, the binary is ill-formed and will be rejected by ptxas. The concept of features that can be mixed and matched in a binary does not exist for nvptx and is therefore not supported by LLVM.
</p>
</details>

<details><summary>It prevents the production of bitcode that cannot be codegen'd after linking</summary>
<p>
A target modifier should prevent configurations that are not composable across crates when those crates are linked together. The most prominent example is when enabling a target feature changes the ABI, making cross-crate calls inherently unsound.

In the case of nvptx, ABI mismatch is (at least for now) not the core problem motivating target modifiers. NVIDIA’s documented PTX calling convention has [remained stable since ptx20](https://docs.nvidia.com/cuda/ptx-writers-guide-to-interoperability/index.html#function-calling-sequence).

However, in the current state it is possible to produce bitcode that cannot be codegen'd after linking, because some operations are only lowerable for sufficiently new SM/PTX levels. In the best case this results in an LLVM error during the final llc step, but this is not something we should rely on for correctness.

nvptx has a special compilation pipeline where instead of linking the final PTX object, instead LLVM bitcode is linked. The resulting artifact is then compiled in one invocation.
Now consider crate A which is independently compiled into bitcode with the following rustc arguments:

```Rust
//@ compile-flags: --target nvptx64-nvidia-cuda -C target-cpu=sm_70 --crate-type=rlib
#[cfg(target_feature = "sm_70")]
fn foo() {
    // cannot be lowered to ptx before "sm_70: so currently produces an LLVM error
}
#[cfg(not(target_feature = "sm_70"))]
fn foo() {
    // can be lowered to ptx before "sm_70"
}
pub fn bar() {
    foo()
}
```
Crate A is a dependency of crate B. In the *rustc* invocation of crate B
1. crate B is compiled into bitcode, too
2. both bitcode artifacts are bitcode-linked by *llvm-link*
3. the resulting bitcode artifact is compiled by *llc -mcpu=sm_60*

This should now ideally create an LLVM error, because the linked bitcode contains code paths that were selected under `sm_70` assumptions but the final NVPTX codegen is targeting `sm_60`, where those operations are not lowerable. An LLVM error here is better than silent miscompilation, but it’s not a promise we should rely on.

A real example where this could happen is the lowering of atomic loads and stores with non-relaxed orderings, which is known to depend on the selected SM level.
</p>
</details>

**Why should `-Ctarget-cpu` be a target-modifier for `amdgcn` and `avr`?**
- In case of AVR the target-cpu defines the ISA, which is encoded in the ELF header flags, amdgcn also encodes the cpu directly into those flags
- To not rely on *lld* which currently prevents it for both by looking at those flags [AVR](597ffbe09d/lld/test/ELF/avr-flags.s) and [amdgcn](597ffbe09d/lld/test/ELF/amdgpu-elf-flags-err.s)

Previous discussions about the topic can be found [here](https://github.com/rust-lang/rust/issues/131799#issuecomment-3390563329) and [here](https://github.com/rust-lang/rust/issues/141468).

I also created a [Zulip discussion](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Making.20-Ctarget-cpu.20a.20target-modifier.20on.20NVPTX/with/566622679).

I am unsure if a MCP is needed before proceeding. If you think so please let me know.

Creating *target-modifiers* for NVPTX *target-features* is to be done in a follow-up.

cc @kjetilkjeka as target maintainer for NVPTX
cc @flakebi as target maintainer for amdgcn
cc @Patryk27 as target maintainer for AVR
cc @RalfJung you were very involved in the discussions so far

Target modifier tracking issue: https://github.com/rust-lang/rust/issues/136966
2026-07-19 23:26:25 +02:00
Jonathan Brouwer
823b1355f7 Rollup merge of #159328 - DeepeshWR:fix/issue-141649-relax-aarch64-stack-check, r=mati865
tests/assembly-llvm: pin frame pointer in issue-141649 aarch64 test

The `scoped_two_small_structs` test expects `sub sp, sp, #48` on
aarch64, which assumes the frame pointer (x29) is saved. Custom targets
that don't set `frame-pointer: non-leaf` (e.g., OpenEmbedded/Yocto's
`aarch64-poky-linux-gnu`) omit x29, producing `sub sp, sp, #32` instead.

Add `-Cforce-frame-pointers=yes` to the aarch64 revision so the test
produces consistent codegen regardless of the target's default frame
pointer policy.
2026-07-18 16:00:03 +02:00
kulst
76d5107658 Treat -Ctarget-cpu as a target-modifier when targeting AVR, AMDGCN and NVPTX
For AVR, AMDGCN, and NVPTX, crates built with different target CPU values are
not generally link-compatible.

Add a `requires_consistent_cpu` flag to the target spec and enable it for these
targets. When the flag is set, treat `-Ctarget-cpu` as a target modifier and
require all linked crates to agree on its value.

Reject `-Ctarget-cpu=native` before codegen for targets that set
`requires_consistent_cpu` to true. Also do not include `native` in the printed
`target-cpus` list for such targets.

Add tests covering:
- which built-in targets set `requires-consistent-cpu`
- cross-crate behavior with and without `requires-consistent-cpu`
- that an omitted `-Ctarget-cpu` compares equal to an explicitly specified
  default CPU
- rejection and printing behavior for `native`
- precedence of repeated `-Ctarget-cpu` flags in metadata comparison and LLVM IR
2026-07-17 15:46:00 +02:00
Jonathan Brouwer
223b78e0f0 Rollup merge of #159391 - nikic:llvm23-test-updates, r=cuviper
Update tests for LLVM 23

Fixes https://github.com/rust-lang/rust/issues/158880.
Fixes https://github.com/rust-lang/rust/issues/158572.
Fixes https://github.com/rust-lang/rust/issues/156050.

One test is disabled on LLVM 23, because it's no longer optimized as expected. Tracked in https://github.com/rust-lang/rust/issues/154141 and https://github.com/llvm/llvm-project/issues/209216.
2026-07-17 15:22:09 +02:00
Deepesh Varatharajan
9e0664acd8 tests/assembly-llvm: pin frame pointer in issue-141649 aarch64 test
The `scoped_two_small_structs` test expects `sub sp, sp, #48` on
aarch64, which assumes the frame pointer (x29) is saved. Custom targets
that don't set `frame-pointer: non-leaf` (e.g., OpenEmbedded/Yocto's
`aarch64-poky-linux-gnu`) omit x29, producing `sub sp, sp, #32` instead.

Add `-Cforce-frame-pointers=yes` to the aarch64 revision so the test
produces consistent codegen regardless of the target's default frame
pointer policy.

Signed-off-by: Deepesh Varatharajan <Deepesh.Varatharajan@windriver.com>
2026-07-16 07:49:54 -07:00
Nikita Popov
61d9ba28a9 Disable slice is_ascii() test on LLVM 23
This doesn't optimize as desired since:
21f439f132
2026-07-16 16:36:06 +02:00
Nikita Popov
283a60b643 Update simd mask test for LLVM 23
Codegen changed in:
66c1b6f019
2026-07-16 16:35:57 +02:00
Jubilee Young
d1990119a8 tests: Verify aarch64 masks bool returns from FFI calls 2026-07-15 16:44:32 -07:00
Jana Dönszelmann
25745ee1f1 fix all tidy annotations 2026-07-13 10:54:53 +02:00
Augie Fackler
f5c700e81a riscv: update c-variadic test for LLVM changes
LLVM 23 is now handling register allocation slightly differently and
only uses CostPerUse=1 in -O{s,z} instead of unconditionally. This
causes the -O3 behavior in this test to be a little smarter and skip
some moves.

I have attempted to make the test pass on both LLVM 22 and 23 without
overly weakening it. Hopefully this is good enough!
2026-07-10 10:33:00 -04:00
Folkert de Vries
3ba37359ab c-variadic: fix i128 argument being misread on arm64ec 2026-07-09 21:51:36 +02:00
Folkert de Vries
acccc68b62 c-variadic: fix i128 argument being misread on aarch64 msvc 2026-07-09 21:51:36 +02:00
Folkert de Vries
92d4098ccc c-variadic: add assembly test files 2026-07-09 21:51:01 +02:00
Folkert de Vries
ab1907725e Support u128/i128 c-variadic arguments
On platforms where `clang` defines `__int128`.
2026-07-09 21:47:37 +02:00
Augie Fackler
f05ac1dcb9 tests: catch up with LLVM returning f128 on the stack
In LLVM 22 the x64 MSVC ABI wasn't matched and f128 was being directly
returned in %xmm0, but now it correctly returns the value via a pointer.
2026-07-06 21:01:44 -04:00
Jonathan Brouwer
3b20143032 Rollup merge of #158473 - hispark-rs:riscv32imfc-unknown-none-elf, r=davidtwco
Add `riscv32imfc-unknown-none-elf` bare-metal target

This adds a new tier 3 bare-metal target for RV32IMFC cores: RISC-V 32-bit with
the `M`, `F` (hardware single-precision float, `ilp32f` ABI) and `C` extensions,
but **no** atomic (`A`) extension.

## Why a new builtin target

No builtin target pairs **hardware single-float** with **no atomics** today:

- `riscv32imafc-unknown-none-elf` (tier 2) has hard-float but *requires* `A`.
- `riscv32imc-unknown-none-elf` has no atomics but is **soft-float** (`ilp32`).

Cores that have an `F` unit but no `A` extension (a common shape for the
application core of low-power Wi-Fi/BT SoCs, where vendor-supplied closed binary
blobs are compiled with the `ilp32f` ABI, so the soft-float ABI is incompatible)
currently have to ship a custom JSON target spec and build `core` with
`-Zbuild-std` on nightly. There is **no stable path today**: custom target specs
are nightly-only, and the spec drifts with each nightly. A builtin target lets
these users stay on stable with a precompiled `core`. The motivating hardware
includes the application core of SoCs such as the HiSilicon WS63/BS2X family, but
the target itself is vendor-neutral.

A working nightly + `-Zbuild-std` proof of concept (builds `core`/`alloc`,
confirms hard-float `fmul.s`/`fadd.s`, and that atomics lower to plain `lw`/`sw`
with zero `amo*`/`lr.w`/`sc.w`): https://github.com/hispark-rs/hisi-riscv-imfc-poc

## How it is defined

It is `riscv32imafc-unknown-none-elf` minus the `A` extension, handled exactly the
way the existing `riscv32imc-unknown-none-elf` handles a no-`a` core:

- `features = "+m,+f,+c,+forced-atomics"`, `llvm_abiname = ilp32f`
- `atomic_cas = false`: `lr.w`/`sc.w`/`amo*` are never emitted, so the target does
  not trap on a core without `A`. `+forced-atomics` lowers atomic load/store to
  plain load/store (sound on a single hart); compare-and-swap and other RMW
  atomics are off, so downstream crates use a critical-section polyfill (e.g.
  `portable-atomic`'s `critical-section` feature) for those.

## Changes

- New target spec `riscv32imfc_unknown_none_elf.rs` + registration in `spec/mod.rs`.
- Added to the `tests/assembly-llvm/targets/targets-elf.rs` sanity test (satisfies
  the `target_policy` and `target_specific_tests` tidy checks).
- Documented on the shared `riscv32-unknown-none-elf` platform-support page and
  listed in `platform-support.md`.

## Verification

- `./x test tidy` — passes.
- `./x test tests/assembly-llvm/targets/targets-elf.rs` — passes (262 passed,
  0 failed); satisfies the "must be able to produce assembly" requirement.

## Tier 3 target policy

Acknowledgement of each [tier 3 target policy](https://doc.rust-lang.org/rustc/target-tier-policy.html#tier-3-target-policy) requirement:

> A tier 3 target must have a designated developer or developers (the "target maintainers") on record to be CCed when issues arise regarding the target. (The mechanism to track and CC such developers may evolve over time.)

Ack. @sanchuanhehe will maintain the target; recorded on the
`riscv32-unknown-none-elf` platform-support page.

> Targets must use naming consistent with any existing targets; for instance, a target for the same CPU or OS as an existing Rust target should use the same name for that CPU or OS. Targets should normally use the same names and naming conventions as used elsewhere in the broader ecosystem beyond Rust (such as in other toolchains), unless they have a very good reason to diverge. Changing the name of a target can be highly disruptive, especially once the target reaches a higher tier, so getting the name right is important even for a tier 3 target.
>
> Target names should not introduce undue confusion or ambiguity unless absolutely necessary to maintain ecosystem compatibility. For example, if the name of the target makes people extremely likely to form incorrect beliefs about what it targets, the name should be changed or augmented to disambiguate it.
>
> If possible, use only letters, numbers, dashes and underscores for the name. Periods (.) are known to cause issues in Cargo.

Ack. The target is named `riscv32imfc-unknown-none-elf`, fitting the existing
`riscv32im{,a,c,fc,ac,afc}-unknown-none-elf` family: standard RISC-V ISA-extension
letters (`imfc`) and the `unknown-none-elf` triple shared by the other bare-metal
RISC-V targets. The name uses only letters, numbers and dashes.

> Tier 3 targets may have unusual requirements to build or use, but must not create legal issues or impose onerous legal terms for the Rust project or for Rust developers or users.
>
> The target must not introduce license incompatibilities.
>
> Anything added to the Rust repository must be under the standard Rust license (MIT OR Apache-2.0).
>
> The target must not cause the Rust tools or libraries built for any other host (even when supporting cross-compilation to the target) to depend on any new dependency less permissive than the Rust licensing policy.
>
> Compiling, linking, and emitting functional binaries, libraries, or other code for the target must not depend on proprietary (non-FOSS) libraries.

Ack. Everything added is under `MIT OR Apache-2.0`. The change is a purely
additive target spec plus docs and a test; it introduces no new dependency and no
proprietary component. Code generation uses the in-tree LLVM RISC-V backend only.

> Neither this policy nor any decisions made regarding targets shall create any binding agreement or estoppel by any party. If any member of an approving Rust team serves as one of the maintainers of a target, or has any legal or employment requirement (explicit or implicit) that might affect their decisions regarding a target, they must recuse themselves from any approval decisions regarding the target's tier status, though they may otherwise participate in discussions.

Ack.

> Tier 3 targets should attempt to implement as much of the standard libraries as possible and appropriate (core for most targets, alloc for targets that can support dynamic memory allocation, std for targets with an operating system or equivalent layer of system-provided functionality), but may leave some code unimplemented (either unavailable or stubbed out as appropriate), whether because the target makes it impossible to implement or challenging to implement. The authors of pull requests are not obligated to avoid calling any portions of the standard library on the basis of a tier 3 target not implementing those portions.

Ack. This is a bare-metal `no_std` target (`std: false`). `core` and `alloc`
build for it, the same as the sibling `riscv32imc` / `riscv32imafc` targets; `std`
is not applicable as there is no operating system layer.

> The target must provide documentation for the Rust community explaining how to build for the target, using cross-compilation if possible. If the target supports running binaries, or running tests (even if they do not pass), the documentation must explain how to run such binaries or tests for the target, using emulation if possible or dedicated hardware if necessary.

Ack. Documented on the shared `riscv32-unknown-none-elf` platform-support page
(cross-compiled, `rust-lld`, linker-script requirement). Like the other bare-metal
RISC-V targets, the Rust test suite cannot be run on it; it must be run in a
simulator or on hardware.

> Tier 3 targets must not impose burden on the authors of pull requests, or other developers in the community, to maintain the target. In particular, do not post comments (automated or manual) on a PR that derail or suggest a block on the PR based on a tier 3 target. Do not send automated messages or notifications (via any medium, including via @) to a PR author or others involved with a PR regarding a tier 3 target, unless they have opted into such messages.

Ack.

> Patches adding or updating tier 3 targets must not break any existing tier 2 or tier 1 target, and must not knowingly break another tier 3 target without approval of either the compiler team or the maintainers of the other tier 3 target. In particular, this may come up when working on closely related targets, such as variations of the same architecture with different features. Avoid introducing unconditional uses of features that another variation of the target may not have; use conditional compilation or runtime detection, as appropriate, to let each target run code supported by that target.

Ack. The change is additive only and touches no code shared with other targets;
`./x test tidy` and the `targets-elf` assembly test pass. No unconditional use of
any feature is introduced that would affect other RISC-V target variations.

> Tier 3 targets must be able to produce assembly using at least one of rustc's supported backends from any host target. (Having support in a fork of the backend is not sufficient, it must be upstream.)

Ack. Covered by the new `tests/assembly-llvm/targets/targets-elf.rs` revision,
which passes using the upstream LLVM backend.

> If a tier 3 target stops meeting these requirements [...] we may post a PR to remove it; any such PR will be CCed to the target maintainers [...] to check potential interest in improving the situation.

Ack.
2026-07-05 08:47:07 +02:00
Lewis McClelland
fbb6a44472 Emit thumb code on VEX V5 2026-07-03 21:30:33 -07:00
Jacob Pratt
95adef7b5c Rollup merge of #158364 - heiher:loong-asm-simd, r=wesleywiser
rustc_target/asm: add LoongArch LSX/LASX inline asm register support

Add support for LoongArch LSX and LASX registers in inline assembly by introducing the `vreg` and `xreg` register classes, along with their associated vector types and operand modifiers. The new register classes are gated behind the `asm_experimental_reg` feature. Also model the overlap between FPU, LSX, and LASX registers so register conflict checking works correctly for aliased registers.
2026-07-01 17:42:28 -04:00
Jacob Pratt
e601172b0b Rollup merge of #158449 - ferrocene:rename-qnx-targets, r=workingjubilee
QNX target renaming

This PR renames two QNX targets:

- `aarch64-unknown-nto-qnx800` becomes simply `aarch64-unknown-qnx`
- `x86_64-pc-nto-qnx800` becomes simply `x86_64-pc-qnx`

In addition:

- references to *QNX OS* and *QNX Neutrino RTOS* are replaced with *QNX SDP* for uniformity
- the `spec::base::nto_qnx` module is renamed to `base::spec::qnx_sdp` to match the above
- the `target_os` of the QNX SDP 8.0 targets is changed to `qnx` to match the target name
- a *lot* of code is then touched to handle `any(target_os = "nto", target_os = "qnx")`

I think it's worth noting that *QNX Software Development Platform* is the *build environment* that you download and install, and you can use it to create a custom *run-time environment*. In SDP 7.x the run-time environment was based on *QNX Neutrino 7.x*, but in SDP 8.0 the run-time environment is based on *QNX OS 8.0*. I think it was weird to users to see the two different run-time environments in the docs, and referring to the build environment just seems to make more sense anyway because that's what users install, it's where the headers live, and ultimately it's what the toolchain will care about.

The new target names match those reported by `clang` running *on* the [self-hosted *QNX Developer Desktop*](https://www.qnx.com/developers/docs/qnxeverywhere/com.qnx.doc.qdd/topic/about.html).

```console
$ clang --version
QNX clang version 21.1.3
Target: x86_64-pc-qnx
Thread model: posix
InstalledDir: /usr/bin
```

Once the compiler knows about the new target names, `libc`, `backtrace` and `cc-rs` can be updated to match, and then building `libstd` for the new targets can be fixed. This rename will cause a bit of churn, but it seemed important to get it changed before anyone tries to finish libstd support for QNX SDP 8.0 (it's currently noted as "in-progress"). It's also Tier 3 so we have fairly broad latitude to do this I think, and aligning with QNX's build of clang just makes sense.

With these changes I can run:

```console
$ ./x build library/std --stage 2 --target x86_64-pc-nto-qnx710,aarch64-unknown-nto-qnx710,x86_64-pc-nto-qnx710_iosock,aarch64-unknown-nto-qnx710_iosock,aarch64-unknown-nto-qnx700
$ ./x build library/core --stage 1 --target x86_64-pc-qnx,aarch64-unknown-qnx
```

The QNX SDP 7.x targets retain their old names, and their `target_os = "nto", target_env = "qnx710"` configuration, to avoid breakage.
2026-07-01 01:03:15 -04:00
Jonathan Brouwer
91316cea83 Rollup merge of #157650 - DeepeshWR:feat/yocto-targets, r=davidtwco
rustc_target: Add OpenEmbedded/Yocto Linux base targets

Add built-in OpenEmbedded/Yocto Linux targets for x86_64, i686, aarch64, armv7, and riscv64.

These targets inherit from the corresponding upstream Linux GNU targets and provide OpenEmbedded-specific target triples and default linker settings. They are intended to serve as base targets for downstream Yocto/OpenEmbedded-generated targets, allowing vendor-specific targets to override metadata (for example, TARGET_VENDOR) while reusing a common target configuration.

This reduces duplication in Yocto-based Rust integrations and avoids maintaining downstream copies of largely identical target specifications.

**Tier 3 Policy Notes**

To cover the Tier 3 requirements:

> A tier 3 target must have a designated developer or developers

These targets have a designated maintainer: @DeepeshWR, as documented in the platform support documentation added by this PR.

> Targets must use naming consistent with any existing targets

The targets follow the existing target naming conventions and are derived from the corresponding upstream Linux GNU targets:

```
x86_64-oe-linux-gnu
aarch64-oe-linux-gnu
i686-oe-linux-gnu
armv7-oe-linux-gnueabihf
riscv64-oe-linux-gnu
```

The oe vendor component identifies OpenEmbedded/Yocto-based systems while preserving the established architecture/OS/ABI naming scheme.

> Tier 3 targets may have unusual requirements to build or use, but must not create legal issues or impose onerous legal terms for the Rust project or for Rust developers or users

These targets do not introduce any additional legal requirements. They use the standard OpenEmbedded/Yocto cross-compilation toolchains and are intended to behave similarly to the corresponding Linux GNU targets.

> Tier 3 targets should attempt to implement as much of the standard libraries as possible and appropriate

These targets inherit from the corresponding Linux GNU targets and support the standard library in the same manner as their upstream counterparts.

> The target must provide documentation for the Rust community explaining how to build for the target

This PR adds platform-support documentation describing the targets, maintainership, requirements, and intended usage.

> Tier 3 targets must not impose burden on the authors of pull requests, or other developers in the community, to maintain the target

The targets are thin wrappers around existing Linux GNU targets and primarily provide canonical OpenEmbedded/Yocto target triples and default linker configuration. They do not require additional CI infrastructure or special maintenance beyond keeping them aligned with their upstream Linux GNU base targets.

> Patches adding or updating tier 3 targets must not break any existing tier 2 or tier 1 target, and must not knowingly break another tier 3 target without approval of either the compiler team or the maintainers of the other tier 3 target

Noted.

> Tier 3 targets must be able to produce assembly using at least one of rustc's supported backends from any host target

These targets use LLVM through the existing Rust code generation pipeline, just like their corresponding Linux GNU targets.

r? @davidtwco
2026-06-30 22:29:29 +02:00
Jonathan Pallant
804de70ca0 QNX target renaming
- aarch64-unknown-nto-qnx800 becomes simply aarch64-unknown-qnx
- x86_64-pc-nto-qnx800 becomes simply x86_64-pc-qnx
- references to QNX OS and QNX Neutrino RTOS are replaced with QNX SDP for uniformity
- various nto_qnx modules are named to qnx_sdp to match the above

The new target names are more consistent with those used by the QNX SDP 8.0 toolchain, and reflect a level on ongoing API stability similar to that for macOS and Linux (which simply have minimum supported versions record for their targets).

Once the compiler knows about the new target names, libc and backtrace can be updated to match, and then building libstd for the new targets can be fixed.

With these changes I can run:

```console
$ ./x build library/std --stage 2 --target x86_64-pc-nto-qnx710,aarch64-unknown-nto-qnx710,x86_64-pc-nto-qnx710_iosock,aarch64-unknown-nto-qnx710_iosock,aarch64-unknown-nto-qnx700
$ ./x build library/core --stage 1 --target x86_64-pc-qnx,aarch64-unknown-qnx
```
2026-06-30 09:01:03 +00:00
Jonathan Brouwer
67b5ab7707 Rollup merge of #155722 - jchlanda:jakub/pac, r=davidtwco
Introduce aarch64-unknown-linux-pauthtest target

This target enables Pointer Authentication Code (PAC) support in Rust on AArch64
ELF-based Linux systems. It uses the `aarch64-unknown-linux-pauthtest` LLVM
target and a pointer-authentication-enabled sysroot with a custom musl as a
reference libc implementation. Dynamic linking is required, with a dynamic
linker acting as the ELF interpreter that can resolve pauth relocations and
enforce pointer authentication constraints.

### Supported features include:
* authentication of signed function pointers for extern "C" calls (corresponds
  to LLVM's `-fptrauth-calls`)
* signing of return addresses before spilling to the stack and authentication
  after restoring for non-leaf functions (corresponds to `-fptrauth-returns`)
* trapping on authentication failure when the FPAC feature is not present
  (corresponds to `-fptrauth-auth-traps`)
* signing of init/fini array entries using the LLVM-defined pointer
  authentication scheme (corresponds to `-fptrauth-init-fini` and
  `-fptrauth-init-fini-address-discrimination`)
* non-ABI-affecting indirect control-flow hardening features as implemented in
  LLVM (corresponds to `-faarch64-jump-table-hardening` and
  `-fptrauth-indirect-gotos`)
* signed ELF GOT entries (gated behind `-Z ptrauth-elf-got`, off by default)

Existing compiler support, such as enabling branch authentication instructions
(i.e.: `-Z branch-protection`) provide limited functionality, mainly signing
return addresses (`pac-ret`). The new target goes further by enabling ABI-level
pointer authentication support.

This target does not define a new ABI; it builds on the existing C/C++ language
ABI with pointer authentication support added. However, different authentication
features, encoded in the signing schema, are not ABI-compatible with one
another.

### Useful links:
* Earlier PR: https://github.com/rust-lang/rust/pull/154759
* Part of: https://github.com/rust-lang/rust/issues/148640
* Project goal: https://rust-lang.github.io/rust-project-goals/2026/aarch64_pointer_authentication_pauthtest.html
* Clang pointer authentication documentation:
  https://clang.llvm.org/docs/PointerAuthentication.html
* LLVM pointer authentication documentation:
  https://llvm.org/docs/PointerAuth.html
* PAuth ABI Extension to ELF for the AArch64 architecture:
  https://github.com/ARM-software/abi-aa/blob/main/pauthabielf64/pauthabielf64.rst

### Tier 3 check list
> - A tier 3 target must have a designated developer or developers (the "target
>   maintainers") on record to be CCed when issues arise regarding the target.
>   (The mechanism to track and CC such developers may evolve over time.)

I pledge to do my best maintaining it.

> - Targets must use naming consistent with any existing targets; for instance, a
>   target for the same CPU or OS as an existing Rust target should use the same
>   name for that CPU or OS. Targets should normally use the same names and
>   naming conventions as used elsewhere in the broader ecosystem beyond Rust
>   (such as in other toolchains), unless they have a very good reason to
>   diverge. Changing the name of a target can be highly disruptive, especially
>   once the target reaches a higher tier, so getting the name right is important
>   even for a tier 3 target.

The name chosen for the target is `aarch64-unknown-linux-pauthtest` which
mirrors the [LLVM target naming](https://github.com/llvm/llvm-project/blob/main/llvm/unittests/TargetParser/TripleTest.cpp#L1407).

>   - Target names should not introduce undue confusion or ambiguity unless
>     absolutely necessary to maintain ecosystem compatibility. For example, if
>     the name of the target makes people extremely likely to form incorrect
>     beliefs about what it targets, the name should be changed or augmented to
>     disambiguate it.

There should be no confusion, the name follows naming convention and is
descriptive.

>   - If possible, use only letters, numbers, dashes and underscores for the name.
>     Periods (`.`) are known to cause issues in Cargo.

Letters, numbers and dashes only.

> - Tier 3 targets may have unusual requirements to build or use, but must not
>   create legal issues or impose onerous legal terms for the Rust project or for
>   Rust developers or users.

The target requires system `clang` and `lld` available as well as custom libc
([musl](https://github.com/access-softek/musl) based) and sysroot, provided [through the build scripts](https://github.com/access-softek/pauth-toolchain-build-scripts/tree/master).

>   - The target must not introduce license incompatibilities.

There are no license implications.

>   - Anything added to the Rust repository must be under the standard Rust
>     license (`MIT OR Apache-2.0`).

Understood.

>   - The target must not cause the Rust tools or libraries built for any other
>     host (even when supporting cross-compilation to the target) to depend
>     on any new dependency less permissive than the Rust licensing policy. This
>     applies whether the dependency is a Rust crate that would require adding
>     new license exceptions (as specified by the `tidy` tool in the
>     rust-lang/rust repository), or whether the dependency is a native library
>     or binary. In other words, the introduction of the target must not cause a
>     user installing or running a version of Rust or the Rust tools to be
>     subject to any new license requirements.

There are no new dependencies or requirements.

>   - Compiling, linking, and emitting functional binaries, libraries, or other
>     code for the target (whether hosted on the target itself or cross-compiling
>     from another target) must not depend on proprietary (non-FOSS) libraries.
>     Host tools built for the target itself may depend on the ordinary runtime
>     libraries supplied by the platform and commonly used by other applications
>     built for the target, but those libraries must not be required for code
>     generation for the target; cross-compilation to the target must not require
>     such libraries at all. For instance, `rustc` built for the target may
>     depend on a common proprietary C runtime library or console output library,
>     but must not depend on a proprietary code generation library or code
>     optimization library. Rust's license permits such combinations, but the
>     Rust project has no interest in maintaining such combinations within the
>     scope of Rust itself, even at tier 3.

The target only relies on open source tools.

>   - "onerous" here is an intentionally subjective term. At a minimum, "onerous"
>     legal/licensing terms include but are *not* limited to: non-disclosure
>     requirements, non-compete requirements, contributor license agreements
>     (CLAs) or equivalent, "non-commercial"/"research-only"/etc terms,
>     requirements conditional on the employer or employment of any particular
>     Rust developers, revocable terms, any requirements that create liability
>     for the Rust project or its developers or users, or any requirements that
>     adversely affect the livelihood or prospects of the Rust project or its
>     developers or users.

No such terms present.

> - Neither this policy nor any decisions made regarding targets shall create any
>   binding agreement or estoppel by any party. If any member of an approving
>   Rust team serves as one of the maintainers of a target, or has any legal or
>   employment requirement (explicit or implicit) that might affect their
>   decisions regarding a target, they must recuse themselves from any approval
>   decisions regarding the target's tier status, though they may otherwise
>   participate in discussions.

Understood.

>   - This requirement does not prevent part or all of this policy from being
>     cited in an explicit contract or work agreement (e.g. to implement or
>     maintain support for a target). This requirement exists to ensure that a
>     developer or team responsible for reviewing and approving a target does not
>     face any legal threats or obligations that would prevent them from freely
>     exercising their judgment in such approval, even if such judgment involves
>     subjective matters or goes beyond the letter of these requirements.

Understood.

> - Tier 3 targets should attempt to implement as much of the standard libraries
>   as possible and appropriate (`core` for most targets, `alloc` for targets
>   that can support dynamic memory allocation, `std` for targets with an
>   operating system or equivalent layer of system-provided functionality), but
>   may leave some code unimplemented (either unavailable or stubbed out as
>   appropriate), whether because the target makes it impossible to implement or
>   challenging to implement. The authors of pull requests are not obligated to
>   avoid calling any portions of the standard library on the basis of a tier 3
>   target not implementing those portions.

`aarch64-unknown-linux-pauthtest target` has std library support, moreover all
`library` tests pass for the target.

> - The target must provide documentation for the Rust community explaining how
>   to build for the target, using cross-compilation if possible. If the target
>   supports running binaries, or running tests (even if they do not pass), the
>   documentation must explain how to run such binaries or tests for the target,
>   using emulation if possible or dedicated hardware if necessary.

Platform support document covers building instructions.

> - Tier 3 targets must not impose burden on the authors of pull requests, or
>   other developers in the community, to maintain the target. In particular,
>   do not post comments (automated or manual) on a PR that derail or suggest a
>   block on the PR based on a tier 3 target. Do not send automated messages or
>   notifications (via any medium, including via `@`) to a PR author or others
>   involved with a PR regarding a tier 3 target, unless they have opted into
>   such messages.

Understood.

>   - Backlinks such as those generated by the issue/PR tracker when linking to
>     an issue or PR are not considered a violation of this policy, within
>     reason. However, such messages (even on a separate repository) must not
>     generate notifications to anyone involved with a PR who has not requested
>     such notifications.

Understood.

> - Patches adding or updating tier 3 targets must not break any existing tier 2
>   or tier 1 target, and must not knowingly break another tier 3 target without
>   approval of either the compiler team or the maintainers of the other tier 3
>   target.

Understood.

>   - In particular, this may come up when working on closely related targets,
>     such as variations of the same architecture with different features. Avoid
>     introducing unconditional uses of features that another variation of the
>     target may not have; use conditional compilation or runtime detection, as
>     appropriate, to let each target run code supported by that target.

Understood.

> - Tier 3 targets must be able to produce assembly using at least one of
>   rustc's supported backends from any host target. (Having support in a fork
>   of the backend is not sufficient, it must be upstream.)

It is expected that the target should be able to compile binaries on any systems
that are capable of compiling `aarch64` code.
2026-06-30 03:41:22 +02:00
Jonathan Brouwer
e2c515a97a Rollup merge of #158306 - durin42:llvm-23-s390x-vec, r=JohnTitor
tests: modify s390x vector test to be robust to instruction scheduling

A recent LLVM change causes some changes here, if I'm understanding correctly it allows some better latency reduction. From what I can tell, this test doesn't care that only a single register is used, so we use -DAG instead of -NEXT to allow some instruction reordering.

By happy coincidence, the z10 and z13 code matches now, which collapsed some of the test lines. I'm happy to split them back out if that's bad for some reason though!
2026-06-27 15:48:44 +02:00
王一赫
edffa703b7 Add riscv32imfc-unknown-none-elf bare-metal target
Add a tier 3 bare-metal target for RV32IMFC cores that have hardware
single-precision floating point (the `F` extension, `ilp32f` ABI) but no
atomic (`A`) extension.

This is `riscv32imafc-unknown-none-elf` minus the atomic extension,
handled the same way `riscv32imc-unknown-none-elf` handles a no-`a` core:
`+forced-atomics` lowers atomic load/store to plain load/store (sound on a
single hart) while `atomic_cas = false` keeps RMW/CAS off, so no
`lr.w`/`sc.w`/`amo*` are ever emitted and the target does not trap on a
core without the `A` extension. Downstream crates use a critical-section
polyfill (e.g. `portable-atomic`) for compare-and-swap.

This combination has no builtin target today: cores that pair a
hardware-float application core with no atomic extension otherwise need a
custom target spec plus `-Zbuild-std` on nightly, which is unavailable on
stable. The motivating hardware is the application core of vendor SoCs such
as the HiSilicon WS63/BS2X family, but the target is vendor-neutral.

Register the target, add it to the `targets-elf` assembly sanity test, and
document it on the shared `riscv32-unknown-none-elf` platform-support page.
2026-06-27 14:06:50 +08:00
Jakub Chlanda
23a7ecb97c PR feedback: Teach bootstrap 2026-06-26 13:24:12 +00:00