Skip to content

libs/libbuiltin/compiler-rt: skip unsupported Arm VFP builtins asm#19513

Open
uditjainstjis wants to merge 1 commit into
apache:masterfrom
uditjainstjis:fix/17386-compiler-rt-arm-vfp
Open

libs/libbuiltin/compiler-rt: skip unsupported Arm VFP builtins asm#19513
uditjainstjis wants to merge 1 commit into
apache:masterfrom
uditjainstjis:fix/17386-compiler-rt-arm-vfp

Conversation

@uditjainstjis

Copy link
Copy Markdown

Summary

libs/libbuiltin/compiler-rt globs every arm/*.S source into the builtins
library ($(wildcard .../arm/*.S) in Make.defs, file(GLOB ...) in
CMakeLists.txt). Several of those hand-written VFP assembly files require FPU
features the selected target may not have. Upstream compiler-rt selects them
conditionally in its own CMake logic; NuttX did not, so enabling
BUILTIN_COMPILER_RT on a single-precision-FPU Arm target (e.g. Cortex-M33 with
-mfpu=fpv5-sp-d16, as on the Raspberry Pi Pico 2 / RP2350) breaks the build
with assembler errors such as:

compiler-rt/lib/builtins/arm/adddf3vfp.S:24: Error: selected FPU does not support instruction -- `vadd.f64 d6,d6,d7'
compiler-rt/lib/builtins/arm/chkstk.S:29:   Error: instruction not supported in Thumb16 mode -- `subs r5,r5,#4096'

This filters the Arm .S source list to match the configured FPU, in both the
Makefile and CMake builds:

  • chkstk.S / chkstk2.S are Windows/MinGW-only stack probes — always dropped;
  • with no hardware FPU (!CONFIG_ARCH_FPU), every arm/*vfp.S is dropped;
  • with a single-precision FPU (!CONFIG_ARCH_DPFPU), the double-precision
    *df*vfp.S routines are dropped.

The excluded set mirrors upstream compiler-rt's own conditional selection.

Fixes #17386.

Impact

  • Fixes the build for CONFIG_BUILTIN_COMPILER_RT=y on single-precision-FPU and
    soft-float Arm targets (previously failed to link/assemble).
  • No behavioural change for targets with a double-precision FPU or for
    non-Arm architectures: those targets keep the same source set (the double-
    precision *df*vfp.S files are only removed when CONFIG_ARCH_DPFPU is unset,
    and the whole block is guarded by CONFIG_ARCH_ARM).
  • Build system only; no runtime code, API, or documentation changes.

Testing

Host: Ubuntu 24.04 (x86_64), arm-none-eabi-gcc 14.2.rel1 (matching the
toolchain in the original report), compiler-rt 17.0.1 (NuttX default
LIB_COMPILER_RT_VERSION).

Reproduced the failure by assembling every arm/*.S builtin with the Cortex-M33
single-precision flags from the issue
(-march=armv8-m.main+dsp -mtune=cortex-m33 -mfpu=fpv5-sp-d16 -mfloat-abi=softfp -mthumb -mcmse):

[RESULT] total=86  FAIL=18  PASS=68
FAILING: adddf3vfp.S chkstk.S divdf3vfp.S eqdf2vfp.S extendsfdf2vfp.S
         fixdfsivfp.S fixunsdfsivfp.S floatsidfvfp.S floatunssidfvfp.S
         gedf2vfp.S gtdf2vfp.S ledf2vfp.S ltdf2vfp.S muldf3vfp.S nedf2vfp.S
         subdf3vfp.S truncdfsf2vfp.S unorddf2vfp.S

Applying this patch's exclusion set (17 double-precision *df*vfp.S files +
chkstk.S) and re-assembling the remainder:

[POST-FIX] assembled=68  remaining_failures=0

negdf2vfp.S and the single-precision *sf*vfp.S routines are correctly
retained (they assemble under a single-precision FPU). Verified the Make filter
logic independently: for a single-precision target it removes exactly the DP-VFP
and chkstk files while keeping negdf2vfp.S, addsf3vfp.S, and .c sources.

./tools/checkpatch.sh -f passes on both changed files (including
cmake-format).

@github-actions github-actions Bot added Area: OS Components OS Components issues Size: S The size of the change in this PR is small labels Jul 24, 2026
@github-actions

github-actions Bot commented Jul 24, 2026

Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

The compiler-rt builtins build globs every arm/*.S source, but several of
those hand-written assembly files require FPU features the target may not
have.  Upstream compiler-rt selects them conditionally; NuttX did not, so
BUILTIN_COMPILER_RT builds for single-precision-FPU Arm targets (e.g.
Cortex-M33, -mfpu=fpv5-sp-d16) failed to assemble with errors such as
"selected FPU does not support instruction -- vadd.f64".

Filter the source list to match the configured FPU, in both the Makefile
and CMake builds:
  - chkstk.S / chkstk2.S are Windows/MinGW-only stack probes, always dropped;
  - with no hardware FPU (!CONFIG_ARCH_FPU) all arm/*vfp.S are dropped;
  - with a single-precision FPU (!CONFIG_ARCH_DPFPU) the double-precision
    *df*vfp.S routines are dropped.

Reproduced against compiler-rt 17.0.1 with arm-none-eabi-gcc 14.2 using the
Cortex-M33 single-precision flags: 18 of 86 arm/*.S files failed to assemble
(17 double-precision *df*vfp.S plus chkstk.S); after the filter all remaining
68 files assemble cleanly.

Fixes: apache#17386
Generated-by: Claude (Anthropic)
Signed-off-by: Udit Jain <uditjainstjis@gmail.com>
@uditjainstjis
uditjainstjis force-pushed the fix/17386-compiler-rt-arm-vfp branch from 7aa491c to adc3f61 Compare July 24, 2026 02:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: OS Components OS Components issues Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] BUILTIN_COMPILER_RT option broken

2 participants