NRF52 LTO flags (#10655)
* Add LTO support for nrf52840 while preserving interrupt handlers * nrf52840: enable whole-image LTO on all targets via nrf52_base Moves -flto + the nrf52_lto.py exclusion middleware from the rak4631 env (771018ca8) up to [nrf52_base], so every nrf52840 target inherits it. nrf52_lto.py keeps the interrupt handlers out of LTO (framework core + TinyUSB USBD_IRQHandler) -- they're referenced only from the asm vector table, so whole-program LTO would otherwise drop them and the chip hangs. HW-validated: RAK4631 (SX1262, -60KB) and muzi-base (LR1121) both boot and init their radios. Build-verified on canaryone (fresh board, base-inherited). Caveat: the RAK "1-Watt" variant's radio does not tolerate global-LTO (SX126x init fails); it shares the rak4631 binary, so keep that hardware on src-only or split it into a separate target. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * nrf52840: move -fmerge-all-constants to nrf52_base (all targets) It had been trialed on rak4631 only; it's a general image-wide flag (the same one stm32 uses globally, ~0.7KB), so move it up to [nrf52_base] next to -flto so every nrf52840 target gets it instead of just rak4631. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * nrf52_lto.py: normalize path separators for Windows (Copilot review) get_abspath() returns backslash-separated paths on Windows, so the "/FrameworkArduino/" / "/cores/nRF5/" substring matches would miss and the ISR-owning objects would still be LTO'd -> hang on first IRQ. Replace backslashes with forward slashes before matching. No-op on macOS/Linux. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Fix directory handling for LTO * Add post-link guard to check for dropped ISR handlers in nrf52 LTO --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: Jason P <applewiz@mac.com>
This commit is contained in:
co-authored by
GitHub
Claude Opus 4.8
Jason P
parent
a9b98f47e9
commit
bf68b9e597
@@ -14,6 +14,7 @@ platform_packages =
|
||||
extra_scripts =
|
||||
${env.extra_scripts}
|
||||
extra_scripts/nrf52_extra.py
|
||||
pre:extra_scripts/nrf52_lto.py
|
||||
|
||||
build_type = release
|
||||
build_flags =
|
||||
@@ -26,6 +27,8 @@ build_flags =
|
||||
-DMESHTASTIC_EXCLUDE_PAXCOUNTER=1
|
||||
-Os
|
||||
-std=gnu++17
|
||||
-flto ; whole-image LTO (~-60KB) on every nrf52840 target; nrf52_lto.py (pre: extra_script) keeps the interrupt handlers out of LTO so they survive
|
||||
-fmerge-all-constants ; fold identical constants image-wide (~0.7KB; same flag stm32 uses)
|
||||
build_unflags =
|
||||
-Ofast
|
||||
-Og
|
||||
|
||||
Reference in New Issue
Block a user