Repository navigation
Conversation
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.
- AGP 9.5 requires Gradle 9.6.0 or newer and fixes the Configuration.setVisible() deprecation warnings that AGP 9.4.1 triggers on Gradle 9.8 - Read libraryVersion with project.property(): Gradle 9.6 deprecates the 'val name: Type by project' delegate, which Gradle 10 removes Kotlin stays at 2.2.21, as KT-88548 is fixed only in Kotlin 2.5.0. The Gradle deprecation warnings left come from its Gradle plugin.
angelix
force-pushed
the
ave-native-support
branch
2 times, most recently
from
November 13, 2026 15:15
3fb7a26 to
ed105e6
Compare
The glsdk-jvm artifact shipped without a native library, so loading the SDK on a desktop JVM failed with UnsatisfiedLinkError. - Build the library for macOS, Linux and Windows, each on x86_64 and arm64, in release mode and unwinding on panic like the mobile libraries, and put each in the jvm resources directory where JNA looks for it - Strip the macOS dylibs with Apple's /usr/bin/strip instead of cargo's rust-objcopy, which in rustc 1.91 does not pad the string table to 8 bytes after an indirect symbol table with an odd number of entries: dyld on macOS 27 refuses such a dylib (seen in LWK, 291 entries). gl-sdk has 280 entries today, so it only loads by luck. The strip first on PATH can be llvm-strip, with the same bug, or GNU strip, without Mach-O support. Stripping the local symbols too almost halves the arm64 dylib. - Cross compile Linux from macOS with cargo-zigbuild against glibc 2.17, so the publish job keeps running on a single runner. The libraries depend only on libc, libm, libdl and libpthread, and the newer glibc functions Rust's std uses are weak symbols. - Cross compile Windows with cargo-xwin and link the C runtime statically: the DLLs depend only on Windows system DLLs and load without the Visual C++ Redistributable. The flag is appended to RUSTFLAGS, as cargo-xwin, like cargo, ignores the target rustflags when RUSTFLAGS is set, and a caller's RUSTFLAGS would drop it. - Pin the MSVC CRT (14.44.17.14) and Windows SDK (10.0.26100) cargo-xwin downloads, in a cache directory per version pair, the one LWK's build uses too: cargo-xwin reuses an existing cache that has the needed arches whatever its versions, which would ignore the pin - On Windows arm64 ring compiles its C code with clang, which reads the clang-cl /imsvc flags cargo-xwin passes the SDK headers with as file names. The headers go in INCLUDE instead, which clang and clang-cl both search, and only CFLAGS loses the flags: CXXFLAGS keeps /EHsc, without which bitcoinconsensus fails to compile. - cargo xwin env folds RUSTFLAGS into the target rustflags and exports an empty RUSTFLAGS, which cargo would use instead: unset it. Its output is assigned before the eval, so a failing cargo xwin env stops the build. - Build the two Windows libraries one after the other: every cargo-xwin run recreates the clang-cl symlink in its shared cache, and on a fresh cache unpacks the SDK there, so two runs at once fail with "Failed to setup clang-cl symlink" or "failed to splat" - Install cargo-zigbuild and cargo-xwin under target/cross-tools once per build. cargo-zigbuild needs zig, which the CI jobs install, the GitLab one only when the runner lacks it. cargo-xwin needs the llvm-tools component, which both CI jobs install: it links its llvm-ar as llvm-lib, the archiver it gives cc-rs, and silently skips the link without it, so ring's build script fails to find llvm-lib. - Target Java 17 and compile against its API: the classes otherwise get the bytecode version of the JDK running Gradle, Java 24 on a JDK 25 machine - Pass --enable-native-access=ALL-UNNAMED to the jvm tests: on Java 24 or later JNA loading the library with System::load, a restricted method, prints a warning. A library jar cannot grant native access itself, so the README tells applications to pass the flag. - Run the jvm tests in the GitHub workflow and build the Kotlin bindings there with Rust 1.91.0, as cargo-xwin needs 1.89 or later. Add the desktop targets to both CI jobs building the bindings.
angelix
force-pushed
the
ave-native-support
branch
from
November 13, 2026 15:27
ed105e6 to
9e21a07
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on #762. This branch carries its two commits, rebased onto
mainbecause the Windows arm64 build needsd6fb51df(see below). Only the last two commits are new here.Problem
glsdk-jvm0.5.0 on Maven Central contains nolibglsdkfor any platform, so the first SDK call on a desktop JVM fails withUnsatisfiedLinkError: Unable to load library 'glsdk'. Thejvm()target is declared, buttask build:kotlinnever builds a desktop library.jvm()sets nojvmTarget, so the bytecode version follows the JDK running Gradle. 0.5.0 happens to be Java 17; a JDK 25 machine produces Java 24 classes (major version 68).lib/build.gradle.ktsreadslibraryVersionwith theby projectdelegate that Gradle 9.6 deprecates.Change
gl-sdk-android: Update Gradle to 9.8.2 and AGP to 9.5.1Configuration.setVisible()deprecations AGP 9.4.1 triggers on Gradle 9.8.libraryVersionis read withproject.property().gl-sdk: Bundle the desktop libraries in the jvm jarjvmtask, whichkotlindepends on, buildslibglsdkfor macOS, Linux and Windows on x86_64 and arm64, in release and unwinding on panic through gl-sdk: build the Android libraries in release mode, and unwind on panic on iOS too #762'ssdk_env. It puts each injvmMain/resources/<platform>/, where JNA looks for it./usr/bin/strip -xinstead of cargo's rust-objcopy. In rustc 1.91, rust-objcopy does not pad the string table to 8 bytes after an indirect symbol table with an odd number of entries, and dyld on macOS 27 refuses such a dylib. LWK hit this with 291 entries; gl-sdk has 280 today, so it only loads by luck. The full path matters: thestripfirst onPATHcan bellvm-strip, with the same bug, or GNU strip, which doesn't handle Mach-O.+crt-staticflag is appended toRUSTFLAGS, because cargo-xwin, like cargo, ignores the target rustflags whenRUSTFLAGSis set, and a caller'sRUSTFLAGSwould drop it. The MSVC CRT (14.44.17.14) and Windows SDK (10.0.26100) are pinned, each version pair in its own cache directory, the one LWK uses too: cargo-xwin reuses an existing cache that has the needed arches whatever its versions, which would ignore a plain pin. On arm64, ring compiles its C code with plain clang, which can't read the clang-cl/imsvcflags cargo-xwin passes the SDK headers with. The headers go inINCLUDEinstead, and onlyCFLAGSloses the flags, sinceCXXFLAGSkeeps/EHsc, whichbitcoinconsensusneeds. This build needs ring 0.17: ring 0.16, whichmaindropped ind6fb51df, has noaarch64-pc-windows-msvcsupport.clang-clsymlink in its shared cache, so Task's parallel deps made them fail withFailed to setup clang-cl symlink ... File exists.-Xjdk-release=17). The jvm tests run with--enable-native-access=ALL-UNNAMED, because Java 24 or later warns when JNA callsSystem::load. The README tells applications to pass the same flag.:lib:jvmTestand builds with Rust 1.91.0, since cargo-xwin needs 1.89 or later. Both CI jobs get the desktop targets, zig, and thellvm-toolscomponent: cargo-xwin links itsllvm-arasllvm-lib, the archiver it gives cc-rs, and silently skips the link without it, so ring's build script fails withfailed to find tool "llvm-lib". The GitLab job'sbefore_scriptexpectsrustupandbrewon the m4 runner, as LWK's does; I can't check that runner.*.dllin.gitignore.This mirrors LWK's desktop support, without its
simplicity-sysNDEBUGworkaround and with a narrower Windows arm64 recipe, as LWK also had to handlepsmandaws-lc.Testing
macOS 27 on arm64, rustc 1.98.1:
task build:kotlintask build:jvm, cached, 5 runs:lib:jvmTest, JDK 25mainwithUnsatisfiedLinkError, passes here with no native-access warningCommonTestagainst the builtlib-jvm.jar,eclipse-temurin:17-jreon linux/arm64 and linux/amd64darwin-x86-64dylib under Rosettaffi_glsdk_uniffi_contract_versionreturns 29GLIBC_2.17; they need only libc, libm, libdl and libpthreadVCRUNTIME140,ucrtbaseorapi-ms-win-crt-*RUSTFLAGS="--cfg glsdk_probe"+crt-staticand the caller's flag. Before appending toRUSTFLAGS, both importedVCRUNTIME140,MSVCP140andapi-ms-win-crt-*.textidentical; about 110 bytes of build metadata differ: generated-source paths in panic locations, whose hash follows the rustflags, the linker timestamp and the PDB GUIDuniffi_glsdksymbols:lib:assemble:lib:iosSimulatorArm64Test:lib:connectedAndroidDeviceTest, arm64 emulatorpublishToMavenLocal, into a scratch repositoryglsdk-jvm-0.5.0.jarcontains all six librariestask build:kotlinand with the libraries built frommain.main, the Android device tests printUnable to strip ... libglsdk.so(AGP's default NDK isn't installed) and, on JDK 25, asun.misc.Unsafewarning from protobuf in AGP's test runner.lld-linkLNK4099 warnings: the static CRT's objects reference debug symbol files on Microsoft's build machines (D:\a\_work\...\libcmt.amd64.pdb). They don't affect the DLL.aka.mswith no timeout, while LWK's runs failed withunable to locate SDK. If Microsoft drops the pinned versions, CI may hang until its job timeout rather than fail.