[Rust][FFI] Add native library support for Linux musl (Alpine)#412
Merged
Conversation
Add x86_64-unknown-linux-musl and aarch64-unknown-linux-musl matrix rows to release-ffi.yml, cross-compiled with cargo-zigbuild on the existing linux-ubuntu-latest runners. Uses RUSTFLAGS=-C target-feature=-crt-static so the libs link musl dynamically, correct for Alpine hosts. Document the musl cross-compile in the FFI README. Mirrors the JNI musl support from #347. Fixes #411 Signed-off-by: Zlata Stefanovic <zlata.stefanovic@databricks.com>
zlata-stefanovic-db
force-pushed
the
ffi-musl-support
branch
from
June 23, 2026 09:24
5eee32a to
16fbfc7
Compare
zlata-stefanovic-db
marked this pull request as ready for review
June 23, 2026 09:25
|
|
||
| ### New Features and Improvements | ||
|
|
||
| - Build the FFI library for Linux musl targets (`x86_64-unknown-linux-musl`, `aarch64-unknown-linux-musl`), enabling C/C++ and Go-on-Alpine consumers to link `libzerobus_ffi.a` / `libzerobus_ffi.so` on musl-based (Alpine) containers. Artifacts ship in the `linux-musl-x86_64` / `linux-musl-aarch64` directories. Mirrors the JNI musl support added in #347. |
Collaborator
There was a problem hiding this comment.
I don't think we need the last sentence.
Contributor
Author
There was a problem hiding this comment.
Deleted
|
|
||
| - name: Install Zig (musl cross-builds) | ||
| if: matrix.zigbuild | ||
| uses: mlugg/setup-zig@a67e68dc5c8281d9608136d3d7ca1b282213e4ac # v2.0.1 |
Contributor
There was a problem hiding this comment.
why not the latest (v2.2.1)
Contributor
Author
There was a problem hiding this comment.
No good reason, it was just the one used by Teodor, changed it now in both workflows.
Signed-off-by: Zlata Stefanovic <zlata.stefanovic@databricks.com>
andrijast-db
approved these changes
Jun 23, 2026
teodordelibasic-db
approved these changes
Jun 23, 2026
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.
What changes are proposed in this pull request?
WHAT: Builds the C FFI library (
rust/ffi) for Linux musl targets so it works on Alpine / musl-based containers:x86_64-unknown-linux-muslandaarch64-unknown-linux-muslmatrix rows to.github/workflows/release-ffi.yml, cross-compiled withcargo-zigbuildon the existingdatabricks-protected-runner-group / linux-ubuntu-latestrunners (no dedicated Alpine runner). Builds withRUSTFLAGS=-C target-feature=-crt-staticso the libs link musl dynamically, which is correct for dynamically-linked Alpine hosts. The crate'scrate-type = ["staticlib", "cdylib"]means onecargo zigbuildrun emits bothlibzerobus_ffi.aandlibzerobus_ffi.so. Artifacts upload asffi-linux-musl-x86_64/ffi-linux-musl-aarch64.rust/ffi/README.md.rust/ffi/NEXT_CHANGELOG.mdentry.WHY: The FFI library was previously built only for glibc targets, so the glibc-linked artifacts do not load or link on Alpine. This is the FFI counterpart to #324 (Java request), which was implemented for JNI in #347 but left the FFI build unchanged — so direct C/C++ consumers on Alpine were still unsupported. This PR mirrors the #347 workflow approach for FFI.
The Java side of #347 also had a runtime
NativeLoader(it bundles all platforms in one JAR and selects the lib at load time). The FFI library has no runtime loader — C/C++ consumers link thelinux-musl-*directory they download directly — so there is no analogous code to add here. Per scope decision, therelease-go.yml/ Go-on-Alpine path (which needs cgo build-tag plumbing to distinguish musl from glibc) is left to a separate change.Fixes #411
How is this tested?
Triggered & passed - https://github.com/databricks/zerobus-sdk/actions/runs/28018404039
CI/packaging change only — no unit-testable code paths. Validated the
release-ffi.ymlYAML parses and that the new matrix rows reuse the existingPrepare artifacts/Upload artifactsteps (keyed offmatrix.artifact_dir/static_lib/dynamic_lib). The workflow isworkflow_dispatch-triggered; a manualrelease-ffi.ymlrun is the end-to-end verification, mirroring how #347 was validated via a triggeredrelease-jni.ymlrun.