Skip to content

build: enable lto + codegen-units=1 for release profile#85

Open
iainmcgin wants to merge 1 commit intomainfrom
build/release-lto
Open

build: enable lto + codegen-units=1 for release profile#85
iainmcgin wants to merge 1 commit intomainfrom
build/release-lto

Conversation

@iainmcgin
Copy link
Copy Markdown
Collaborator

Closes #60.

Adds lto = true and codegen-units = 1 to the workspace [profile.release].

Effect

Binary before after
protoc-gen-buffa ~3.9 MiB 3.08 MiB
protoc-gen-buffa-packaging ~706 KiB 529 KiB

Clean cargo build --release -p protoc-gen-buffa -p protoc-gen-buffa-packaging: ~10 s → ~27 s.

Scope

  • Applies to in-workspace release builds: CI-built GitHub Release binaries, benchmarks, conformance.
  • Does not apply to library consumers of buffa / buffa-build — Cargo only honors [profile.*] from the top-level workspace. The CHANGELOG entry calls this out.
  • Does not apply to cargo install protoc-gen-buffa — the workspace manifest isn't published. Adding per-crate [profile.release] to the plugin manifests was considered but produces a "profiles for the non root package will be ignored" warning on every workspace build. The guide's "Installing the protoc plugins" section now documents the CARGO_PROFILE_RELEASE_LTO=true CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1 cargo install ... form instead.

Semver

No public-API change. Suitable for 0.4.1.

Shrinks the prebuilt protoc-gen-buffa* release binaries by ~20% at the
cost of ~2x clean release-build time. Only the workspace root profile is
set (Cargo ignores per-crate profile sections inside a workspace, and the
warning noise outweighs the cargo-install benefit); the guide documents
the CARGO_PROFILE_RELEASE_LTO env-var path for cargo install users, and
the CHANGELOG notes that library consumers do not inherit this.
@github-actions
Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@iainmcgin iainmcgin marked this pull request as ready for review April 29, 2026 22:45
@iainmcgin iainmcgin requested a review from kollektiv April 29, 2026 22:45
@iainmcgin iainmcgin enabled auto-merge (squash) April 29, 2026 22:45
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.

Enable Link-Time Optimization (LTO) and codegen-units = 1 for Release builds

1 participant