Skip to content

feat(shrink): report an unhonoured --shrink request instead of dropping it (#1459 part 1) - #1813

Merged
zackees merged 1 commit into
mainfrom
agent/shrink-decision-plumb
Oct 31, 2026
Merged

zackees merged 1 commit into
mainfrom
agent/shrink-decision-plumb

Conversation

@zackees

@zackees zackees commented Oct 31, 2026

Copy link
Copy Markdown
Member

Problem

fbuild build --shrink=<mode> has been accepted since #496 and silently dropped ever since. Three facts from origin/main (47d81e0):

  • crates/fbuild-cli/src/cli/dispatch.rs bound the flags as shrink: _, no_shrink: _ — the values never reached a build.
  • fbuild_build::shrink::resolve_for_context and registry_for have zero call sites outside crates/fbuild-build-engine/src/shrink/.
  • registry_for returns &[] for all 15 platforms.

So --shrink=safe|aggressive|printf produced a stock build and printed nothing. The flag looks functional; the user finds out it isn't from a symbol dump. That is the "the build prints no shrink decision" half of #1459.

What this changed

One reporting path, no behaviour change to compilation or linking:

  • New crates/fbuild-cli/src/cli/shrink_notice.rs: unsupported_notice(mode, platform, available) returns the single line to print, None when silence is correct.
  • dispatch.rs now resolves the flag with the existing resolve_explicit(global, subcommand, no_shrink) and reports it before the build runs.
  • Platform id comes from the project's own platformio.ini (get_default_environment + get_env_config("platform") → Platform::from_platform_str), best-effort: unreadable ini → "this platform", never an error.

Semantics:

request registry output
auto (default, bare --shrink) empty silent
off / --no-shrink any silent
safe/aggressive/printf empty shrink: --shrink=safe has no effect yet: no shrinker is registered for espressif32; building unshrunk (FastLED/fbuild#1459)
explicit mode non-empty silent — the link stage owns the applied line

The notice deletes itself once a platform registry gains entries, so it cannot go stale.

What this does NOT do

No printf reducer, no link-strategy change, no build_info field. --shrink=auto still resolves to off on ESP32-S3/newlib, so a stock Blink ELF still retains _vfprintf_r/_svfprintf_r (28,320 B cluster from #1459). #1459 stays open; this is its reporting prerequisite — the build_info telemetry criterion is still outstanding because the decision never reaches the link stage.

Tests

crates/fbuild-cli/src/cli/shrink_notice.rs unit tests:

  • auto_is_silent, off_is_silent — the two silent paths.
  • explicit_mode_with_empty_registry_is_reported_with_platform — message names --shrink=safe, the platform, and feat(shrink): make ESP32-S3 printf reduction actually apply #1459.
  • every_explicit_non_off_mode_is_reported — safe/aggressive/printf.
  • unknown_platform_still_reports — falls back to "this platform".
  • registered_shrinker_suppresses_the_notice — injected non-empty registry → silence.
  • esp32_s3_newlib_auto_is_off_today — the RED half of feat(shrink): make ESP32-S3 printf reduction actually apply #1459 pinned as a test: resolve_for_context(Auto, espressif32/newlib/arduino) == Off and registry_for(espressif32) == [].
  • platform_id_covers_every_slice_of_the_report.
$ soldr cargo test -p fbuild-cli --bin fbuild shrink
running 14 tests
test result: ok. 14 passed; 0 failed; 0 ignored; 0 measured; 449 filtered out

End-to-end on the real binary (default verbosity, no RUST_LOG), tests/platform/esp32s3:

$ fbuild build --shrink=safe --dry-run
WARNING: shrink: --shrink=safe has no effect yet: no shrinker is registered for espressif32; building unshrunk (FastLED/fbuild#1459)
$ fbuild build --shrink=printf --dry-run    # same line, --shrink=printf
$ fbuild build --shrink=aggressive --dry-run # same line, --shrink=aggressive
$ fbuild build --no-shrink --dry-run        # silent
$ fbuild build --dry-run                    # silent (auto)

and the platform id really comes from the project, tests/platform/uno:

$ fbuild build --shrink=safe --dry-run
WARNING: shrink: --shrink=safe has no effect yet: no shrinker is registered for atmelavr; building unshrunk (FastLED/fbuild#1459)

Note on the output channel

output::warn is a tracing::warn!, which is invisible at default verbosity (only RUST_LOG=info surfaced it) — that would have recreated the same silent-flag problem. The notice therefore goes through output::diagnostic with the repo's WARNING: marker, the always-visible path (--quiet and redirected stderr included).

…ng it

`--shrink` has been parsed since #496 and never consumed: dispatch bound the
flags as `shrink: _, no_shrink: _`, and resolve_for_context/registry_for had no
call sites outside fbuild-build-engine. --shrink=safe built a stock image and
said nothing, so the flag looked functional.

Report the resolved decision once per build. auto/off stay silent; an explicit
safe/aggressive/printf with an empty platform registry prints

  WARNING: shrink: --shrink=safe has no effect yet: no shrinker is registered
  for espressif32; building unshrunk (#1459)

The platform id is read from the project's own platformio.ini (best-effort), and
the notice disappears by itself once a registry gains entries. No compilation or
link behaviour changes; the printf reducer itself is still #1459's remaining
work.
@coderabbitai

coderabbitai Bot commented Oct 31, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@zackees
zackees added this pull request to the merge queue Oct 31, 2026
Merged via the queue into main with commit 3c2b0a2 Oct 31, 2026
29 checks passed
@zackees
zackees deleted the agent/shrink-decision-plumb branch October 31, 2026 05:51
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Nov 1, 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