Skip to content

fix(importer): feature-gate wasmtime so --no-default-features drops cranelift - #1430

Merged
robcohen merged 1 commit into
mainfrom
fix/termux-no-default-wasmtime
Jun 18, 2026
Merged

robcohen merged 1 commit into
mainfrom
fix/termux-no-default-wasmtime

Conversation

@robcohen

Copy link
Copy Markdown
Member

Closes #1427 (regression of #867). cargo install rustledger --no-default-features still compiled cranelift-codegen, which can't build on Termux/aarch64.

Root cause

Two unconditional paths to wasmtime survived --no-default-features:

  1. rustledger-importer depended on wasmtime (+ rustledger-plugin's wasm-runtime) unconditionally for the WASM importer loader (added in feat(importer): WasmImporter host loader (wave 2.3b) #1131 — this is what re-broke Build/installation fails on Android (Termux) #867).
  2. The CLI pulled rustledger-importer/rustledger-plugin with their default, wasmtime-enabling features.

Fix

Gate the WASM importer behind a new wasm-importer feature (off by default):

  • rustledger-importer: wasmtime/rmp-serde/serde/thiserror/rustledger-plugin are now optional, enabled only by wasm-importer. The wasm module, the registry's register_wasm_* methods + WasmDirScanReport, and the e2e test are #[cfg(feature = "wasm-importer")].
  • CLI: both crates resolve to their wasmtime-free feature sets by default; the existing default python-plugin-wasm feature re-enables rustledger-importer/wasm-importer. The extract command's WASM-importer-dir loading + its resolve_scan_dirs/WasmDirSetting/expand_tilde helpers are gated behind python-plugin-wasm (the CLI's plugin-runtime paths were already gated).

Verification

  • cargo tree -p rustledger --no-default-features -i wasmtime → "did not match any packages" (wasmtime/cranelift gone).
  • Both configs build clean (no warnings); cargo clippy -- -D warnings clean in both.
  • Default build unchanged: WASM importer + Python-plugin sandbox present; 364 lib tests pass (incl. the gated register_wasm_*/resolve_scan_dirs/expand_tilde tests). Importer no-default tests pass.
  • A --no-default-features build keeps check/query/price-download — the use case the reporter needs.

Regression guard

scripts/check-slim-no-wasmtime.sh + a CI job (Slim Build (no wasmtime)) fail if wasmtime re-enters the no-default dependency tree — so #867→#1427 can't happen a third time (ties into #1395).

How to test

cargo build -p rustledger --no-default-features          # no cranelift compiled
cargo tree -p rustledger --no-default-features -i wasmtime   # "did not match any packages"
cargo build -p rustledger                                # default: full feature set

…ranelift

`cargo install rustledger --no-default-features` regressed (#1427, same as
#867): it still compiled `cranelift-codegen`, which can't build on Termux/
aarch64. The cause was two unconditional paths to `wasmtime`:

1. `rustledger-importer` depended on `wasmtime` (and `rustledger-plugin`'s
   `wasm-runtime`) unconditionally for the WASM importer loader (#1131).
2. The CLI pulled both crates with their default (wasmtime-enabling) features.

Gate the WASM importer behind a new `wasm-importer` feature (off by default):
- rustledger-importer: `wasmtime`/`rmp-serde`/`serde`/`thiserror`/
  `rustledger-plugin` are now optional, enabled only by `wasm-importer`; the
  `wasm` module, the registry's `register_wasm_*` methods + `WasmDirScanReport`,
  and the e2e test are `#[cfg(feature = "wasm-importer")]`.
- CLI: `rustledger-importer`/`rustledger-plugin` resolve to their wasmtime-free
  feature sets by default; `python-plugin-wasm` (still the default feature)
  re-enables `rustledger-importer/wasm-importer`. The extract command's WASM
  importer-dir loading + its `resolve_scan_dirs`/`WasmDirSetting`/`expand_tilde`
  helpers are gated behind `python-plugin-wasm`.

The default build is unchanged (WASM importer + Python-plugin sandbox present;
364 lib tests pass). A `--no-default-features` build now carries no `wasmtime`/
cranelift and keeps `check`/`query`/price-download. A CI ratchet
(`scripts/check-slim-no-wasmtime.sh`) fails if `wasmtime` re-enters the
no-default tree, so this can't regress a third time (#1395).

Closes #1427.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@robcohen
robcohen requested a review from a team as a code owner June 18, 2026 12:36
Copilot AI review requested due to automatic review settings June 18, 2026 12:36
@codecov

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.47619% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/rustledger/src/cmd/extract_cmd/mod.rs 90.47% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@github-actions

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

Tool Time Memory
rustledger 35.3ms ± 0.4ms 24.5 MB
beancount 900.8ms ± 9.4ms 50.7 MB
Comparison 25.5x faster 2.1x less

vs main branch (2026-06-18)

Metric main this PR Change
Time 36.3ms 35.3ms -2.8% ✅
10K transactions · 5 runs, 2 warmup · hyperfine
What do these numbers mean?
  • Time: Wall-clock time to parse and validate the ledger (± std dev)
  • Memory: Peak resident set size (RSS)
  • vs main: Compared to latest nightly benchmark on main branch

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a build regression where cargo install rustledger --no-default-features still pulled in wasmtime (and therefore cranelift-codegen), preventing slim native builds on platforms like Termux/aarch64. It does so by feature-gating the WASM importer support behind a new rustledger-importer/wasm-importer feature and wiring the CLI’s existing python-plugin-wasm default feature to re-enable it.

Changes:

  • Add wasm-importer feature to rustledger-importer, making wasmtime (and related deps/APIs/tests) optional and #[cfg]-gated.
  • Gate the CLI’s WASM-importer registry loading and related helpers/tests behind python-plugin-wasm.
  • Add a “slim build” guard script and CI job to ensure --no-default-features stays wasmtime-free.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
scripts/check-slim-no-wasmtime.sh Adds a dependency-tree guard to assert wasmtime is absent under --no-default-features.
crates/rustledger/src/cmd/extract_cmd/mod.rs Gates WASM importer loading/dir resolution and related tests behind python-plugin-wasm.
crates/rustledger/src/cmd/extract_cmd/config.rs Gates TOML wasm_importer_dir handling and expand_tilde behind python-plugin-wasm.
crates/rustledger/Cargo.toml Ensures python-plugin-wasm re-enables rustledger-importer/wasm-importer and documents slim build intent.
crates/rustledger-importer/Cargo.toml Introduces wasm-importer feature; makes wasmtime + serialization deps optional.
crates/rustledger-importer/src/lib.rs #[cfg]-gates the wasm module and WASM-related re-exports.
crates/rustledger-importer/src/registry.rs #[cfg]-gates WASM registry APIs and report type; gates WASM discovery tests.
crates/rustledger-importer/tests/wasm_importer_e2e.rs Gates the e2e WASM importer test behind wasm-importer.
.github/workflows/ci.yml Adds “Slim Build (no wasmtime)” CI job running the new guard script.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/ci.yml Resolved
@github-actions

Copy link
Copy Markdown
Contributor

✅ Compatibility Test Results

Metric Result
Check Compatibility 100%
BQL Compatibility 100%
Full AST Match 100%
Total Files 792
What's tested
  • Check: Exit codes and error counts match bean-check
  • BQL: Query results match bean-query
  • Files: ~800 test files downloaded from 10+ beancount repositories

Full results available in workflow artifacts

@robcohen
robcohen merged commit 31faa12 into main Jun 18, 2026
43 checks passed
@robcohen
robcohen deleted the fix/termux-no-default-wasmtime branch June 18, 2026 19:20
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.

[Bug]: cranelift error when building in Termux

2 participants