Skip to content

perf(esp32): suppress Arduino-ESP32 boot banner via build-flag shim (#2886 Stage 2) - #2894

Merged
zackees merged 1 commit into
masterfrom
feat/2893-stage2-suppress-chip-debug-banner
Jun 7, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/2893-stage2-suppress-chip-debug-banner

Conversation

@zackees

@zackees zackees commented Jun 7, 2026 •

Copy link
Copy Markdown
Member

perf(esp32): suppress Arduino-ESP32 boot banner via build-flag shim (#2886 Stage 2)

Closes #2893.

Adds a build-flag-gated strong override of the Arduino-ESP32 core's
shouldPrintChipDebugReport() weak symbol. Setting

build_flags = -DFASTLED_SUPPRESS_ARDUINO_CHIP_DEBUG_REPORT=1

in platformio.ini (or the equivalent in Arduino IDE
compiler.cpp.extra_flags) makes the optimizer fold both
if (shouldPrintChipDebugReport()) branches at vendor main.cpp:55
and main.cpp:63 to dead code. --gc-sections then drops
printBeforeSetupInfo() (~1,464 B at top-25 row #21 of #2886) plus
its ~1-2 KB of formatted-stream rodata carrier strings — projected
~3 KB of flash savings on the ESP32-S3 NEOPIXEL Blink baseline.

Why a build flag, not an include?

The earlier design (an opt-in include #include <extras/suppress_arduino_chip_debug_report.cpp.hpp> in the user
sketch) collided with the unity-build linter: every .cpp.hpp under
src/ is required to participate in a _build.cpp.hpp aggregator,
which in turn is compiled by a +.cpp wrapper in src/fl/build/. The
shim file is therefore unavoidably part of the library compilation
unit.

Gating the body on FASTLED_SUPPRESS_ARDUINO_CHIP_DEBUG_REPORT and
FL_IS_ESP32 keeps the default behavior unchanged for every user
who doesn't explicitly opt in. Opt-in via build flag is the same
ergonomic shape as FASTLED_RMT_STATIC_ALLOCATION (#2846) and
FASTLED_LOG_VERBOSITY (#2791) — recognizable to existing users
following the bloat-reduction docs.

Files

  • src/extras/suppress_arduino_chip_debug_report.cpp.hpp — the shim.
    Empty body unless FL_IS_ESP32 && FASTLED_SUPPRESS_ARDUINO_CHIP_DEBUG_REPORT.
  • src/extras/_build.cpp.hpp — unity-build aggregator for extras/,
    documented as the home for build-flag-gated shims.
  • src/fl/build/extras+.cpp — independently-compiled wrapper TU that
    pulls extras/_build.cpp.hpp into the library build (matches the
    existing platforms+.cpp / third_party+.cpp pattern).
  • ci/lint_cpp/test_unity_build.py — register fl/build/extras+.cpp
    in EXPECTED_BUILD_FILES so the unity-build linter accepts the
    new wrapper.

Verification

User-facing behavior

Build flag ESP32 target Effect
unset / =0 yes no change (vendor weak default fires)
=1 yes strong override → printBeforeSetupInfo() dead-stripped
any no shim expands to nothing

Refs #2886, #2893.

Summary by CodeRabbit

  • New Features

    • Added opt-in flag to suppress Arduino-ESP32 chip debug messages. Enable FASTLED_SUPPRESS_ARDUINO_CHIP_DEBUG_REPORT to hide startup messages on ESP32 targets.
  • Chores

    • Refactored build infrastructure with a new extras module supporting build-flag-gated features that safely reduce to no-ops when disabled.

…2886 Stage 2)

Closes #2893.

Adds a build-flag-gated strong override of the Arduino-ESP32 core's
`shouldPrintChipDebugReport()` weak symbol. Setting

    build_flags = -DFASTLED_SUPPRESS_ARDUINO_CHIP_DEBUG_REPORT=1

in `platformio.ini` (or the equivalent in Arduino IDE
`compiler.cpp.extra_flags`) makes the optimizer fold both
`if (shouldPrintChipDebugReport())` branches at vendor `main.cpp:55`
and `main.cpp:63` to dead code. `--gc-sections` then drops
`printBeforeSetupInfo()` (~1,464 B at top-25 row #21 of #2886) plus
its ~1-2 KB of formatted-stream rodata carrier strings — projected
~3 KB of flash savings on the ESP32-S3 NEOPIXEL Blink baseline.

## Why a build flag, not an include?

The earlier design (an opt-in include `#include
<extras/suppress_arduino_chip_debug_report.cpp.hpp>` in the user
sketch) collided with the unity-build linter: every `.cpp.hpp` under
`src/` is required to participate in a `_build.cpp.hpp` aggregator,
which in turn is compiled by a `+.cpp` wrapper in `src/fl/build/`. The
shim file is therefore unavoidably part of the library compilation
unit.

Gating the body on `FASTLED_SUPPRESS_ARDUINO_CHIP_DEBUG_REPORT` and
`FL_IS_ESP32` keeps the default behavior unchanged for every user
who doesn't explicitly opt in. Opt-in via build flag is the same
ergonomic shape as `FASTLED_RMT_STATIC_ALLOCATION` (#2846) and
`FASTLED_LOG_VERBOSITY` (#2791) — recognizable to existing users
following the bloat-reduction docs.

## Files

- `src/extras/suppress_arduino_chip_debug_report.cpp.hpp` — the shim.
  Empty body unless `FL_IS_ESP32 && FASTLED_SUPPRESS_ARDUINO_CHIP_DEBUG_REPORT`.
- `src/extras/_build.cpp.hpp` — unity-build aggregator for `extras/`,
  documented as the home for build-flag-gated shims.
- `src/fl/build/extras+.cpp` — independently-compiled wrapper TU that
  pulls `extras/_build.cpp.hpp` into the library build (matches the
  existing `platforms+.cpp` / `third_party+.cpp` pattern).
- `ci/lint_cpp/test_unity_build.py` — register `fl/build/extras+.cpp`
  in `EXPECTED_BUILD_FILES` so the unity-build linter accepts the
  new wrapper.

## Verification

- `bash lint --cpp` → all C++ linting checks pass; the pre-existing
  PlatformIO-internal-usage warnings (issue #2701) are warn-only and
  unchanged by this PR.
- Flash savings (`bash bloat esp32s3 --build` with
  `-DFASTLED_SUPPRESS_ARDUINO_CHIP_DEBUG_REPORT=1`) measured by the
  Stage 6 verification gate; this PR only ships the mechanism.

## User-facing behavior

| Build flag | ESP32 target | Effect |
|---|---|---|
| unset / `=0` | yes | no change (vendor weak default fires) |
| `=1` | yes | strong override → `printBeforeSetupInfo()` dead-stripped |
| any | no  | shim expands to nothing |

Refs #2886, #2893.
@coderabbitai

coderabbitai Bot commented Jun 7, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: dcaa0fa1-207b-4d22-98b2-cf94031e6f90

📥 Commits

Reviewing files that changed from the base of the PR and between 4628fdb and 8960247.

📒 Files selected for processing (4)
  • ci/lint_cpp/test_unity_build.py
  • src/extras/_build.cpp.hpp
  • src/extras/suppress_arduino_chip_debug_report.cpp.hpp
  • src/fl/build/extras+.cpp

📝 Walkthrough

Walkthrough

This PR implements Stage 2 of the bloat-reduction plan by adding an opt-in shim that suppresses the Arduino-ESP32 boot-banner code path. The shim provides a strong override of the vendor's weak shouldPrintChipDebugReport() symbol to return false, allowing the linker to dead-strip ~3 KB of rodata strings and banner-formatting code. The implementation is guarded by FASTLED_SUPPRESS_ARDUINO_CHIP_DEBUG_REPORT macro and integrated into the build system via new unity-build aggregator files and lint test validation.

Changes

Boot-banner suppression shim and build integration

Layer / File(s) Summary
Shim implementation and documentation
src/extras/suppress_arduino_chip_debug_report.cpp.hpp
Introduces documentation explaining the opt-in macro flag and weak-symbol override mechanism. Adds conditional compilation that defines extern "C" bool shouldPrintChipDebugReport(void) returning false when both FL_IS_ESP32 and FASTLED_SUPPRESS_ARDUINO_CHIP_DEBUG_REPORT are enabled, allowing the linker to dead-strip the boot-banner code path.
Build system integration and aggregation
src/extras/_build.cpp.hpp, src/fl/build/extras+.cpp
Adds _build.cpp.hpp as an aggregator header documenting opt-in shim behavior and including the suppression shim. Introduces extras+.cpp as a new unity-build translation unit that includes the aggregator header along with platform and system headers to compile opt-in extra shims.
Lint test validation
ci/lint_cpp/test_unity_build.py
Registers the new fl/build/extras+.cpp unity-build file in EXPECTED_BUILD_FILES so the naming lint check validates its presence in the build directory.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

  • #2893 — Stage 2: Suppress Arduino-ESP32 boot banner via shim — directly implemented by these changes, which add the opt-in shim and unity-build integration to suppress the boot-banner code path and save ~3 KB on ESP32-S3 builds.
  • #2886 — Multi-stage bloat-reduction plan parent issue; this PR fulfills the Stage 2 deliverable for boot-banner suppression via the shouldPrintChipDebugReport() weak-symbol override.

Poem

🐰 A shim so sleek, a banner gone,
Three kilobytes of flash set free,
On ESP32 they carry on,
Without the boot-print symphony! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and specifically describes the main change: suppressing Arduino-ESP32 boot banner via a build-flag shim.
Linked Issues check ✅ Passed The PR fully implements the Stage 2 deliverable from issue #2893: provides the opt-in shim file, unity-build aggregator, build registration, and conditional strong override of shouldPrintChipDebugReport().
Out of Scope Changes check ✅ Passed All changes directly support the stated objective of delivering a build-flag-gated shim mechanism; no unrelated modifications to examples, auto-includes, or documentation files are present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/2893-stage2-suppress-chip-debug-banner

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Infer (1.2.0)
src/fl/build/extras+.cpp

src/fl/build/extras+.cpp:10:10: fatal error: 'platforms/new.h' file not found
10 | #include "platforms/new.h"
| ^~~~~~~~~~~~~~~~~
1 error generated.
Error: the following clang command did not run successfully:
/opt/infer-linux-x86_64-v1.2.0/lib/infer/facebook-clang-plugins/clang/install/bin/clang-18
@/tmp/coderabbit-infer/89602472009ff9b229e230fbadd7852bef51be19-ab839260ad1bc82a/tmp/clang_command_.tmp.1cac53.txt
++Contents of '/tmp/coderabbit-infer/89602472009ff9b229e230fbadd7852bef51be19-ab839260ad1bc82a/tmp/clang_command_.tmp.1cac53.txt':
"-cc1" "-load"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../../facebook-clang-plugins/libtooling/build/FacebookClangPlugin.dylib"
"-add-plugin" "BiniouASTExporter" "-plugin-arg-BiniouASTExporter" "-"
"-plugin-arg-BiniouASTExporter" "PREPEND_CURRENT_DIR=1"
"-plugin-arg-BiniouASTExporter" "MAX_STRING_SIZE=65535" "-cc1" "-triple"
"x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "-disable

... [truncated 1067 characters] ...

ng/install/lib/clang/18/include"
"-internal-isystem" "/usr/local/include" "-internal-isystem"
"/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include"
"-internal-externc-isystem" "/usr/include/x86_64-linux-gnu"
"-internal-externc-isystem" "/include" "-internal-externc-isystem"
"/usr/include" "-Wno-ignored-optimization-argument" "-Wno-everything"
"-fdeprecated-macro" "-ferror-limit" "19" "-fgnuc-version=4.2.1"
"-fskip-odr-check-in-gmf" "-fcxx-exceptions" "-fexceptions"
"-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o"
"/tmp/coderabbit-infer/ab839260ad1bc82a/file.o" "-x" "c++"
"src/fl/build/extras+.cpp" "-O0" "-fno-builtin" "-include"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../lib/clang_wrappers/global_defines.h"
"-Wno-everything"


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

Comment @coderabbitai help to get the list of available commands and usage tips.

@zackees
zackees merged commit 80c6d98 into master Jun 7, 2026
7 of 8 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 7, 2026
zackees added a commit that referenced this pull request Jun 7, 2026
…rlay (#2886 Stage 3) (#2896)

Closes #2895.

Adds a documented, opt-in ESP-IDF sdkconfig overlay that users plug into
`board_build.sdkconfig_defaults`. Drops ~10-15 KB of release-build flash
on a typical ESP32 LED installation by disabling IDF components that a
deployed strip never uses:

| Knob | Eliminates | Savings |
|---|---|---:|
| `CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH=n` | libespcoredump (top-25 rows #18 + #25, ~3 KB symbols + ~5 KB tail) | ~8 KB |
| `CONFIG_LOG_DEFAULT_LEVEL=ESP_LOG_NONE`  | libesp_diagnostics + IDF log strings (top-25 row #19) | ~3 KB |
| `CONFIG_BOOTLOADER_LOG_LEVEL_NONE=y`     | bootloader-stage UART chatter | ~1 KB |
| `CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT=y`   | panic-time backtrace formatter | ~1-2 KB |

`CONFIG_BT_ENABLED=n` is shipped commented-out (~15 KB extra when the
project currently has BT on) — users uncomment when they know their
sketch doesn't touch BLE/BT.

## Files

- `tools/sdkconfig_for_smallest_fastled.defaults` — the overlay
  itself, with inline per-knob comments grounding each line in the
  #2886 top-25 attribution.
- `agents/docs/binary-size-analysis.md` — adds a "Release-build flash
  savers (in order of impact)" table that lists this overlay
  alongside the FASTLED_LOG_VERBOSITY default (#2890), the boot-banner
  shim (#2894), and FASTLED_RMT_STATIC_ALLOCATION (#2846). Single
  reference point for what knobs exist and how to enable them.

## Why a user-side overlay, not a library-side default

`sdkconfig` is consumed by the ESP-IDF build before any FastLED TU is
compiled. FastLED cannot mutate IDF defaults from a library; the
deliverable here is therefore a *shippable overlay file* the user
points `board_build.sdkconfig_defaults` at, plus documentation that
tells them which lines map to which savings.

## User integration

```
[env:esp32s3]
board_build.sdkconfig_defaults =
    sdkconfig.defaults
    ${platformio.packages_dir}/framework-arduinoespressif32/tools/sdkconfig.defaults.esp32s3
    ${PROJECT_LIBDEPS_DIR}/${PIOENV}/FastLED/tools/sdkconfig_for_smallest_fastled.defaults
```

(See the file's header for the full snippet; `PROJECT_LIBDEPS_DIR`
resolution varies by PIO project layout.)

## Verification

- `bash lint --cpp` → C++ linting passes (this PR is docs-only;
  pre-existing PlatformIO-internal-usage warnings unchanged).
- Per-project flash deltas are user-side measurements; the projection
  table in `binary-size-analysis.md` cites the #2886 top-25 baseline
  attribution for each line.

Refs #2886, #2895.
zackees added a commit that referenced this pull request Jun 7, 2026
…tage 0) (#2898)

Closes #2897.

Adds a user-facing reference page that consolidates every release-build
flash-saver FastLED currently ships into a single discoverable
location. End users no longer have to grep across PRs and meta-issues
to find the knobs.

Sections:

1. **TL;DR** — a drop-in `platformio.ini` snippet that stacks Stages
   1+2+3 and `FASTLED_RMT_STATIC_ALLOCATION` in one place.
2. **Baseline & how to measure** — pre-#2886 NEOPIXEL Blink baseline
   (388,380 B), Stage 6 target (≤ 280,000 B), `bash bloat esp32s3`
   pointer.
3. **Release-build flash savers (in priority order)** — five-row
   table with how-to-enable, savings, status (✅ measured vs.
   📊 projected), and PR cross-link for each knob.
4. **Per-stage detail** — one section per shipped stage with the
   mechanism, file path, and integration snippet:
   - Stage 1 (`FASTLED_LOG_VERBOSITY=0`, now NDEBUG default) — #2890
   - Stage 2 (`FASTLED_SUPPRESS_ARDUINO_CHIP_DEBUG_REPORT=1` build
     flag → strong override of vendor weak `shouldPrintChipDebugReport()`)
     — #2894
   - Stage 3 (`tools/sdkconfig_for_smallest_fastled.defaults` overlay
     applied via `board_build.sdkconfig_defaults`) — #2896
   - `FASTLED_RMT_STATIC_ALLOCATION=1` — #2846 (pre-existing)
5. **Situational notes** — Stage stacking, sdkconfig integration
   gotchas, `PROJECT_LIBDEPS_DIR` fallback.
6. **Measuring your build** — `bash bloat esp32s3` quickstart + diff
   pointer.
7. **Roadmap** — Stages 4 (cold-helper audit), 5 (basic_string::write
   simplification), 6 (CI regression gate). The ✅/📊 status flags on
   the priority table flip to ✅ when Stage 6 records measured deltas.

Also adds a cross-reference from
`agents/docs/binary-size-analysis.md` (the agent-facing reference
shipped in #2896) to the new user-facing doc, with a maintenance note
that future knobs must update both surfaces.

## Honesty about projections

Every savings figure in this PR is marked 📊 (projected from the
#2886 top-25 attribution). The ✅ status gets unlocked when Stage 6
of #2886 wires the regression-gate run that records measured baselines.
The Roadmap section calls this out explicitly so readers know which
numbers carry empirical weight.

## Verification

- `bash lint --cpp` → all C++ linting checks pass; this PR adds no
  C++ code.
- Doc references (`tools/sdkconfig_for_smallest_fastled.defaults`,
  `src/extras/suppress_arduino_chip_debug_report.cpp.hpp`,
  `src/fl/log/log.h:66-92`) verified against the post-#2896 tree.

Refs #2886, #2897.
zackees added a commit that referenced this pull request Jun 7, 2026
…DISABLE_SPI_CHIPSETS (#2914)

Closes #2913.

Adds an opt-in build flag `FASTLED_DISABLE_SPI_CHIPSETS=1` that gates
the SPI dispatch branch in `fl::Channel::showPixels`. For NEOPIXEL-only
sketches the SPI branch is dynamically unreachable, but the compiler
cannot prove that — every `pixelIterator.writeXXX(...)` reference
inside the 11-case switch is statically reachable, keeping ~720 B of
encoder bodies and the switch-table footprint linked.

## Measured baseline (post-#2911, `master @ 6bd4ebd`)

Dead-code SPI encoder symbols currently linked into a NEOPIXEL Blink:

| Symbol | Size |
|---|---:|
| `fl::PixelIterator::writeLPD8806<fl::vector_psram<u8>>` | 235 B |
| `fl::PixelIterator::writeSK9822<fl::vector_psram<u8>>` | 197 B |
| `fl::PixelIterator::writeAPA102<fl::vector_psram<u8>>` | 197 B |
| `fl::PixelIterator::writeSM16716<fl::vector_psram<u8>>` | 91 B |
| **Total** | **720 B** |

Plus the `showPixels` body itself shrinks by the switch-table footprint
(~300-500 B for an 11-case xtensa switch). Projected total saving:
**~1.0-1.2 KB** on a NEOPIXEL Blink build with the flag enabled.

## Behavior

- **Flag unset (default):** No change. The SPI dispatch is present;
  every existing example using APA102 / SK9822 / etc. continues to
  work.
- **Flag set (`-DFASTLED_DISABLE_SPI_CHIPSETS=1`):** The SPI branch is
  removed at preprocess time. `showPixels()` on a channel whose
  chipset is an `SpiChipsetConfig` falls through to the post-dispatch
  event emission with no data encoded — the channel silently emits
  nothing. Users opt in with the understanding that they're not
  using SPI chipsets in this build.

This mirrors the opt-in build-flag pattern shipped in #2894
(Stage 2 / boot-banner shim) — minimal default-change risk, real
savings for users who can accept the constraint.

## Files

- `src/fl/channels/channel.cpp.hpp` — `#if !defined(FASTLED_DISABLE_SPI_CHIPSETS) || !FASTLED_DISABLE_SPI_CHIPSETS`
  wraps the `else if (mChipset.is<SpiChipsetConfig>())` block. The
  gate's behavior + savings are documented inline at the comment block
  above the branch.
- `docs/SLIM_ESP32S3.md` — adds row 6 to the "Release-build flash
  savers" priority table with the new flag, its constraint, and PR
  link.

## Verification

- `bash lint --cpp` → all C++ linting checks pass.
- The flag follows the established opt-in pattern; default behavior
  unchanged.
- Measured saving will be validated on the post-merge build (a
  `-DFASTLED_DISABLE_SPI_CHIPSETS=1` build of Blink, compared against
  the current `347,004 B` baseline).

## Expected savings

- Eliminated: writeAPA102 (197 B), writeSK9822 (197 B), writeLPD8806
  (235 B), writeSM16716 (91 B) = 720 B (PixelIterator SPI encoders
  reachable only from showPixels' SPI branch).
- Eliminated: ~300-500 B of switch-table + dispatch code in
  `showPixels` body.
- Net: ~1.0-1.2 KB projected on NEOPIXEL Blink with flag set.

The Stage 6 regression gate (`tests/test_esp32s3_bloat_regression.py`,
baseline = `347004`) does NOT change in this PR because it measures
the default-flag build, which is unchanged. A separate follow-up
records the flag-on measured number once a measurement run lands.

Refs #2886, #2913, #2908, #2911.
@zackees
zackees deleted the feat/2893-stage2-suppress-chip-debug-banner branch August 21, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Stage 2: Suppress Arduino-ESP32 boot banner via shim — ~3 KB (#2886)

1 participant