Re: [PATCH 2/2] ARM: rust: Enable Rust support for ARMv5TE

From: Arnd Bergmann

Date: Sat Oct 03 2026 - 06:46:00 EST


On Sat, Oct 3, 2026, at 11:38, Karl Mehltretter wrote:
> HAVE_RUST is currently selected for CPU_32v7 only. The
> arm-unknown-linux-gnueabi target used for ARMv7 emits ARMv6
> instructions (+v6), so it cannot be used for ARMv5. Use rustc's
> built-in armv5te-unknown-linux-gnueabi target instead. It keeps the
> Linux EABI (no short enums, unlike the -none-eabi targets) and is
> soft-float and strict-align.
>
> Kernels that also contain ARMv4 or ARMv4T CPUs are built for the
> lowest architecture and stay excluded. CPU_32v5 also covers the ARMv5T
> ARM1020. C code is already built with -march=armv5te there, so Rust
> matches.

None of this makes sense to me: The target should not control
the instruction set, that is what the -march= flag is needed for.
Does that not get passed for Rust?

If an ARMv7 kernel includes ARMv6 instructions, that is broken
on ARMv8 CPUs that are lacking the CP15 barriers and swp style
atomics, so that needs to be fixed.

I don't see what part of rust would depend on ARMv5 instructions,
it should just work on ARMv4T as well, though ARMv4 may be
trickier because missing bx instructions etc.

> ==============================================
> -``arm`` Maintained ARMv7 Little Endian only.
> +``arm`` Maintained ARMv5TE and ARMv7, Little Endian only.

Here you exclude ARMv6K and ARMv8-A-aarch32...

> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index ffbc7f386131..f6b14d9f0e1f 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -138,7 +138,7 @@ config ARM
> select MMU_GATHER_RCU_TABLE_FREE if SMP && ARM_LPAE
> select HAVE_REGS_AND_STACK_ACCESS_API
> select HAVE_RSEQ
> - select HAVE_RUST if CPU_LITTLE_ENDIAN && CPU_32v7 && !KASAN
> + select HAVE_RUST if CPU_LITTLE_ENDIAN && (CPU_32v7 || (CPU_32v5 &&
> !CPU_32v4T && !CPU_32v4)) && !KASAN

but here you allow it, so I think one of them should change,
and you need to better explain what the dependency on !CPU_32v4T
is about, and what happens for an ARMv6K-only kernel, compared
to a combined ARMv6K+ARMv7-A one.

> KBUILD_AFLAGS +=$(CFLAGS_ABI) $(AFLAGS_ISA) -Wa,$(arch-y) $(tune-y)
> -include $(srctree)/arch/arm/include/asm/unified.h -msoft-float
> +ifdef CONFIG_CPU_32v5
> +KBUILD_RUSTFLAGS += --target=armv5te-unknown-linux-gnueabi
> +else
> KBUILD_RUSTFLAGS += --target=arm-unknown-linux-gnueabi
> +endif

This looks wrong, the choice between armv5 and armv7 should work
the same way as the choice between armv6 and armv7/v8, if I read
the rustc docs correctly, this should be using the target-cpu=
argument on the generic arm-unknown-linux-gnueabi target.

Arnd