Repository navigation
fix(nrf52): keep LTO links in range with per-symbol partitions - #2098
Merged
Merged
Conversation
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
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The Adafruit nRF52 core's FreeRTOS port uses
ldr rN, =symbolin 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:Every nRF52 board that enables LTO therefore has to fall back to
-fno-lto(FastLED/FastLED carries that workaround inci/boards.pyfor five boards).Fix
Append
-flto-partition=maxwhen 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: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-ltoworkaround on the five nRF52 boards.