Skip to content

feat(esp): add production size-optimization flags to all 11 ESP starter configs#15

Merged
zackees merged 1 commit into
mainfrom
feat/esp-release-size-flags
Jun 20, 2026
Merged

feat(esp): add production size-optimization flags to all 11 ESP starter configs#15
zackees merged 1 commit into
mainfrom
feat/esp-release-size-flags

Conversation

@zackees

@zackees zackees commented Jun 20, 2026

Copy link
Copy Markdown
Member

Summary

ESP32-family and ESP8266 starter configs all linked at ~600 KB Blink-class binaries because the default Arduino-ESP32 build carries:

  • build_type = debug + -Og (no optimization)
  • CORE_DEBUG_LEVEL=5 + ESP_LOG_VERBOSE (every log string compiled in)
  • full libstdc++ exception machinery (no -fno-exceptions / -fno-rtti)
  • no per-function/data sections + no -Wl,--gc-sections, so the linker drops nothing it doesn't have to

This PR adds a heavily commented [build_type=release / build_flags / build_unflags] block to each ESP env.

Verified savings (from FastLED's own esp32dev CI, FastLED/FastLED#3268):

Sketch Before After Delta
Blink 631100 B 408136 B -223 KB (-35%)

The block is fully commented for new users: "comment out (or set build_type = debug) when you need verbose logs / exception decoding while developing." Each file points to FastLED/FastLED#3268 for the underlying investigation.

Files updated (all 11 ESP starters)

  • platformio.esp32c2.ini
  • platformio.esp32c3.ini
  • platformio.esp32c5.ini (preserves existing PARLIO ISR flags)
  • platformio.esp32c6.ini (preserves existing PARLIO ISR flags)
  • platformio.esp32dev.ini
  • platformio.esp32h2.ini (preserves existing PARLIO ISR flags)
  • platformio.esp32p4.ini (preserves existing PARLIO ISR flags)
  • platformio.esp32s2.ini
  • platformio.esp32s3.ini (preserves existing exception_decoder filter)
  • platformio.esp8266.ini (NONOS SDK — no CORE_DEBUG_LEVEL macro)
  • platformio.seeed_xiao_esp32s3.ini

Test plan

  • Inspected each ESP starter file in platforms/ — flags are appropriate for the SDK each targets (ESP-IDF for esp32-family, NONOS for esp8266).
  • Preserved existing PARLIO ISR / exception_decoder configurations.
  • CI / sample builds against each board to confirm sizes track the FastLED PR's numbers.

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Chores
    • Updated build configurations for all supported platforms (ESP32 variants, ESP8266, and Seeed Xiao ESP32-S3) with optimized compiler and linker flags for release builds, including size optimization, debug output removal, and link-time optimization.

…er configs

ESP32-family and ESP8266 starter configs all linked at ~600 KB
Blink-class binaries because the default Arduino-ESP32 build carries:
  - build_type = debug + -Og (no optimization)
  - CORE_DEBUG_LEVEL=5 + ESP_LOG_VERBOSE (every log string compiled in)
  - full libstdc++ exception machinery (no -fno-exceptions / -fno-rtti)
  - no per-function/data sections + no -Wl,--gc-sections, so the linker
    drops nothing it doesn't have to

Adds a heavily commented [build_type=release / build_flags / build_unflags]
block to each ESP env. Result on FastLED's own esp32dev CI:
  Blink:   631100 B -> 408136 B  (-223 KB / -35%)

The block is fully commented for new users: 'comment out (or set
build_type = debug) when you need verbose logs / exception decoding
while developing.' Each file points to the FastLED PR that did the
investigation (FastLED/FastLED#3268).

Files updated (all 11):
  platformio.esp32c2.ini
  platformio.esp32c3.ini
  platformio.esp32c5.ini       (preserves existing PARLIO ISR flags)
  platformio.esp32c6.ini       (preserves existing PARLIO ISR flags)
  platformio.esp32dev.ini
  platformio.esp32h2.ini       (preserves existing PARLIO ISR flags)
  platformio.esp32p4.ini       (preserves existing PARLIO ISR flags)
  platformio.esp32s2.ini
  platformio.esp32s3.ini       (preserves existing exception_decoder filter)
  platformio.esp8266.ini       (NONOS SDK — no CORE_DEBUG_LEVEL macro)
  platformio.seeed_xiao_esp32s3.ini

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e06fbfb0-965b-489e-966a-15f0332c4ff9

📥 Commits

Reviewing files that changed from the base of the PR and between 58faf18 and b2e0b6f.

📒 Files selected for processing (11)
  • platforms/platformio.esp32c2.ini
  • platforms/platformio.esp32c3.ini
  • platforms/platformio.esp32c5.ini
  • platforms/platformio.esp32c6.ini
  • platforms/platformio.esp32dev.ini
  • platforms/platformio.esp32h2.ini
  • platforms/platformio.esp32p4.ini
  • platforms/platformio.esp32s2.ini
  • platforms/platformio.esp32s3.ini
  • platforms/platformio.esp8266.ini
  • platforms/platformio.seeed_xiao_esp32s3.ini

📝 Walkthrough

Walkthrough

All ten ESP32 and ESP8266 PlatformIO environment INI files receive a uniform size-optimization release build configuration: build_type = release, compiler/linker flags disabling debug logs, C++ exceptions, RTTI, and unwind tables while enabling -Os, LTO, function/data sectioning, and linker GC-sections, plus build_unflags removing -Og and -g. Targets that already had PARLIO ISR defines retain those alongside the new flags.

Changes

Size Optimization Release Build Config

Layer / File(s) Summary
Targets with no prior build_flags
platforms/platformio.esp32c2.ini, platforms/platformio.esp32c3.ini, platforms/platformio.esp32dev.ini, platforms/platformio.esp32s2.ini, platforms/platformio.esp8266.ini, platforms/platformio.seeed_xiao_esp32s3.ini, platforms/platformio.esp32s3.ini
Adds build_type = release, build_flags for -Os, LTO, sectioning, disabled exceptions/RTTI/unwind tables, and build_unflags removing -Og/-g to environments that had no prior flag overrides. ESP32-S3 additionally reformats monitor_filters to list default and esp32_exception_decoder explicitly.
Targets extending PARLIO build_flags
platforms/platformio.esp32c5.ini, platforms/platformio.esp32c6.ini, platforms/platformio.esp32h2.ini, platforms/platformio.esp32p4.ini
Expands the existing PARLIO ISR define-only build_flags block with the same release/size-optimization configuration, keeping the PARLIO -DCONFIG_* defines alongside the new flags.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

Poem

🐇 Hop, hop, the bunny trims the code so lean,
-Os and LTO make the binaries clean.
No RTTI, no exceptions, no debug to weigh,
Sections get collected, dead code swept away.
Release flags bloom in every .ini file,
The rabbit grins — smaller builds in style! 🌸

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/esp-release-size-flags

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 4705e18 into main Jun 20, 2026
1 of 2 checks passed
@zackees zackees deleted the feat/esp-release-size-flags branch June 20, 2026 10:15
@zackees zackees mentioned this pull request Jun 20, 2026
3 tasks
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Jun 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

1 participant