Skip to content

feat(build): compile WASM templates with size-optimizing cargo profile#163

Merged
sdbondi merged 1 commit into
mainfrom
compile-opt
Jun 24, 2026
Merged

feat(build): compile WASM templates with size-optimizing cargo profile#163
sdbondi merged 1 commit into
mainfrom
compile-opt

Conversation

@sdbondi

@sdbondi sdbondi commented Jun 24, 2026

Copy link
Copy Markdown
Member

Summary

Compile WASM templates with size-optimizing release profile settings, injected on the cargo build command line via --config so a template doesn't need to declare them in its own Cargo.toml. Because --config takes precedence over the manifest, the overrides apply even when a template defines its own [profile.release]:

opt-level = 's'      # Optimize for size
lto = true           # Link Time Optimization
codegen-units = 1    # More optimization
panic = 'abort'      # Abort on panic
strip = true         # Strip symbols

These are on by default. Pass --no-cargo-opts to tari build / tari publish (and tari template publish) to skip them and build with the template's plain release profile.

Changes

  • build_project / build_template take an optimize flag; the overrides live in a CARGO_OPT_CONFIGS const and are only added when enabled.
  • --no-cargo-opts added to tari build, tari publish, and tari template publish.
  • Internal "metadata stale → rebuild" paths (inspect, metadata publish) use the default opts so the cargo build cache stays consistent with a normal build.

Dependency fix

Pins curve25519-dalek to =5.0.0-pre.6. 5.0.0-rc.1 switched to the upstream ff 0.14 crate, which breaks tari_bulletproofs_plus 0.5.0 (Scalar no longer exposes pow_vartime). Follows the repo's existing hickory-proto pinning idiom (direct dep + cargo-machete ignore). See tari-project/bulletproofs-plus#148.

Testing

  • cargo check -p tari-ootle-cli --locked compiles the whole workspace clean.
  • Verified empirically that cargo build --config "profile.release.opt-level='s'" overrides a manifest's own [profile.release], and that all five --config flags are accepted together.

🤖 Generated with Claude Code

Inject size-optimizing release profile settings into the WASM template
build via `cargo build --config`, so templates get small binaries without
having to declare a `[profile.release]` themselves. The overrides take
precedence over a template's own manifest profile:

  opt-level = 's'      # Optimize for size
  lto = true           # Link Time Optimization
  codegen-units = 1    # More optimization
  panic = 'abort'      # Abort on panic
  strip = true         # Strip symbols

These are applied by default. Pass `--no-cargo-opts` to `tari build` /
`tari publish` to skip them.

Also pin curve25519-dalek to =5.0.0-pre.6: 5.0.0-rc.1 switched to the
upstream `ff` 0.14 crate which breaks tari_bulletproofs_plus 0.5.0.
See tari-project/bulletproofs-plus#148

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces size-optimizing release profile overrides (such as opt-level='s', lto=true, codegen-units=1, panic='abort', and strip=true) to the WASM template build process via cargo build --config. It adds a --no-cargo-opts CLI flag to the build, publish, and template publish commands to allow skipping these optimizations. Additionally, it pins the curve25519-dalek dependency to version =5.0.0-pre.6 to prevent compatibility issues with tari_bulletproofs_plus, and bumps the workspace package version to 0.20.1. There are no review comments, so I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@sdbondi sdbondi merged commit 9cacb5f into main Jun 24, 2026
4 of 6 checks passed
@sdbondi sdbondi deleted the compile-opt branch June 24, 2026 11:14
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