Skip to content

gl-sdk: build the Android libraries in release mode, and unwind on panic on iOS too - #762

Open
angelix wants to merge 2 commits into
Blockstream:mainfrom
angelix:ave-sdk-release-build
Open

angelix wants to merge 2 commits into
Blockstream:mainfrom
angelix:ave-sdk-release-build

Conversation

@angelix

@angelix angelix commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Problem

  • The Android libraries are debug builds. The linux-*-* tasks run cargo ndk ... build -p gl-sdk without --release, so task build:kotlin packages dev-profile libraries: unoptimized and with debug assertions. Cargo reports Finished `dev` profile [unoptimized + debuginfo] for them. The published glsdk-android 0.5.0 carries the same marks: its arm64-v8a library is 29.1 MB and holds hundreds of unsafe precondition(s) violated messages, which Rust only compiles in with debug assertions.
  • iOS aborts on panic. The iOS tasks build in release, and the workspace's [profile.release] sets panic = "abort". So a Rust panic in the SDK aborts an iOS app, while on Android, which unwinds because it is a debug build, UniFFI hands the panic to Kotlin as an exception. Building Android in release as it stands would make it abort too.

Change

  • The Android, iOS and iOS simulator tasks set CARGO_PROFILE_RELEASE_PANIC=unwind, so the SDK libraries unwind on panic on both platforms. Other builds, such as the plugins and the Python bindings, keep panic = "abort".
  • The Android tasks pass --release, and task build:kotlin generates the Kotlin bindings from target/aarch64-linux-android/release/libglsdk.a instead of debug.
  • Changelog entries for both, one commit each.

Testing

cargo ndk 3.5.4, NDK 29, rustc 1.98.1, on main and on this branch:

Library Branch Profile Size Compressed (zip -9) unsafe precondition messages Panic runtime
Android arm64-v8a libglsdk.so main dev 29.9 MB 9.8 MB 1,110 unwind
Android arm64-v8a libglsdk.so this branch release 11.0 MB 5.5 MB 0 unwind
iOS aarch64-apple-ios libglsdk.a main release abort
iOS aarch64-apple-ios libglsdk.a this branch release unwind
  • Panic runtime. main's iOS archive links panic_abort and has 0.02 MB of exception tables (__gcc_except_tab). This branch's links panic_unwind and has 1.31 MB. The release Android library links panic_unwind and keeps its .gcc_except_table (1.29 MB).
  • API. Both Android libraries export the same uniffi_* symbols, including the 71 uniffi_glsdk_fn_* functions.
  • Bindings. The pinned gobley generates identical Kotlin from main's debug libglsdk.a and from this branch's release one.
  • Taskfile. A throwaway Taskfile confirmed that an anchored env on a wildcard task in an included Taskfile reaches that task's commands and no other task's.
  • Not tested. I haven't run the libraries in an app, or triggered a panic to watch it arrive in Kotlin or Swift.

The workspace's release profile sets panic = "abort", so on iOS a Rust
panic in the SDK aborts the app instead of reaching Kotlin or Swift as
an exception. The Android, iOS and iOS simulator tasks override it with
CARGO_PROFILE_RELEASE_PANIC=unwind. The Android libraries are debug
builds and already unwind; the override keeps them unwinding once they
build in release.
The Android tasks ran `cargo ndk ... build` without `--release`, so the
Kotlin package shipped dev-profile libraries: unoptimized, with debug
assertions, and almost three times the size of a release build
(arm64-v8a libglsdk.so: 29.9 MB, 11.0 MB in release). The iOS tasks
already build in release.

The Kotlin bindings are generated from the release arm64 library, which
yields the same Kotlin as the debug one.

This branch has not been deployed

No deployments
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