Commit Graph

2090 Commits

Author SHA1 Message Date
David Wood f0dfeab43d abi: Display bound on TyAbiInterface
The `fmt::Debug` impl for `TyAndLayout<'a, Ty>'` requires `fmt::Display`
on the `Ty` parameter. In `ArgAbi`, `TyAndLayout`'s Ty` is instantiated
with a parameter that implements `TyAbiInterface`. `TyAbiInterface`
only required `fmt::Debug` be implemented on `Self`, not `fmt::Display`,
which meant that it wasn't actually possible to debug print `ArgAbi`.
2025-12-16 11:01:26 +00:00
David Wood 5f27abdbc8 mono: require target feature for scalable vectors
Scalable vector types only work with the relevant target features
enabled, so require this for any function with the types in its
signature.
2025-12-16 11:01:26 +00:00
David Wood a56b1b9283 codegen: implement repr(scalable)
Introduces `BackendRepr::ScalableVector` corresponding to scalable
vector types annotated with `repr(scalable)` which lowers to a scalable
vector type in LLVM.

Co-authored-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com>
2025-12-16 11:00:12 +00:00
Stuart Cook 0ea7d0b956 Rollup merge of #148790 - kevaundray:kw/rv64im-unknown-elf, r=davidtwco,JonathanBrouwer
Add new Tier-3 target: riscv64im-unknown-none-elf

This PR proposes to add riscv64im-unknown-none-elf, a subset of the already supported riscv64imac-unknown-none-elf.

The motivation behind this PR is that we want to standardize (most) zkVMs on riscv64im-none and riscv64ima-none. Having different variants of riscv extensions, also seems to be within expectation, atleast with respects to riscv32.

Note: This does not mean that we will be able to remove [riscv32im-risc0-zkvm-elf](https://doc.rust-lang.org/rustc/platform-support/riscv32im-risc0-zkvm-elf.html) -- I am not aware of all of the dependents for this

**Tier-3 Policy**

> 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 assigned  Rust Embedded Working Group, since they are already maintaining riscv64IMAC, though I am happy to assign myself.

> 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.

It follows the naming convention of the other bare metal riscv targets

> 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.

This has the same requirements as riscv{32, 64}imac

> 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.

> 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.

> 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.

> 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.

> 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.

> 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.)

Acknowledging the above.
2025-12-16 14:40:41 +11:00
Kevaundray Wedderburn 1fe0a85df7 Add rv64IM 2025-12-15 12:17:55 +00:00
Flakebi a9b147259b Allow vector types for amdgpu
The amdgpu target uses vector types in various places. The vector types
can be used on all architectures, there is no associated target feature
that needs to be enabled.

The largest vector type found in LLVM intrinsics is `v32i32`
(`[32 x i32]`) for mfma intrinsics. Note that while this intrinsic is
only supported on some architectures, the vector type itself is
supported on all architectures.
2025-12-14 17:03:51 +01:00
Matthias Krüger b3948e5f10 Rollup merge of #149679 - pmur:murp/ppc-inline-improvements, r=Amanieu
Restrict spe_acc to PowerPC SPE targets

Update the tests, add powerpc-*-gnuspe testing, and create a distinct clobber_abi list for PowerPC SPE targets.

Note, the SPE target does not have vector, vector-scalar, or floating-point specific registers.

r? ```@Amanieu```
2025-12-10 07:54:20 +01:00
Matthias Krüger 397de87965 Rollup merge of #148294 - chenx97:mips64-padding-aggregate-args, r=workingjubilee
callconv: fix mips64 aggregate argument passing for C FFI

MIPS64 needs to put a padding argument before an aggregate argument when
this argument is in an odd-number position, starting from 0, and has an
alignment of 16 bytes or higher, e.g.
`void foo(int a, max_align_t b);` is the same as
`void foo(int a, long _padding, max_align_t b);`
2025-12-10 07:54:18 +01:00
Matthias Krüger 76370238b0 Rollup merge of #144938 - tgross35:more-outline-atomics, r=davidtwco
Enable `outline-atomics` by default on more AArch64 platforms

The baseline Armv8.0 ISA doesn't have atomics instructions, but in
practice most hardware is at least Armv8.1-A (2014), which includes
single-instruction atomics as part of the LSE feature. As a performance
optimization for these cases, GCC and LLVM have the `-moutline-atomics` flag
to turn atomic operations into calls to symbols like `__aarch64_cas1_acq`.
These can do runtime feature detection and use the LSE instructions if
available, falling back to more portable load-exclusive/store-exclusive
loops.

Since the recent 3b50253b57 ("compiler-builtins: plumb LSE support
for aarch64 on linux") our builtins support this LSE optimization, and
since 6936bb975a ("Dynamically enable LSE for aarch64 rust provided
intrinsics"), std will set the flag as part of its startup code. The first
commit in this PR configures this to work on all platforms built with
`outline-atomics`, not just Linux.

Thus, enable `outline-atomics` by default on Android, OpenBSD, Windows,
and Fuchsia platforms that don't have LSE in the baseline. The feature is
already enabled on Linux. Platform-specific details are included in each
commit message.

The current implementation can still be accessed by setting
`-Ctarget-feature=-outline-atomics`. Setting `-Ctarget-feature=+lse` or
a relevant CPU will use the single-instruction atomics without the call
overhead. https://rust.godbolt.org/z/dsdrzszoe

Link: https://learn.arm.com/learning-paths/servers-and-cloud-computing/lse/intro/
Original Clang outline-atomics benchmarks: https://reviews.llvm.org/D91157#2435844

try-job: aarch64-msvc-*
try-job: arm-android
try-job: dist-android
try-job: dist-aarch64-llvm-mingw
try-job: dist-aarch64-msvc
try-job: dist-various-*
try-job: test-various
2025-12-09 17:36:47 +01:00
Jana Dönszelmann f8bbf2ca06 split out blob decode trait 2025-12-08 00:24:28 +01:00
Paul Murphy a1f4caf467 Restrict spe_acc to PowerPC SPE targets
Update the tests, add powerpc-*-gnuspe testing, and create a distinct
clobber_abi list for PowerPC SPE targets.

Note, the SPE target does not have vector, vector-scalar, or
floating-point specific registers.
2025-12-05 08:37:22 -06:00
bors 29e035e172 Auto merge of #149632 - matthiaskrgr:rollup-c5iqgtn, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#149521 (Improve `io::Error::downcast`)
 - rust-lang/rust#149544 (Only apply `no_mangle_const_items`'s suggestion to plain const items)
 - rust-lang/rust#149545 (fix the check for which expressions read never type)
 - rust-lang/rust#149570 (rename cortex-ar references to unified aarch32)
 - rust-lang/rust#149574 (Batched compiletest Config fixups)
 - rust-lang/rust#149579 (Motor OS: fix compile error)
 - rust-lang/rust#149595 (Tidying up `tests/ui/issues` tests [2/N])
 - rust-lang/rust#149597 (Revert "implement and test `Iterator::{exactly_one, collect_array}`")
 - rust-lang/rust#149608 (Allow PowerPC spe_acc as clobber-only register)
 - rust-lang/rust#149610 (Implement benchmarks for uN::{gather,scatter}_bits)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-12-04 14:38:19 +00:00
Trevor Gross 66c150c1fa Enable outline-atomics by default on AArch64 OpenBSD
Clang has recently started doing this, as of LLVM commit 5d774ec8d183
("[Driver] Enable outline atomics for OpenBSD/aarch64") [1]. Thus, do
the same here.

[1]: https://github.com/llvm/llvm-project/commit/5d774ec8d183cbbb243c57f50d891822211d3ec2
2025-12-04 03:36:22 -05:00
Trevor Gross 21525f862d Enable outline-atomics by default on AArch64 Fuchsia
Clang has done this by default since LLVM commit 1a963d3278c2 ("[Driver]
Make -moutline-atomics default for aarch64-fuchsia targets"), [1], so do
the same here.

[1]: https://github.com/llvm/llvm-project/commit/1a963d3278c2daab7e12125371442cd129c09954
2025-12-04 03:36:22 -05:00
Trevor Gross c455903978 Enable outline-atomics by default on AArch64 Android
Per LLVM commit c5e7e649d537 ("[AArch64][Clang][Linux] Enable
out-of-line atomics by default.") [1], Clang enables these on Android.
Thus, do the same in Rust.

[1]: https://github.com/llvm/llvm-project/commit/c5e7e649d537067de
2025-12-04 03:36:22 -05:00
Trevor Gross 1ed1b6e267 Enable outline-atomics by default on AArch64 Windows platforms
Windows has a similar flag `/forceInterlockedFunctions`, which uses
names such as `_InterlockedAdd64_rel`.
2025-12-04 03:36:22 -05:00
Matthias Krüger 62a42e8a31 Rollup merge of #149557 - folkertdev:c-variadic-not-supported, r=workingjubilee
c-variadic: bpf and spirv do not support c-variadic definitions

tracking issue: https://github.com/rust-lang/rust/issues/44930

Emit a nice error message on bpf and spirv targets when a c-variadic function is defined. Spirv also does not support c-variadic calls, bpf appears to allow them.

r? ```@workingjubilee```
2025-12-04 08:46:24 +01:00
Paul Murphy b54b288518 Allow PowerPC spe_acc as clobber-only register
This register is only supported on the *powerpc*spe targets. It is
only recognized by LLVM. gcc does not accept this as a clobber, nor
does it support these targets.

This is a volatile register, thus it is included with clobber_abi.
2025-12-03 12:37:22 -06:00
Folkert de Vries fc017dd176 c-variadic: bpf and spirv do not support c-variadic definitions 2025-12-03 11:33:00 +01:00
Bart Massey 48002fc0b2 added default_uwtables=true to aarch64_unknown_none targets 2025-12-02 09:58:45 -08:00
Stuart Cook c539f3ffe1 Rollup merge of #149241 - thejpster:fix-armv4t-armv5te-bare-metal, r=davidtwco
Fix armv4t- and armv5te- bare metal targets

These two targets currently force on the LLVM feature `+atomics-32`. LLVM doesn't appear to actually be able to emit 32-bit load/store atomics for these targets despite this feature, and emits calls to a shim function called `__sync_lock_test_and_set_4`, which nothing in the Rust standard library supplies.

See [#t-compiler/arm > __sync_lock_test_and_set_4 on Armv5TE](https://rust-lang.zulipchat.com/#narrow/channel/242906-t-compiler.2Farm/topic/__sync_lock_test_and_set_4.20on.20Armv5TE/with/553724827) for more details.

Experimenting with clang and gcc (as logged in that zulip thread) shows that C code cannot do atomic load/stores on that architecture either (at least, not without a library call inserted).

So, the safest thing to do is probably turn off `+atomics-32` for these two Tier 3 targets.

I asked `@Lokathor` and he said he didn't even use atomics on the `armv4t-none-eabi`/`thumbv4t-none-eabi` target he maintains.

I was unable to reach `@QuinnPainter` for comment for `armv5te-none-eabi`/`thumbv5te-none-eabi`.

The second commit renames the base target spec `spec::base::thumb` to `spec::base::arm_none` and changes `armv4t-none-eabi`/`thumbv4t-none-eabi` and `armv5te-none-eabi`/`thumbv5te-none-eabi` to use it. This harmonises the frame-pointer and linker options across the bare-metal Arm EABI and EABIHF targets.

You could make an argument for harmonising `armv7a-none-*`, `armv7r-none*` and `armv8r-none-*` as well, but that can be another PR.
2025-12-02 13:56:30 +11:00
Stuart Cook 3d404d0e9e Rollup merge of #149312 - mati865:push-uxlynzmxzswo, r=wesleywiser
Mark riscv64gc-unknown-linux-musl as tier 2 target

According to https://github.com/rust-lang/rust/blob/cdb4236e654a49c3035269588fe22dfafc0cfa3a/src/doc/rustc/src/platform-support/riscv64gc-unknown-linux-musl.md?plain=1#L3 it's tier 2 target.

In case you are wondering how I noticed it:
Dockerfiles at Wild linker repo started to fail building recently due to missing `riscv64gc-unknown-linux-musl` std. I had hoped the problem would go away by itself, but it did not (it never does...).
https://github.com/rust-lang/rust/pull/148983 happened recently, so I checked https://rust-lang.github.io/rustup-components-history/riscv64gc-unknown-linux-musl.html and yeah, the date matches.
Given this condition: https://github.com/rust-lang/rust/blob/cdb4236e654a49c3035269588fe22dfafc0cfa3a/src/tools/build-manifest/build.rs#L35 I'm certain PR will fix the problem.
2025-11-26 23:32:09 +11:00
Stuart Cook 3b531a18b5 Rollup merge of #149173 - bjorn3:target_spec_rust_features, r=RalfJung
Use rust rather than LLVM target features in the target spec

This works better with non-LLVM codegen backends.
2025-11-26 23:32:08 +11:00
Stuart Cook d1b9331a76 Rollup merge of #148452 - Fulgen301:pdb-large-symbols-v0, r=jackh726
Mangle symbols with a mangled name close to PDB limits with v0 instead of legacy mangling to avoid linker errors

This is rust-lang/compiler-team#934

As PDB debuginfo has a 64KiB limit for symbol names, we use v0 mangling instead of legacy mangling for symbol names >= 65000 bytes if PDB is used. The cutoff number was chosen to leave some room for potential errors in the empirical measurement of the limit of 65521 bytes, as well as potential symbol prefixes and suffixes that are applied later, plus some generous extra space.

Tracking issue: rust-lang/rust#148429
2025-11-26 23:32:05 +11:00
bjorn3 fedbccd320 Use rust rather than LLVM target features in the target spec
This works better with non-LLVM codegen backends.
2025-11-25 14:39:42 +00:00
Mateusz Mikuła fd1852f5f3 Mark riscv64gc-unknown-linux-musl as tier 2 target 2025-11-25 12:32:06 +01:00
chenx97 d60e7cf94b callconv: adapt mips padding logic to mips64
MIPS64 needs to put a padding argument before an aggregate argument when
this argument is in an odd-number position, starting from 0, and has an
alignment of 16 bytes or higher, e.g.
`void foo(int a, max_align_t b);` is the same as
`void foo(int a, long _padding, max_align_t b);`

This fix uses an i32 padding, but it should work just fine because i32 is
aligned like i64 for arguments.
2025-11-24 11:12:20 +08:00
Jonathan 'theJPster' Pallant 99a393444c Set max-atomic-width for armv4 and armv5 to zero, to disable atomics 2025-11-23 18:29:59 +00:00
Jonathan 'theJPster' Pallant dbcb048e28 Unify the arm*-none-* and thumb*-none-* target descriptions. 2025-11-23 16:22:09 +00:00
Jonathan 'theJPster' Pallant 38987c0b9a Remove +atomics-32 for armv4t-none-eabi and armv5te-none-eabi
Also rationalise the settings, and copy in the thumb base defaults,
rather than just import them, because these aren't M-profile
microcontrollers and may not want to always have the same settings.
2025-11-23 15:36:03 +00:00
bors 4b1b6dde0c Auto merge of #147536 - mati865:gnullvm-self-contained, r=petrochenkov
Add `rust-mingw` component for `*-windows-gnullvm` hosts

Cc https://github.com/rust-lang/rust/issues/146634
2025-11-22 16:34:09 +00:00
Mateusz Mikuła 3ad82500ba Add rust-mingw component for *-windows-gnullvm
hosts
2025-11-21 15:59:44 +01:00
Matthias Krüger 6b1bdacffe Rollup merge of #149139 - 12101111:ohos-host-tools, r=nnethercote
Enable host tools for aarch64-unknown-linux-ohos

![7dd6b50e474ee5fd14fd0bffda522874](https://github.com/user-attachments/assets/9b718630-a8a8-426c-ab54-5d767d605091)
2025-11-20 20:11:47 +01:00
12101111 1e14a5dc73 Enable host tools for aarch64-unknown-linux-ohos 2025-11-20 19:22:01 +08:00
Matthias Krüger 7198d31e4b Rollup merge of #149041 - folkertdev:sparc64-mips64-ignore-unsized, r=bjorn3
ignore unsized types in mips64 and sparc64 callconvs

Non-rustic calling conventions should not make up an ABI for unsized types (cc https://github.com/rust-lang/rust/pull/148302). The vast majority of our callconv implementations already ignore unsized types, `sparc64` and `mips64` I guess were missed.

r? `````@bjorn3`````
2025-11-20 11:15:53 +01:00
Matthias Krüger 422b83aeee Rollup merge of #147173 - androm3da:bcain/hexagon_qurt, r=davidtwco,tgross35
Add support for hexagon-unknown-qurt target

MCP: https://github.com/rust-lang/compiler-team/issues/919
Fixes https://github.com/rust-lang/rust/issues/148982.
2025-11-20 11:15:51 +01:00
Folkert de Vries bbf7dc0ddf ignore unsized types in mips64 and sparc64 callconvs 2025-11-17 22:47:59 +01:00
Stuart Cook 6ce31bffaf Rollup merge of #148999 - moturus:remote-test-server, r=jieyouxu
Tweak Motor OS linker preset, fix `remote-test-server` for Motor OS

Had to tweak linking options in target spec to make it work (see https://github.com/moturus/motor-os/issues/46).
2025-11-17 16:41:05 +11:00
Brian Cain ecfc64207a Add support for hexagon-unknown-qurt target 2025-11-16 18:30:37 -06:00
U. Lasiotus 02770b339b remote-test-server: make it build for Motor OS
Had to tweak linking options in target spec to make it work
(see https://github.com/moturus/motor-os/issues/46).
2025-11-16 09:49:16 -08:00
Mark Rousskov 18483225fa Move build-manifest target lists to rustc target metadata
This ensures that as long as the target metadata is updated to reflect
the current state (tier 3 vs 1/2, host toolchain support), the manifest
will also be updated. This avoids an extremely common 'oops' when we
move targets between tiers.

This mostly removes a bunch of tier 3 targets from manifests. I didn't
spot check against produced artifacts but given that they are tier 3
it's probably reasonable to leave it as-is and bug reporters can fix the
target metadata in rustc (or we can stop producing artifacts).

Follow-up work would ideally lint the artifact list as part of
nightly/beta/stable builds as well, but for now this is simple and
hopefully removes at common source of extra PRs when modifying targets.
2025-11-16 11:13:49 -05:00
Stuart Cook 672c6b603c Rollup merge of #148819 - bjorn3:fix_fixme, r=jieyouxu
Remove specialized warning for removed target

It has been removed 9 months ago, which is more than a few months.
2025-11-12 12:26:41 +11:00
Tamir Duberstein 19e26afff8 rustc_target: rehome target_abi comment 2025-11-11 19:00:42 -05:00
Tamir Duberstein fcf6809b05 rustc_target: introduce Os
Improve type safety by using an enum rather than strings.
2025-11-11 18:55:40 -05:00
Tamir Duberstein ddd7596400 rustc_target: introduce Env
Improve type safety by using an enum rather than strings.
2025-11-11 18:34:47 -05:00
Tamir Duberstein 86c74a4d16 rustc_target: introduce Abi
Improve type safety by using an enum rather than strings.
2025-11-11 18:22:38 -05:00
Tamir Duberstein a1122a1088 rustc_target: rename Arch::{Uknown,Other}
Prepare for additional enums like Vendor and Os which have true
`Unknown` variants. We want to use the same name for the escape hatch
for all of these, thus rename this one.
2025-11-11 16:47:24 -05:00
Tamir Duberstein c6f924c182 rustc_target: move comment to macro
Avoid duplicating this comment in preparation for adding more enums.
2025-11-11 16:47:24 -05:00
bors 2636cb4c13 Auto merge of #148818 - Zalathar:rollup-4vujcg0, r=Zalathar
Rollup of 13 pull requests

Successful merges:

 - rust-lang/rust#148694 (std: support `RwLock` and thread parking on TEEOS)
 - rust-lang/rust#148712 (Port `cfg_select!` to the new attribute parsing system)
 - rust-lang/rust#148760 (rustc_target: hide TargetOptions::vendor)
 - rust-lang/rust#148771 (IAT: Reinstate early bailout)
 - rust-lang/rust#148775 (Fix a typo in the documentation for the strict_shr function)
 - rust-lang/rust#148779 (Implement DynSend and DynSync for std::panic::Location.)
 - rust-lang/rust#148781 ([rustdoc] Remove unneeded `allow(rustc::potential_query_instability)`)
 - rust-lang/rust#148783 (add test for assoc type norm wf check)
 - rust-lang/rust#148785 (Replace `master` branch references with `main`)
 - rust-lang/rust#148791 (fix "is_closure_like" doc comment)
 - rust-lang/rust#148792 (Prefer to use file.stable_id over file.name from source map)
 - rust-lang/rust#148805 (rustc-dev-guide subtree update)
 - rust-lang/rust#148807 (Document (and test) a problem with `Clone`/`Copy` deriving.)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-11-11 13:30:50 +00:00
bjorn3 fcce61c811 Remove specialized warning for removed target
It has been removed 9 months ago, which is more than a few months.
2025-11-11 11:34:28 +00:00