Repository navigation
Description
Goal
Ship a single-include shim in FastLED that suppresses the Arduino-ESP32 boot-banner code path so the linker dead-strips printBeforeSetupInfo() and its ~1-2 KB of rodata strings.
Projected savings: ~3 KB on the ESP32-S3 NEOPIXEL Blink baseline (top-25 row #21 from #2886: 1,464 B for printBeforeSetupInfo() + ~1-2 KB of carrier strings).
Parent: #2886 — Stage 2 of the multi-stage bloat-reduction plan.
Why the symbol is currently kept alive
The vendor call sites in framework-arduinoespressif32/cores/esp32/main.cpp (verified against the locally installed PIO copy of the Arduino-ESP32 core, lines 43-63):
// main.cpp:43
__attribute__((weak)) bool shouldPrintChipDebugReport(void) {
// default impl returns true under some conditions
...
}
// main.cpp:52-58
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG
printBeforeSetupInfo();
#else
if (shouldPrintChipDebugReport()) {
printBeforeSetupInfo();
}
#endif
// main.cpp:60-65
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG
// ...
#else
if (shouldPrintChipDebugReport()) {
// ...
}
#endifEven when the user has ARDUHAL_LOG_LEVEL=0 (i.e. the release default), the else branch still references printBeforeSetupInfo() and shouldPrintChipDebugReport(), so the linker keeps both alive. The "default" weak impl of shouldPrintChipDebugReport() returns truthy under common conditions, so the path is also live at runtime.
The leverage point is that shouldPrintChipDebugReport() is weak. A strong override defined in user TU is preferred by the linker over the framework's weak default, and replacing the body with return false; lets the optimizer fold the two if (shouldPrintChipDebugReport()) branches at the else site to dead code, after which --gc-sections drops printBeforeSetupInfo() and its ~292 lines of formatted-stream code.
Deliverable
Ship a single FastLED-owned shim:
- File:
src/extras/suppress_arduino_chip_debug_report.cpp.hpp - Content:
// Strong override of the Arduino-ESP32 weak default in cores/esp32/main.cpp:43. // Returning false unconditionally lets `--gc-sections` drop // printBeforeSetupInfo() and its ~1-2 KB of rodata strings, saving // ~3 KB on release builds. See FastLED #2886 Stage 2. #if defined(ESP32) extern "C" bool shouldPrintChipDebugReport(void) { return false; } #endif
User integration is one line in their sketch:
#include <FastLED/extras/suppress_arduino_chip_debug_report.cpp.hpp>The include lives outside src/FastLED.h's default surface — opt-in only, because globally overriding a vendor weak symbol on every FastLED user's behalf would be surprising scope creep. The file name encodes the action.
Why not auto-include from FastLED.h?
- Some users intentionally rely on the boot-info banner (debugging brownouts / wakeup sources, validating PSRAM detection).
- Strong-overriding a vendor weak symbol changes user-observable behavior — that belongs in an explicit opt-in, not the default.
- The shim is a 4-line
.cpp.hpp— the integration cost is zero for users who want it.
Documentation
- Add a short entry to the future
docs/SLIM_ESP32S3.mdreference page (Stage 0 of Meta: ESP32-S3 Blink bloat reduction (file:line concrete plan) — supersedes #2885 #2886) once that page exists, listing this shim + the measured savings. - Note the shim in
agents/docs/binary-size-analysis.mdunder "release-build flash savers".
Acceptance
A release build of examples/Blink/Blink.ino with #include <FastLED/extras/suppress_arduino_chip_debug_report.cpp.hpp> immediately after the FastLED include shows:
printBeforeSetupInfoabsent frombash bloat esp32s3output.shouldPrintChipDebugReportresolved to the FastLED shim (not the vendor weak default) — verify viaxtensa-esp32s3-elf-nmon the linked ELF.- Total flash decreases by ≥ 2.5 KB (target ~3 KB) versus the same sketch without the shim include.
Measurement command:
bash bloat esp32s3 --build
jq '.total_flash' .build/symbols/esp32s3/report.json
# Should be ≥ 2,500 B lower than the pre-Stage-2 baseline (388,380 B
# - 55,000 B from Stage 1 = ~333,380 B target; this stage brings it
# down another ~3 KB to ~330,380 B).Out of scope
- Changes to existing examples (none of the in-tree
.inosketches add the shim). - The Stage 0
docs/SLIM_ESP32S3.mdreference page — separately tracked. - Auto-include from
FastLED.h— explicitly opt-in per "Why not auto-include?" above.
Related
- Meta: ESP32-S3 Blink bloat reduction (file:line concrete plan) — supersedes #2885 #2886 — parent meta tracking the multi-stage bloat reduction (Stage 2 of 6).
- perf(log): default FASTLED_LOG_VERBOSITY=0 in release builds (#2886 Stage 1) #2890 — Stage 1 (FASTLED_LOG_VERBOSITY default flip), merged at
0674ccdd8e. agents/docs/binary-size-analysis.md— thebash bloatwrapper this issue's acceptance gate uses.
🤖 Generated with Claude Code
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
perf(esp32): suppress Arduino-ESP32 boot banner via build-flag shim (F…