Skip to content

fix(nrf52): keep LTO links in range with per-symbol partitions - #2098

Merged
zackees merged 2 commits into
mainfrom
fix/nrf52-lto-partition-max
Nov 19, 2026
Merged

zackees merged 2 commits into
mainfrom
fix/nrf52-lto-partition-max

Conversation

@zackees

@zackees zackees commented Nov 19, 2026

Copy link
Copy Markdown
Member

Problem

The Adafruit nRF52 core's FreeRTOS port uses ldr rN, =symbol in naked functions. With LTO's default partitioner the merged unit places those literal pools beyond the 4 KB PC-relative reach of the load, and the assembler fails:

Error: offset out of range
lto-wrapper: fatal error: arm-none-eabi-gcc returned 1 exit status

Every nRF52 board that enables LTO therefore has to fall back to -fno-lto (FastLED/FastLED carries that workaround in ci/boards.py for five boards).

Fix

Append -flto-partition=max when the link command already requests LTO and the caller did not choose a partition strategy. Per-symbol partitions keep each literal pool within reach, so LTO stays on.

Evidence

Manual link of nrf52840_dk (Blink, arm-gnu 15.2.1, Adafruit BSP 1.10700.0) on the current master of FastLED:

  • default partitioner: 12 x Error: offset out of range, no firmware
  • -flto-partition=max: 0 errors, firmware.elf produced (45,152 B flash text, 451 KB hex)

Unit tests added for the three cases (LTO requested, no LTO, explicit partition choice). soldr cargo test -p fbuild-build-arm nrf2 → 45 passed.

Follow-up

Once this ships in a release, FastLED can drop the -fno-lto workaround on the five nRF52 boards.

The Adafruit nRF52 core's FreeRTOS port uses `ldr rN, =symbol` in naked
functions. With LTO's default partitioner the merged unit places those
literal pools beyond the 4 KB PC-relative reach of the load and the
assembler fails with "offset out of range", so every nRF52 board that
turns LTO on has to fall back to `-fno-lto`.

Append `-flto-partition=max` when the link command already requests LTO
and the caller did not pick a partition strategy. A verified manual link
of nrf52840_dk with LTO on produced zero errors and a firmware.elf where
the default partitioner produced 12.

Refs #2016
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@zackees
zackees added this pull request to the merge queue Nov 19, 2026
Merged via the queue into main with commit 5b64990 Nov 19, 2026
33 checks passed
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

1 participant