RT-Thread / RT-Thread/rt-thread

[rust] detect_rust_target 未处理 Cortex-M33 硬浮点,导致链接失败

Open
#11,810 3 comments 0 reactions 1 assignee View on GitHub

@KingingWang is already working on this.

Since Sep 18, 2026.

in progress
Dominant language
C
Stars
12.2k
Forks
5.4k
Avg merge
4d 12h
Merged PRs (30d)
40

Description

问题

components/rust/tools/build_support.pydetect_rust_target() 中,Cortex-M33 分支固定返回软浮点 target,没有使用同函数已算好的 hard_float

if has("ARCH_ARM_CORTEX_M4") or has("ARCH_ARM_CORTEX_M7"):
    return "thumbv7em-none-eabihf" if hard_float else "thumbv7em-none-eabi"   # 有判断
if has("ARCH_ARM_CORTEX_M33"):
    return "thumbv8m.main-none-eabi"                                          # 无判断

硬浮点的 M33 板卡因此拿到软浮点 ABI 的 Rust 库,链接期直接失败。

复现

BSP:bsp/stm32/stm32u575-st-nucleo(CFLAGS 为 -mfpu=fpv5-sp-d16 -mfloat-abi=hard

.config 增加:

CONFIG_RT_USING_RUST=y
CONFIG_RT_RUST_CORE=y
CONFIG_RUST_INIT_COMPONENT=y

基线(不开 Rust)编译通过,ROM 101740 B。开启 Rust 后:

Detected Rust target: thumbv8m.main-none-eabi
Rust component built successfully
Rust library linked successfully
...
ld: error: rt-thread.elf uses VFP register arguments, build/rust/target/thumbv8m.main-none-eabi/release/librt_rust.a(...) does not
ld: failed to merge target specific data of file ...
collect2: error: ld returned 1 exit status
scons: *** [rt-thread.elf] Error 1
影响范围

仓库里走 M33 分支的 BSP 共 29 个,其中 27 个是硬浮点,都会命中,例如 stm32h503/h563/l552/u575/u585、renesas ra4e2/ra6e2/ra6w1、nxp lpc55sxx、mcxa/mcxn、imxrt1180/cm33、gd32527I-eval、mm32f526x、swm341-mini。

thumbv8m.main-none-eabihf 在 rustup 中已存在,features 为 +fp-armv8d16sp,与 -mfpu=fpv5-sp-d16 一致。

另外两个同类缺口
  1. Cortex-M85 不在 ARM 分支列表中,会落到 ARCH='arm' 的字符串兜底,得到 armv7a-none-eabi(A-profile),且构建过程不报错,例如 bsp/stm32/stm32n657-st-nucleo。Cortex-R4/R52 同样没有分支,落到同一个兜底。
  2. Cortex-A 分支也未使用 hard_float,固定返回 armv7a-none-eabi。目前仓库内 9 个 Cortex-A BSP 都是软浮点,暂未触发。

环境:rustup nightly(rustc 1.97.0-nightly)、arm-none-eabi-gcc 14.2.1。

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.