Skip to content

build: gate uniffi cli behind uniffi-bindgen feature - #1153

Merged
thunderbiscuit merged 1 commit into
bitcoindevkit:masterfrom
Arowolokehinde:build/gate-uniffi-cli
Nov 5, 2026
Merged

thunderbiscuit merged 1 commit into
bitcoindevkit:masterfrom
Arowolokehinde:build/gate-uniffi-cli

Conversation

@Arowolokehinde

Copy link
Copy Markdown
Contributor

Description

The cli feature was enabled on the library's uniffi dependency, so the bindgen toolchain (uniffi_bindgen, clap, goblin, weedle2, askama, ...) was bundled into every libbdkffi.a.

This PR:
moves cli into a uniffi-bindgen feature that is off by default and required by the uniffi-bindgen binary, adds --features uniffi-bindgen to the 8 cargo run --bin uniffi-bindgen calls in the Swift and Android build scripts and sets resolver = "2"

Fixes #1124

Notes to the reviewers

I confirmed the bug before changing anything. I built the iOS (aarch64-apple-ios) and macOS (aarch64-apple-darwin) static libraries on master with the release-smaller profile, the same way build-xcframework.sh does. Both archives were about 125 MB, and each contained 4,748 symbols from the bindgen toolchain (uniffi_bindgen, clap, goblin, weedle, ...). cargo tree also showed clap as a normal dependency of the library, pulled in through uniffi.

I first applied only the fix proposed in the issue. The iOS library went from about 125 MB to about 122 MB (3.3 MB smaller), and 3,824 bindgen symbols were still there. That led to the resolver finding below.

After adding resolver = "2", I rebuilt both libraries the same way. Both are now about 93 MB, 37.4 MB smaller each, and contain no bindgen symbols. The bindgen crates are gone from the library's dependency graph. The tests pass, and the generated Swift bindings are identical to master.

The crate is on edition 2018, so Cargo uses the v1 feature resolver, which unifies features across normal, build and dev dependencies. uniffi's build feature (from [build-dependencies]) and bindgen-tests (from [dev-dependencies]) were therefore also enabled on the library, and both pull in uniffi_bindgen.

Documentation

Changelog

changelog: fixed

All Submissions:

  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing
  • I've added exactly one changelog:* label
  • I've linked the relevant upstream docs or specs above

@thunderbiscuit thunderbiscuit left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ACK 160301a. Thanks for the work.

One thing to note here is that this will require bdk-jvm, bdk-python, bdk-dart, and bdk-rn to also upgrade their build script (but they also benefit from the change so I'm happy about that). Since they're all using bdk-ffi submodules, nothing breaks right at the moment, but we should open issues on these repos to remind devs that when they bump their submodules to the latest on master (after this is merged) their build script will fail.

This needs a rebase. Also, can you open the issues on the given repos to remind us of this required update? Thanks!

@Arowolokehinde

Copy link
Copy Markdown
Contributor Author

Thanks for the review!

I'll rebase and open issues on bdk-jvm, bdk-python, bdk-dart and bdk-rn noting that when they bump their submodules to the latest on master their build script will fail.

@Arowolokehinde

Copy link
Copy Markdown
Contributor Author

Opened the reminder issues on bdk-rn, bdk-jvm, bdk-dart and bdk-python.
you can check it out @thunderbiscuit

The cli feature was enabled on the library's uniffi dependency, so the
bindgen toolchain was bundled into every libbdkffi.a.

Move cli behind an opt-in uniffi-bindgen feature and set resolver = "2"
so the bindgen toolchain stays out of the library.
@thunderbiscuit
thunderbiscuit merged commit 8295cd6 into bitcoindevkit:master Nov 5, 2026
6 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in BDK-Bindings Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Gate uniffi/cli behind a feature so the static libraries don't bundle the bindgen toolchain

2 participants