Skip to content

ci(pio): make -fopt-info-all opt-in per board (default OFF) - #2659

Merged
zackees merged 1 commit into
masterfrom
ci/opt-in-fopt-info-all
May 31, 2026
Merged

zackees merged 1 commit into
masterfrom
ci/opt-in-fopt-info-all

Conversation

@zackees

@zackees zackees commented May 31, 2026 •

Copy link
Copy Markdown
Member

Summary

  • ci/compiler/pio.py currently injects -fopt-info-all=<board>/optimization_report.txt for every board (except esp32c2 + atmelavr) unconditionally. The flag is APPEND-mode and writes to a single per-board file shared across every example in the matrix.
  • For slow-link (no-LTO) boards with the full example matrix — nrf52840 + Adafruit BSP runs ~110 examples × ~25-96 source files × hundreds of opt-info lines per TU — the file routinely exceeds 100 MB.
  • When build_template.yml's Optimization Report step then dumps that file to the GHA log via ci/optimization_report.py --first, the per-step log buffer overruns and the runner gets shutdown mid-step. That's the root cause of the nrf52840 "build succeeds but workflow marked failure" pattern. PR ci(optimization-report): cap stdout dump at 1 MiB to keep GHA runner alive #2658 capped the log-side dump at 1 MiB as a stop-gap; this PR closes the source-side hole.

Changes

  • Add Board.generate_optimization_report: bool = False (default OFF).
  • ci/compiler/pio.py only adds the -fopt-info-all=... flag when the board opts in (and still respects the existing esp32c2 / atmelavr suppression).
  • The linker map (-Wl,-Map,firmware.map) stays unconditional — it's a small per-example file and is consumed by size-analysis tooling.

Behavior preservation

  • Opted-in boards (currently none): Optimization Report step works exactly as today.
  • Other boards: the report file simply doesn't exist; ci/optimization_report.py --first already handles that case gracefully (prints No optimization report found for board '<name>' and exits 0). No workflow change needed.
  • Boards that need the report for size/perf debugging can opt in with one line: generate_optimization_report=True on the Board(...) definition.

Why no board is opted in by default

The only consumer of optimization_report.txt is the workflow's display step — no automated tooling processes it. Boards that genuinely need optimizer notes for debugging can opt in selectively (one example doesn't trigger the >100MB overrun; a per-board single-sketch CI does).

Test plan

  • Smoke: Board(...) defaults to generate_optimization_report=False; Board(..., generate_optimization_report=True) round-trips correctly.
  • CI passes on this branch (PR build path).
  • After merge, master CI for nrf52840_dk + nrf52_xiaoblesense workflows turn green — exactly the goal condition.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added opt-in board configuration to enable optimization report generation. Users can now selectively generate detailed optimization artifacts on a per-board basis.

Today every non-AVR / non-esp32c2 board unconditionally gets
`-fopt-info-all=<board>/optimization_report.txt` injected by
ci/compiler/pio.py. The flag is APPEND-mode and writes a single file
shared across every example in the matrix — for slow-link (no-LTO)
boards with a large example set (nrf52840 + Adafruit BSP: ~110
examples × ~25-96 source files × hundreds of opt-info lines per TU)
the file routinely exceeds 100 MB.

When build_template.yml's Optimization Report step then dumps that
file to the GitHub Actions log via `ci/optimization_report.py --first`,
the per-step log buffer overruns and the runner is killed mid-step,
masking already-successful builds. PR #2658 capped the log-side dump
at 1 MiB as a stop-gap; this PR closes the source-side hole by making
the GCC flag itself opt-in.

Changes:
- Add `Board.generate_optimization_report: bool = False` (default OFF)
- ci/compiler/pio.py only injects `-fopt-info-all=...` when the board
  opts in (and still respects the esp32c2 / atmelavr suppression)
- The linker map (`-Wl,-Map,firmware.map`) stays unconditional — it's
  a small per-example file and is consumed by size-analysis tooling

Behavior for the Optimization Report workflow step is unchanged for
opted-in boards. For non-opted-in boards the report file simply
doesn't exist; `ci/optimization_report.py --first` already handles
that case gracefully (prints a "No optimization report found" message
and exits 0).

Boards that need the report for size/perf debugging can opt in by
adding `generate_optimization_report=True` to their `Board(...)`
definition in ci/boards.py.

Refs PR #2658.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@coderabbitai

coderabbitai Bot commented May 31, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR introduces an opt-in mechanism for GCC optimization report generation in the build system. A new boolean field generate_optimization_report is added to the Board dataclass, and the PlatformIO compiler flag logic is updated to conditionally emit -fopt-info-all only when this field is enabled per board, while linker map generation remains unconditional.

Changes

Optimization Report Opt-In

Layer / File(s) Summary
Board configuration field
ci/boards.py
The Board dataclass gains a new generate_optimization_report: bool = False field with documentation describing it as an opt-in switch for enabling GCC optimization-info output.
PlatformIO conditional optimization flags
ci/compiler/pio.py
Compiler flag setup is refactored so that -fopt-info-all is appended only when Board.generate_optimization_report is True, while -Wl,-Map,firmware.map remains unconditional and platform exclusions for esp32c2 and atmelavr are preserved.

Estimated Code Review Effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

A flag for reports, now opt-in and bright,
Per-board optimization shines with delight,
No more forced whispers from GCC's tongue,
Just when you ask, the tune is sung! 🐇✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.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 title clearly and specifically summarizes the main change: making -fopt-info-all opt-in per board with default OFF, which directly matches the primary objective of the PR.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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 ci/opt-in-fopt-info-all

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 d3931c5 into master May 31, 2026
6 of 7 checks passed
@zackees
zackees deleted the ci/opt-in-fopt-info-all 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

None yet

Development

Successfully merging this pull request may close these issues.

1 participant