Repository navigation
Description
Summary
Follow-up to #2420 / #2421 / #2424 / #2428. After the recent fixes landed (channels-as-default-opt-in driver registry, audio/net/video/fx/gfx eh_frame cleanup, FL_NO_UNWIND via #2423), the ESP32-S3 NEOPIXEL Blink binary is 657,072 B — that's the structural floor of the new Channel API. The 3.10.3 baseline on the same minimal sketch was ~344 KB, so we still carry a +313 KB delta. This issue tracks where that residual lives so we can decide what (if anything) to chip away at next.
Measured on
| Item | Value |
|---|---|
| Branch | feat/remove-legacy-driver-registry-macro |
| Commit | 4127a0c8da |
| Sketch | examples/Blink/Blink.ino (single NEOPIXEL controller, pin 3) |
| Board | esp32-s3-devkitc-1 (Espressif ESP32-S3-DevKitC-1-N8, 8 MB flash, no PSRAM) |
| Toolchain | xtensa-esp-elf-gcc 14.2.0 |
| Build path | PlatformIO 6.1.19 → pio run -e esp32s3 (fbuild hangs on cold ESP32 builds — see fbuild#117) |
firmware.bin |
657,072 B |
firmware.elf |
38,516,728 B (with DWARF) |
firmware.map |
28,136,474 B |
Section sizes (xtensa-esp32s3-elf-size -A)
| Section | Bytes | vs reporter's #2420 (master#ea5d8ec, 783 KB bin) |
|---|---|---|
.flash.text |
260,444 | −85,456 (was 345,900) |
.flash.rodata |
317,064 | −42,144 (was 359,208) |
.iram0.text |
64,527 | −15,012 (was 79,539) |
.dram0.data |
13,584 | −2,532 |
.dram0.bss |
11,368 | — |
Symbol categories (xtensa-esp32s3-elf-nm --print-size -C)
| Category | Bytes | KB | Symbols |
|---|---|---|---|
| OTHER (Arduino core, ESP-IDF init, debug, crypto, partition) | 130,315 | 127.3 | 1,834 |
FastLED (fl::*, CFastLED, CLEDController, PixelController) |
71,453 | 69.8 | 801 |
| ESP-IDF/HAL (rmt, gdma, tlsf, mmu, nvs, rtc, panic, coredump) | 57,563 | 56.2 | 428 |
| libc/runtime (printf family, dtoa, ieee754_pow, get_arg) | 57,354 | 56.0 | 600 |
| UART/Serial (Arduino HardwareSerial — for console, not FastLED) | 25,034 | 24.4 | 186 |
| FreeRTOS | 12,229 | 11.9 | 58 |
| App (setup/loop/main) | 2,122 | 2.1 | 43 |
Subsystems that #2421/#2424 fixed (verified GC'd now)
fl::audio 0 bytes (was 34 KB orphan eh_frame)
fl::video 0 bytes
fl::net 0 bytes
fl::http 0 bytes
fl::remote 0 bytes
fl::fx 0 bytes
fl::gfx 0 bytes
fl::Font 0 bytes
AudioManager 0 bytes
BleDevice 0 bytes
formatJsonResponse 0 bytes
ChunkedReader 0 bytes
fl::asio 32 bytes (one residual stub symbol)
Driver families that #2428 fixed (verified — only RMT survives)
ChannelEngineRMT*Impl 14,301 B <- needed (NEOPIXEL -> RMT)
Rmt5* (encoder/peripheral) 5,691 B <- needed
ClocklessIdf5 991 B <- needed
BusTraits 16 B
ChannelEngineSpi (vtable) 88 B (typeinfo only - no code)
ChannelEngineUART 0 B
ChannelEngineI2S 0 B
ChannelDriverLcdSpi 0 B
ChannelDriverLcdClockless 0 B
ChannelDriverParlio 0 B
ESP-IDF drag-ins that #2428 fixed (was ~46 KB):
rmt_new_tx_channel 2,072 B <- needed
uart_driver_install 711 B <- Arduino HardwareSerial (Serial.begin), not FastLED
rmt_rx 0 B
spi_master 0 B
esp_lcd_panel_io_i80 0 B
esp_lcd_panel_io_spi 0 B
i2s_ 0 B
Where the FastLED 70 KB actually lives
| Subsystem | Bytes | KB | Symbols |
|---|---|---|---|
| RMT (encoder, peripheral impl, memory mgr, buffer pool) | 28,154 | 27.5 | 114 |
| Channels (Channel::showPixels, ChipsetTiming, ChannelData) | 13,663 | 13.3 | 170 |
Other fl:: (lifecycle, Singleton, misc) |
7,240 | 7.1 | 192 |
| PixelIterator / PixelController | 4,248 | 4.1 | 72 |
| ChannelManager | 3,905 | 3.8 | 31 |
fl::basic_string |
2,827 | 2.8 | 24 |
fl::vector_basic |
2,568 | 2.5 | 37 |
Gamma LUT (ProgmemLUT16<GammaEval16<...>, 256>::kData = 512 B table + accessors) |
2,159 | 2.1 | 32 |
fl::task::Scheduler |
1,928 | 1.9 | 30 |
| ChannelEvents / EngineEvents | 1,316 | 1.3 | 34 |
| ClocklessIdf5 wrapper | 1,107 | 1.1 | 16 |
| shared_ptr / weak_ptr / RefCount | 506 | 0.5 | 12 |
| variant | 106 | 0.1 | 5 |
Top 12 single largest FastLED symbols (where reduction would have biggest impact)
| Bytes | Symbol |
|---|---|
| 5,013 | fl::Channel::showPixels(PixelController<GRB, 1, 0xFFFFFFFF>&) |
| 4,590 | fl::ChannelEngineRMTImpl::createChannel(...) |
| 2,708 | fl::RmtMemoryManager::allocateTx(uint8_t, bool, bool) |
| 2,160 | fl::ChannelEngineRMTImpl::reconfigureForNetwork() |
| 1,528 | fl::detail::Rmt5EncoderImpl::initialize(ChipsetTiming, unsigned long) |
| 1,151 | fl::basic_string::write(const char*, unsigned) |
| 948 | fl::ChannelEngineRMTImpl::processPendingChannels() |
| 826 | fl::RmtMemoryManager::calculateMemoryBlocks(bool) |
| 738 | fl::ChannelEngineRMTImpl::configureChannel(...) |
| 676 | fl::ChannelManager::selectDriverForChannel(shared_ptr<ChannelData>, string) |
| 606 | fl::detail::Rmt5PeripheralESPImpl::waitAllDone(void*, unsigned long) |
| 564 | fl::ChannelEngineRMTImpl::destroyChannel(...) |
Top 5 NON-FastLED single largest symbols
| Bytes | Symbol | Source |
|---|---|---|
| 11,309 | _vfprintf_r |
newlib |
| 11,118 | _svfprintf_r |
newlib |
| 7,337 | _svfiprintf_r |
newlib |
| 7,265 | _vfiprintf_r |
newlib |
| 4,096 | port_IntStack |
FreeRTOS |
→ ~36 KB of printf-family is being dragged in. Likely culprit: FL_LOG / FL_WARN / FL_ERROR macros emit format strings that ODR-use the full _vfprintf_r family. Worth checking whether we can route logging through a smaller printf-substitute on embedded targets, or gate verbose log macros behind a release-build define.
Reduction hypotheses (in rough priority order)
-
Channel::showPixelsis 5 KB for a single GRB instantiation. The map shows just one PixelController template instantiation in the final binary — that's fine for cold-start size, but the function itself is large. Worth checking if it's pulling in the gamma scaling, dither, and brightness paths even when the user hasn't calledsetBrightness/setGamma. A tiered fast-path (no-brightness, no-gamma, no-dither) could probably cut this in half for the default case. -
ChannelEngineRMTImpl::createChannelis 4.6 KB andreconfigureForNetworkis 2.2 KB. These look like they handle the full driver lifecycle for hot-plug add/remove of channels. A NEOPIXEL-only sketch withaddLeds<>at static init never reconfigures the network — could we split a "one-shot setup" path from the dynamic reconfigure path and only link the dynamic one when the user actually callsremoveLeds()/ dynamic add? -
RmtMemoryManageris 4.5 KB acrossallocateTx/calculateMemoryBlocks/freeDMA. The dynamic memory-block planner is rich. For a single fixed-strip sketch, a compile-time-fixed memory block count would eliminate the planner. -
printf family ~36 KB. Likely from
FL_LOG/FL_WARN. Two options:- Gate all
FL_LOG_*behindFASTLED_LOG_LEVEL(default off in release) - Replace
printf-style formatting in those macros with a minimal hand-rolled formatter that doesn't pull in_vfprintf_r
- Gate all
-
fl::basic_stringandfl::vector_basictogether = 5.4 KB. Could be reduced if we audit where strings are constructed at runtime in non-error paths.ChannelManager::selectDriverForChanneltakes afl::stringby const-ref — checking whether the caller actually needs a string here or if astring_view/ enum would suffice. -
fl::task::Scheduler::warn_no_thenis 476 B for an error-path warning. Cheap fix: move the format string andprintfcall out-of-line into a single__attribute__((cold,noinline))helper.
Reproduction
# Branch: feat/remove-legacy-driver-registry-macro @ 4127a0c8da
bash compile esp32s3 --examples Blink
# OR (fbuild #117 workaround):
cd .build/pio/esp32s3 && .venv/Scripts/pio run -e esp32s3
ELF=.pio/build/esp32s3/firmware.elf
xtensa-esp32s3-elf-size -A "$ELF"
xtensa-esp32s3-elf-nm --print-size --size-sort --reverse-sort -C "$ELF" | head -40Related
- [Bug] Compounded timing inaccuracy on master compared to 3.10.3 #2420 — Original report (timing + bloat)
- [Tracking] ESP32-S3 timing regression + binary bloat from Channel API (from #2420) #2421 — Architecture investigation tracking
- feat(fl/stl): add FL_NO_UNWIND macros, apply to ESP32 unity headers #2423 —
FL_NO_UNWIND(strip eh_frame) — merged - [Tracking] Break unwanted cross-TU references that drag optional subsystems into all builds (follow-up to #2421) #2424 — Cross-TU reference cleanup — merged
- refactor(fl/gfx): lazy-init rgb_2_rgbw user function via Singleton<T> #2426 —
Rgb2Rgbwlazy init — merged - feat(channels): compile-time Bus binding via templated ChannelConfig (eliminates Channel API binary bloat) #2428 — Compile-time driver binding via
fl::Bus— merged - (current branch
feat/remove-legacy-driver-registry-macro, 4127a0c) — removed theFASTLED_DISABLE_LEGACY_DRIVER_REGISTRYmacro and made the opt-in driver registry the default
Out of scope (but worth mentioning)
fbuild v2.2.3 reliably hangs on cold ESP32-S3 builds at the post-framework-libs handoff (fbuild#117 — closed as "instrumentation added" without an actual fix). This forced the symbol analysis above to run through pio run directly. Not strictly a FastLED issue, but worth a heads-up since it complicates measurement workflows for anyone trying to reproduce these numbers.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
zackees commentedon May 12, 2026
.eh_frameI did a full per-archive map-based audit and the picture is materially worse than the original symbol-level breakdown above suggested. Symbol-level
nm --print-sizeonly counts symbols with explicit size annotations, which misses.eh_frameentirely (it has no per-symbol attribution) and misses the merged-string pool (.rodata.str1.1).Where the 657 KB actually lives (map-based, per output section)
.eh_frameorphan unwind metadata.rodata.str1.1— FL_LOG / FL_WARN format strings + RTTI demangled names).flash.textfrom libFastLED.a)_vfprintf_rfamily).eh_frameper archive in the binary.eh_frameper FastLED unity TUWhy FL_NOEXCEPT and FL_NO_UNWIND aren't preventing this
Three cascading failures:
(1)
FL_NOEXCEPTis currently a no-opsrc/fl/stl/noexcept.h:7-9:Header comment: "noexcept was causing too many platform compatibility issues (AVR, WASM, etc.) so it is disabled everywhere until a robust cross-platform solution is found."
Even if FL_NOEXCEPT expanded to real
noexcept, that's a C++ language contract and does not suppress-fasynchronous-unwind-tablescodegen.noexceptand.eh_frameare independent.(2)
FL_NO_UNWIND_BEGINdisables the wrong flagsrc/fl/stl/compiler_control.h:330:This disables
-funwind-tables(default OFF) but does NOT disable-fasynchronous-unwind-tables(default ON on ESP32 because the panic handler needs backtraces).Both flags produce
.eh_frame. Disabling only the off-by-default one accomplishes nothing on ESP32. That is whyplatforms+.cpp.o— the one TU that IS wrapped withFL_NO_UNWIND_BEGIN— still ships 34,960 B of eh_frame in the binary.The pragma needed to actually strip it would be:
…and even that is unreliable because GCC's
optimizeattribute is officially documented as intended for-O*levels; for non-optimization codegen flags the behavior is "may or may not propagate" depending on GCC version. The robust mechanism is to pass-fno-asynchronous-unwind-tables -fno-unwind-tableson the compile command line for every TU, not via pragma.(3)
FL_NO_UNWIND_BEGINis wrapped around only 2 of 15+ FastLED unity TUsFiles that currently have FL_NO_UNWIND_BEGIN/_END:
All these other unity build headers have no wrapping at all:
(4)
--gc-sectionsdoesn't reap orphan.eh_frameentriesKnown GNU LD limitation: when
--gc-sectionsstrips a.text.foochunk for a function the linker proves unreachable, the corresponding FDE in.eh_frameis not automatically removed because LD treats.eh_frameas one merged section rather than per-function chunks. This is why audio/net/gfx/fx/video TUs — whose code is provably dead-stripped (nmshows zerofl::audio::*symbols) — still ship their eh_frame metadata.ESP-IDF intentionally does not add
/DISCARD/ : { *(.eh_frame) }to its linker script because the panic handler needs eh_frame for backtraces.What would actually fix it
The only mechanisms that reliably strip
.eh_frameon GCC 14.2.0 for ESP32:-fno-asynchronous-unwind-tables -fno-unwind-tablesas compile flags for every libFastLED.a TU. This needs PIOlib_compile_flagsor build-system per-library injection — not a header-level pragma. Estimated savings: ~169 KB (the full libFastLED.a eh_frame).CONFIG_ESP_SYSTEM_PANIC_PRINT_BACKTRACEis on, leave eh_frame in so the panic handler can backtrace through FastLED frames). The existing FL_NO_UNWIND_ACTIVE logic already has the gating right; the macro just doesn't emit the right flag.FASTLED_STRIP_EH_FRAME=1that injects those compile flags via the library build system.Bonus: the merged-strings pool (~55 KB) is mostly FastLED FL_LOG/FL_WARN
The first input to
.flash.rodatais 55,190 bytes attributed to a single template-ctor's.str1.1(the merged-strings input section) — that's the linker placing the deduplicated string-literal pool there. It contains FL_LOG / FL_WARN / format strings, RTTI demangled names (vtable for fl::ClocklessIdf5<3, TIMING_WS2812_800KHZ, ...>),__FILE__/__func__literals, andfl::busName(fl::Bus)enum-name table strings.Recovery target if we gate the verbose log strings behind a release-mode
FASTLED_LOG_LEVELdefine: an estimated 30–40 KB. RTTI demangled name strings can be killed with-fno-rttifor the FastLED library, but that breakstypeid()usage anywhere — needs auditing first.Revised reduction priorities
-fno-asynchronous-unwind-tablesto FastLED lib compile flags + apply to all_build.cpp.hppwrappers,no-asynchronous-unwind-tables(best-effort pragma)loadAndScaleRGBWAfter #1 alone the binary would drop from 657 KB -> ~488 KB. Combined with #3 we are at ~450 KB, within 100 KB of the 3.10.3 baseline. The remaining ~100 KB is the genuine structural cost of the Channel API + RMT engine (which is what the original "structural delta" framing should have referred to).
zackees commentedon May 12, 2026
Quick clarification on the commit reference: the analysis was run on local commit
4127a0c8daof branchfeat/remove-legacy-driver-registry-macro, which is byte-for-byte identical toorigin/masterat8616873b73(merged as #2469 — same change, different SHA due to GitHub squash).git diff HEAD origin/master= 0. The numbers reported here represent current master state.zackees commentedon May 12, 2026
Object-file-level evidence:
FL_NO_UNWIND_BEGINis a no-op on GCC 14.2.0 / XtensaTo answer "is the pragma actually doing anything?" directly: I dumped the
.eh_framecount from the wrapped TU's.ofile before linking. The numbers leave no ambiguity.Setup
src/platforms/esp/32/_build.cpp.hppwraps every driver include withFL_NO_UNWIND_BEGIN/FL_NO_UNWIND_END:drivers/_build.cpp.hppwraps the driver subdir includes a second time at lines 21+43 — belt-and-suspenders.Result: 3,007 FDEs survive in the wrapped .o
GCC emitted 3,007 frame description entries — one per function in the unity TU — despite the
FL_NO_UNWIND_BEGINwrap covering every single function. The wrap is doing literally nothing.Side-by-side: wrapped vs unwrapped TUs
FL_NO_UNWIND_BEGIN?.eh_framein.o.eh_frameinfirmware.binplatforms+.cpp.ofl.audio+.cpp.ofl.gfx+.cpp.ofl.channels+.cpp.oWrapped and unwrapped TUs behave identically. Both ship full unwind tables. The
_Pragma("GCC optimize(\"no-unwind-tables\")")form is a no-op for.eh_frameon this toolchain.Why the macro fails — root cause
src/fl/stl/compiler_control.h:330:Two compounding problems:
1. Wrong flag. GCC has two separate
.eh_frameemitters:-funwind-tables-fno-exceptions, so it'd be off anyway)-fasynchronous-unwind-tablesThe actual emitter on ESP32 is
-fasynchronous-unwind-tables, not-funwind-tables. Our pragma flips the wrong switch.2. The
optimizeattribute doesn't reliably propagate codegen flags. Per the GCC documentation for__attribute__((optimize(...))):-fno-asynchronous-unwind-tablesis a codegen flag, not an-O*-style optimization flag. Even if we changed the pragma string to"no-asynchronous-unwind-tables", GCC may or may not honor it depending on the version. The 3,007 FDEs in the wrapped object file confirm GCC 14.2.0 / xtensa-esp-elf is silently no-op'ing the current pragma.The fix that actually works
Pass the flags on the compile command line, not via pragma:
For PlatformIO consumers this needs library-level injection. Two options:
library.json— add abuild.flagsarray forFastLEDso every.cppinlib*/FastLED/gets these flags on the cc1 command line. Targeted, won't affect user sketches.platformio.initemplate — surface aFASTLED_STRIP_EH_FRAME=1shortcut that expands to the two compile flags viabuild_unflags+build_flags. User-controllable, opt-in.For our internal builds (
bash compile ...) we'd add these to whatever defines flags for ESP32 release builds. Estimated savings: ~169 KB libFastLED.a eh_frame + ~56 KB libstdc++.a eh_frame if we can also propagate to the toolchain's libstdc++ link.Gating: leave eh_frame in for debug builds
The existing
FL_NO_UNWIND_ACTIVEresolution logic incompiler_control.h:285-313already covers the right gating semantics:FASTLED_FORCE_UNWIND_TABLES=1→ keep (e.g. when developing and need backtraces)!defined(NDEBUG),CONFIG_ESP_SYSTEM_PANIC_PRINT_BACKTRACE, etc.) → keepJust swap the macro body from emitting a broken pragma to feeding the right value into a build-system include of the correct flags. The policy is correct; the mechanism is wrong.
zackees commentedon May 12, 2026
Cross-link: filed on fbuild as FastLED/fbuild#243
The right fix for the 225 KB of orphan
.eh_frameis centralized in the build system, not in FastLED headers. Filed FastLED/fbuild#243 — "ESP32: auto-strip .eh_frame when exception handling and panic backtrace are both off" — to track the proper implementation: parsesdkconfigpanic mode + project build flags, inject-fno-asynchronous-unwind-tables -fno-unwind-tableson the compile command line when nothing in the build asks for unwind info.The FL_NO_UNWIND macros can stay as documentation of intent and as the user-visible
FASTLED_FORCE_NO_UNWIND_TABLES/FASTLED_FORCE_UNWIND_TABLESpolicy knob, but the actual byte-stripping work moves to fbuild.zackees commentedon May 12, 2026
Update on the cross-link: refined the proposal in FastLED/fbuild#243 with a per-architecture policy split.
Xtensa (ESP32 / S2 / S3): the ESP-IDF panic backtrace walks register windows, not
.eh_frame. Safe to strip unconditionally when-fno-exceptionsis in effect. Dominant FastLED-on-ESP32 case lands here.RISC-V (C3 / C6 / H2 / C5 / P4): ESP-IDF panic backtrace defaults to frame-pointer walking. Strip by default; preserve only if user opts into DWARF unwinding via
CONFIG_ESP_SYSTEM_USE_EH_FRAME=y(which is opt-in, not default).Result: stock ESP32-S3 Blink drops from 657 KB → ~432 KB out of the box with no diagnostic regression. Comment: FastLED/fbuild#243 (comment)
zackees commentedon May 12, 2026
Spawned follow-up #2474 to purge the FL_NO_UNWIND macros and FASTLED_FORCE_*_UNWIND_TABLES overrides from
src/fl/stl/compiler_control.hand their two call sites insrc/platforms/esp/32/_build.cpp.hpp+src/platforms/esp/32/drivers/_build.cpp.hpp. Zero source-level risk (the macros were no-ops). Migration path for any user who had-DFASTLED_FORCE_NO_UNWIND_TABLES=1is thebuild_flagsform documented in #2473 andsrc/fl/channels/README.md's new "Reducing Binary Size" section.zackees commentedon May 12, 2026
Also filed against the starter project: FastLED/PlatformIO-Starter#6 — add the two
-fno-*unwind-tablesflags to every ESP32 (and Cortex-M / RISC-V).iniinplatforms/. Until fbuild#243 lands, this is the place where new FastLED users meet the flag, so the size win is opt-out instead of opt-in.feat(build): #243 #244 strip .eh_frame on release builds across all G…
feat(build): #243 #244 strip .eh_frame on release builds across all G…
zackees commentedon Jun 5, 2026
Issue #2473 —
-fno-unwind-tablesis a no-op forfirmware.binon current master (xtensa-esp-elf-gcc 14.2.0)TL;DR
The
-fno-asynchronous-unwind-tables -fno-unwind-tablesflags suggested insrc/fl/channels/README.md("Reducing Binary Size") do not reducefirmware.binsize on ESP32-S3 with the current toolchain, across both thePlatformIO (pioarduino IDF 5.4) and Arduino-CLI (esp32:esp32 3.1.1, IDF 5.3)
toolchains.
.eh_frameis already absent from both default builds — only.debug_frame(DWARF, non-loadable, lives in the ELF, not in the flash image) survives, and
xtensa is not currently emitting any unwind data into a
PT_LOADsegment.Stripping it via codegen flags rewrites the codegen (different bytes in
.flash.text) but produces afirmware.binof identical size.fbuildcannot be measured — it still hangs on cold ESP32-S3 builds(fbuild#117), even with warm PlatformIO caches sitting next to it.
Setup
examples/Blink/Blink.ino(single NEOPIXEL controller, pin 3)esp32-s3-devkitc-1(PIO/fbuild),esp32:esp32:esp32s3,PartitionScheme=huge_app,FlashSize=4M,USBMode=default,CDCOnBoot=default,FlashMode=qio(Arduino-CLI)master511730eb1cxtensa-esp-elf-gcc 14.2.0via pioarduino 54.03.20 (IDF 5.4)xtensa-esp-elf-gcc 14.2.0(IDF 5.3)Baseline = master
ci/boards.pyas-shipped. "No-unwind" = sameESP32_S3_DEVKITC_1with added
build_flags = ["-fno-asynchronous-unwind-tables", "-fno-unwind-tables"].Arduino-CLI no-unwind = same flags injected via two
--build-propertyoverrides:Binary-size comparison
firmware.binfirmware.elfpio run)pio run)-fno-(asynchronous-)unwind-tables)arduino-cli compile)arduino-cli compile)fbuild ... build)firmware.elfdeltas (+464 B for PIO, +856 B for Arduino) are entirely inDWARF debug sections (different
.debug_framecontent after re-compile); theflash image is byte-count identical.
ELF section sizes (loadable only)
PIO, no-unwind run (current master + flags)
No
.eh_framesection..debug_frame= 388,040 B (DWARF — not flashed).Arduino-CLI, baseline (no flags)
No
.eh_framesection..debug_frame= 427,628 B (DWARF — not flashed).Arduino-CLI, no-unwind (extra_flags injected)
Loadable sections byte-for-byte identical to baseline on Arduino-CLI —
the only ELF delta is in DWARF.
Why isn't the README's "~180 KB savings" reproducing?
The README's "Reducing Binary Size" section (
src/fl/channels/README.md:1058)notes:
This audit could not reproduce that on
mastertoday:not emit
.eh_framefor an ESP32-S3 Arduino build of Blink — only.debug_frame, which is a DWARF debug section that is never flashed..flash.textcodegen subtly (different bytes,same byte count on PIO; byte-for-byte identical loadable sections on
Arduino-CLI), so they are applied — they just don't shrink anything.
(the FL_NO_UNWIND removal predates the 14.2.0 update) or against
firmware.elfrather thanfirmware.bin. The deltas in.debug_frame(388 KB on PIO, 428 KB on Arduino-CLI) are in the ELF but never reach flash.
Drift from the original issue snapshot
Issue #2473 measured on
feat/remove-legacy-driver-registry-macro @ 4127a0c8da:firmware.bin = 657,072 B. Currentmaster(511730e, PIO same toolchain):673,504 B. That's +16,432 B drift between the branch in the issue and
today, in regular work —
.flash.text+10,448 B,.flash.rodata+5,780 B,.iram0.text+200 B. This is normal feature accretion since the branch wascut, not unwind-related.
Recommendation
Remove or clarify the "Reducing Binary Size" guidance in
src/fl/channels/README.md. With xtensa-esp-elf-gcc 14.2.0, the flags donothing for
firmware.bin. Users who add them expecting a 180 KB reductionwill be disappointed.
The 313 KB delta vs 3.10.3 lives somewhere else. Per the issue's own
detailed breakdown, the largest reducible chunks today are:
Channel::showPixels5 KB (single GRB instantiation pullinggamma/dither/brightness)
ChannelEngineRMTImpl::createChannel4.6 KB +reconfigureForNetwork2.2 KB (full dynamic lifecycle pulled in for static
addLeds)RmtMemoryManager4.5 KB (runtime memory-block planner)printf-family ~36 KB (likelyFL_LOG/FL_WARNODR-using_vfprintf_r)These are codegen/feature changes, not codegen-flag tweaks.
fbuild#117 still bites.
fbuild ... build -e esp32s3hangs at thepost-toolchain-fetch stage and times out at 30 min even with PIO caches
already populated. Any size-measurement workflow on ESP32-S3 has to go
through
pio runorarduino-cli compiletoday.Reproduction
zackees commentedon Jun 5, 2026
Issue #2473 — Comprehensive symbol/section analysis: where the 673 KB lives
TL;DR
A fresh symbol-level audit of the current
master(511730e) ESP32-S3 Blinkbuild (PlatformIO, IDF 5.4, xtensa-esp-elf-gcc 14.2.0,
firmware.bin = 673,504 B)identifies five concrete tree-shake failures that account for ~150 KB of
bloat the user can't avoid by writing a smaller sketch:
mbedtls/x509_crt_bundle(Mozilla CA cert bundle)libwpa_supplicant.a, which referencesesp_crt_bundle_attach→ drags in the full root CA blob. Pure ESP-IDF/Arduino problem (not FastLED), but it's the biggest single contributor to the 313 KB delta vs 3.10.3._svfprintf_rchainsrc/fl/system/file_system.cpp.hppincludesplatforms/fs_sdcard_arduino.hppwhenever<SD.h>exists. That#include <SD.h>triggers PlatformIO LDF to linklibSD.a+libFS.a+Arduino::VFSImpl, which calls Csnprintf→ pulls_svfprintf_r(11 KB) for a sketch that never opens a file.libmesh.a(mesh_parent, mesh_schedule, mesh_utilities, mesh_route, mesh.o, mesh_main, mesh_network) is always linked. Pure Arduino-ESP32 problem; not FastLED.Channel::showPixels5.7 KB monolithScaledPixelIteratorBrightness,ScaledPixelIteratorRGB,ScaledPixelIteratorRGBW,Gamma8::getOrCreate,XYMap::*,Rgbwwvariant code into every NEOPIXEL Blink, even whensetBrightness/setGamma/setCorrectionare never called. No tiered fast-path.ChannelEngineRMTImpl::createChannel4.6 KBFastLED.addLeds<>pulls in the dynamic lifecycle:reconfigureForNetwork,NetworkDetector::isAnyNetworkActive, hot-plug add/remove paths, and ansstream-based warning emitter.EspIOholdsmUartANDmUsbSerialJtagas members; theif (mUseUsbSerialJtag)is a runtime check, so the linker can't dead-strip either driver. Not the biggest leak by bytes, but it's the cleanest example of a fixable polymorphism failure.These five (plus the EspIO oddity) compose about 105 KB of structural bloat
that any user of the default Channel API has to pay. The rest of the binary —
~568 KB — is broadly load-bearing (the RMT driver, FastLED's Channel API, the
Arduino HardwareSerial console, ESP-IDF init/RTOS/heap, libc).
The full breakdown follows.
1. Section-level top-down (
xtensa-esp32s3-elf-size -A).flash.text.flash.rodata.iram0.text.iram0.vectors.dram0.data.dram0.bss.rtc.*.debug_*firmware.bin = 673,504 B. Loadable total (.flash.text+.flash.rodata+.iram0.text+.iram0.vectors+.dram0.data+.rtc.*) ≈ 685 KB; bin isslightly smaller because boot stubs are not duplicated and some sections
overlap in the image layout.
2. Subsystem breakdown of
.flash.text+.iram0.text(~358 KB sized symbols, 4012 entries)fl::*(FastLED)setup/loop/printBeforeSetupInfo)Total bin grew 16 KB vs the issue's snapshot (657 KB → 673 KB), but FastLED
grew 18 KB and ESP-IDF grew 40 KB — net partially offset by some
already-shrunk areas.
2.1 FastLED 88 KB — what's inside
fl::*(Singleton, EngineEvents, Lifecycle, misc)Channel::*, ChipsetTiming, ChannelData)shared_ptr/weak_ptr/RefCountfl::basic_stringfl::vector_basic/vector_psramfl::task::SchedulerCFastLED/CLEDController/CPixelLEDControllerRgb2Rgbw/rgb_2_rgbw_colorimetricProgmemLUT16+ accessors)The 18 KB FastLED growth concentrates in PixelIterator/Controller (+5.9),
Other fl:: lifecycle/singleton glue (+8.3), and shared_ptr machinery
(+3.2).
2.2 Top 12 single largest FastLED symbols
fl::Channel::showPixels(PixelController<GRB, 1, 0xFFFFFFFF>&)fl::ChannelEngineRMTImpl::createChannel(...)fl::RmtMemoryManager::allocateTx(uint8_t, bool, bool)fl::ChannelEngineRMTImpl::reconfigureForNetwork()fl::ChannelManager::addDriver(int, fl::shared_ptr<fl::IChannelDriver>)fl::detail::Rmt5EncoderImpl::initialize(ChipsetTiming, unsigned long)fl::basic_string::write(const char*, unsigned)fl::ChannelEngineRMTImpl::processPendingChannels()fl::RmtMemoryManager::calculateMemoryBlocks(bool)fl::ChannelEngineRMTImpl::configureChannel(...)fl::ChannelManager::selectDriverForChannel(...)fl::detail::Rmt5PeripheralESPImpl::waitAllDone(void*, unsigned long)The shape matches the issue's earlier snapshot — same hotspots, all slightly
larger on master.
2.3 Top non-FastLED single symbols
_vfprintf_r_svfprintf_r_svfiprintf_r_vfiprintf_rport_IntStack_dtoa_r__ieee754_pow_vfprintf_rand_svfprintf_rare both linked because BOTHfprintfandsnprintfget used (fprintffromlibesp_driver_gpio,snprintffromplatforms+.cpp.o's OTA code — see §4.2). Newlib also pulls in theinteger-only fallbacks. ~37 KB total from the printf family alone.
3.
.flash.rodata322 KB — the elephant.flash.rodatais larger than.flash.textbut is rarely audited becausemost data is anonymous string literals / tables that don't surface as nm
symbols. Reconstructed from the map file's section assignments, the biggest
single contributors are:
libmbedtls.a(x509_crt_bundle.S.obj).rodata.embeddedlibwpa_supplicant.a(esp_eap_client.c.obj)'s reference toesp_crt_bundle_attach. Arduino-ESP32 auto-links WPA Supplicant even when the sketch never touches WiFi. This is the single biggest fixable line item.src/main.cpp.o.str1.1(merged string pool)FL_WARN/FL_LOG/format string literals that get inlined into the sketch TU from FastLED headers. Map file attributes the merged region to the first symbol that contributed (ClocklessIdf5ctor here) — actually the union of all inlined log strings.libmesh.a(mesh_parent.o)libFastLED.a(third_party+.cpp.o)fl::third_party::huffTablelibc.a(libc_a-svfwprintf.o)libc.a(libc_a-svfscanf.o)libc.a(libc_a-svfiscanf.o)libmbedtls_2.a(ssl_tls12_server.c.obj)libesp_common.a(esp_err_to_name.c.obj).str1.1libFastLED.a(platforms+.cpp.o)otaHttpGetHandler.str1.1libmesh.a(mesh_schedule.o)libmbedtls_2.a(ssl_ciphersuites.c.obj)libc.a(libc_a-strtod.o)libmesh.a(mesh_utilities.o)libc.a(libc_a-strerror.o)libmesh.a(mesh_route.o)libmbedcrypto.a(oid.c.obj)libc.a(libc_a-strftime.o)libmesh.a(mesh.o)libbtdm_app.a(ip_funcs.o)libm.a(libm_a-ef_pow.o)libFastLED.a(third_party+.cpp.o)PLM_AUDIO_SYNTHESIS_WINDOWlibmbedtls_2.a(ssl_ciphersuites.c.obj)ciphersuite_definitionslibesp_common.a(esp_err_to_name.c.obj)esp_err_msg_tablelibhttp_parser.aTop-10 rodata contributors sum: ~187 KB / 322 KB rodata = 58% of all
rodata. Of that:
third_party/audio/codec lookup tables that survive in the link4. Tree-shake failure walkthroughs
4.1 SD / FS /
_svfprintf_r(~14 KB)src/fl/system/file_system.cpp.hpp:20conditionally includesplatforms/fs_sdcard_arduino.hppbased on header presence:fs_sdcard_arduino.hpp:6,14unconditionally:PlatformIO's Library Dependency Finder sees
<SD.h>in a FastLED header,pulls
libSD.a, which pullslibFS.a(VFSImpl::open,VFSFileImpl::*).VFSFileImpl::VFSFileImplcalls Csnprintffor path normalization, whichmakes the linker extract
libc_a-snprintf.o, which references_svfprintf_r(11,118 B) and
_dtoa_r. Result: ~14 KB of file-system + printf bloat inevery ESP32 Blink build.
Fix surface: gate
make_sdcard_filesystem(and the<SD.h>include) behindan opt-in like
FASTLED_USE_SDCARD, or replace theFL_HAS_INCLUDEheuristicwith an explicit user setting. The file-system header probe is too eager — it
opts in by default any time the Arduino SD library is even present.
4.2
mbedtlsX.509 cert bundle (68 KB)Map-file trace:
ESP-IDF's WPA Supplicant calls
esp_crt_bundle_attachfromesp_eap_client.c.obj, which the linker resolves by extractingesp_crt_bundle.c.obj, which pulls in the 68 KB embedded cert bundle.Arduino-ESP32 auto-links the entire WiFi+WPA stack even for sketches that
don't call
WiFi.begin(). This is upstream of FastLED — the only mitigationinside FastLED is documentation ("ESP32-S3 Arduino baseline carries 68 KB of
CA certs you can't remove without recompiling Arduino-core with WPA
Supplicant stripped"), or pushing for an Arduino-core fix that elides
WPA/cert-bundle unless WiFi is initialized.
4.3 ESP-IDF mesh strings (~17 KB)
Same root cause as 4.2 — Arduino-ESP32 auto-links the WiFi/mesh
infrastructure. Not FastLED's fault; can only be tracked, not fixed inside
this repo.
4.4
EspIOalways instantiates both UART + USB-Serial-JTAG (~1 KB)src/platforms/esp/32/detail/io_esp_jtag_or_uart.hpp:51-93:Both
mUartandmUsbSerialJtagare non-static, non-template members of thesingle
EspIOsingleton. Every code path throughprint()/println()/read()/flush()has aif (mUseUsbSerialJtag)runtime test, so the linkersees both drivers as reachable from the same
EspIOsymbol and can'tdead-strip either one. ~422 B (UartEsp32 ctor) + ~462 B (UsbSerialJtag) +
~274 B (
reportInitDiagnosticsIfNeededitself) of always-linked overhead.Fix surface: replace the boolean branch with a
fl::variant<UartEsp32, UsbSerialJtagEsp32>or a polymorphicunique_ptr<IEspSerial>chosen once atconstruction. Then only the selected driver's text section is reachable.
4.5
Channel::showPixels5.7 KB — no tiered fast pathDisassembly of the live
fl::Channel::showPixels<GRB, 1, 0xFFFFFFFF>calls(among others):
fl::detail::ScaledPixelIteratorBrightness::advance(brightness scaling — even whensetBrightnesswas never called)fl::detail::ScaledPixelIteratorRGB::advance/::operator!=(RGB scaling iterator)fl::detail::ScaledPixelIteratorRGBW::advance/::operator!=(RGBW scaling iterator — even though Blink is plain GRB)fl::Gamma8::getOrCreate(float)(gamma table lookup)fl::XYMap::getHeight() / ::getWidth() / ::mapToIndex(2D coordinate mapping — even for a single linear strip)fl::ChannelManager::findDriverByName/selectDriverForChannelfl::PixelIteratorAny::init/~PixelIteratorAny(type-erased iterator wrapper)fl::makeScaledPixelRangeRGB(fl::PixelIterator*)(scaled range builder)__cxa_guard_acquire/release(thread-safe local static init)_Unwind_Resume(C++ exception unwind — emitted by destructor cleanup paths even with-fno-exceptions)The fast path through this function for a one-controller, no-brightness,
no-gamma, no-XYMap, no-RGBW Blink should be ~500 B (advance source iterator,
copy bytes, hand to RMT). Instead the whole 5.7 KB carries every optional
codepath.
Fix surface: split
showPixelsinto specialized templates and pick thenarrowest one at
addLeds<>instantiation. The compiler/linker can thendead-strip the unused variants per controller-type.
4.6
ChannelEngineRMTImpl::createChannel4.6 KB pulls dynamic lifecycleLive call targets from
createChannel:fl::NetworkDetector::isAnyNetworkActive(WiFi coexistence check — even for sketches that never callWiFi.begin())fl::RmtMemoryManager::{instance, allocateTx, allocateDMA, freeDMA, calculateMemoryBlocks, availableTxWords, hasActiveRxChannels, isDMAAvailable, recordRecoveryAllocation, free}— full memory planner reachable from one entry pointfl::sstream::appendFormatted(long)/appendFormatted(unsigned long)— for warning messagesfl::println(which feeds into the EspIO singleton)_Unwind_Resume— exception cleanupreconfigureForNetwork(2.2 KB) handles hot-plug add/remove of channels whenthe network state changes. A sketch that calls
addLeds<>exactly once atstatic-init time never reconfigures, so this code path is dead weight.
Fix surface: split a "static-only" channel construction path from the
dynamic-reconfigure path, and only instantiate the dynamic one when the user
actually calls
removeLeds()or hot-adds a channel.4.7 FastLED
third_party/audio data leaking into Blinkfl::third_party::huffTable(8,484 B) andfl::third_party::PLM_AUDIO_SYNTHESIS_WINDOW(2,048 B) — totalling 10.5 KBof MPEG-Audio decode tables — are linked into the Blink binary. Source is
src/fl/build/third_party+.cppaggregate. The audio decoder functionsthemselves are dead-stripped, but their
.rodata.consttables survive becausethey have external linkage and are at the namespace-scope
.rodatasection,which the linker preserves whenever any symbol from
libFastLED.a(third_party+.cpp.o)is live (it appearshuffTableand thewindow are addressed in non-tree-shakable references).
Fix surface: move the audio tables under an
#ifdef FASTLED_HAS_CODECguard,or split
third_party+.cppinto one TU per third-party codec so the linkercan drop unused TUs entirely.
5. Other observations
__gxx_personality_v0(717 B) and_Unwind_Resumecallsites arepresent despite
-fno-exceptions. GCC still emits cleanup code thatreferences the unwind ABI when destructors are involved on non-trivially-
destructible types in stack frames. With the
FL_NO_UNWINDmacros nowremoved (audit ESP32-S3 binary size: 657 KB on master vs 344 KB on 3.10.3 — remaining +313 KB delta breakdown #2473 above), the only remaining mitigation is at the global
-fno-exceptions -fno-rttilevel (already set).port_IntStack4 KB is the FreeRTOS interrupt-handler stack. Pre-allocated, can't shrink without reconfiguring
CONFIG_FREERTOS_ISR_STACKSIZE.GCC's C1/C2 (complete/base) constructor variants pointing at the same
generated body — not a real duplication.
6. Recommended priority order for fixes (FastLED-internal)
(High value, low risk) Gate the
<SD.h>include infs_sdcard_arduino.hppbehind an opt-in macro(
FASTLED_USE_SDCARD). Saves ~14 KB for the 99% of sketches thatnever touch SD.
(High value, medium risk) Split
Channel::showPixelsintospecialized templates for the (no-brightness, no-gamma, no-XYMap, RGB-only)
common case. Estimated ~3 KB savings on the default path.
(High value, medium risk) Move audio/codec lookup tables in
src/fl/third_party/under explicit codec opt-in macros, or split intoper-codec TUs. Saves ~10.5 KB.
(Medium value, medium risk) Replace
EspIO's pair-of-members with afl::variantor polymorphic selection so only one driver is linked. Saves~1 KB.
(Medium value, medium risk) Split
ChannelEngineRMTImpl::createChannelinto "static one-shot" and "dynamic reconfigure" paths. Saves
~2-3 KB for static
addLeds<>users.(Documentation) Add a note in the size-tuning docs that ~85 KB of the
ESP32-S3 baseline (
mbedtlscert bundle 68 KB +libmesh17 KB) isArduino-ESP32's auto-linked WPA/WiFi/mesh stack, not FastLED, and cannot
be removed without recompiling Arduino-core.
Implementing 1-5 saves ~30 KB off the current 673 KB → ~643 KB.
Combined with an Arduino-core fix to elide WPA+mesh when WiFi isn't used,
the realistic ESP32-S3 NEOPIXEL Blink floor could approach ~555 KB
(still 211 KB above 3.10.3, with the structural ChannelManager/RMT lifecycle
being most of the residual).
Reproduction
refactor(stdio): route libFastLED.a printf through fl::snprintf + lin…
zackees commentedon Jun 5, 2026
Closing as superseded by #2773, which is the actionable tracker for ESP32-S3 size-reduction work (with corrected numbers — this issue's breakdown was used as the source per #2773's body). All remaining size-reduction sub-items live there. The analytical content here remains valuable as historical context.
feat(log): FASTLED_LOG_VERBOSITY release knob — opt-in −43 KB on ESP3…
feat(stl): FL_NO_INLINE portable macro + cold-helper split for showPi…