build: strip release cdylib to shrink the JNI native library - #8314
Merged
Conversation
The release JNI cdylib currently ships unstripped, retaining the .symtab/.strtab symbol tables (~57 MB on linux-x86-64). strip = true removes them. JNI method resolution uses the dynamic symbol table (.dynsym), which strip preserves -- all exported Java_* symbols remain, so this is functionally safe. Measured on linux-x86-64: liblance_jni.so 278.35 MB -> 221.0 MB (-57.35 MB, -20.6%). Because java/lance-jni is excluded from the root workspace, this profile applies to the crate build directly. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
✅ Gate recommendation: approve.
The standalone release profile applies to both published Linux and macOS builds, and Cargo’s symbol stripping preserves the dynamic export table used by JNI. Keeping the policy in Cargo is simpler and less drift-prone than platform-specific post-link stripping.
Xuanwo
approved these changes
Aug 7, 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
Add a
[profile.release]tojava/lance-jni/Cargo.tomlthat strips symbols from the release build:Because
java/lance-jniis excluded from the root workspace (see the rootCargo.toml), this profile applies to the crate's release build directly.Why
The release JNI
cdylibcurrently ships unstripped, retaining the.symtab/.strtabsymbol tables. These add tens of MB to the shipped shared library and provide no runtime benefit for the loaded native library.Measured on linux-x86-64:
liblance_jni.soThe removed weight is almost entirely the symbol tables (
.symtab≈ 12.5 MB,.strtab≈ 44.8 MB); the release build already emits no DWARF (.debug_*sections are absent).Why this is safe
strip = trueremoves.symtab/.strtab(the regular symbol tables) but preserves the dynamic symbol table (.dynsym). The JVM resolves native methods through.dynsym, so every exportedJava_*symbol is retained and native-method lookup is unaffected — verified that allJava_*exports remain resolvable (nm -D) after stripping. Only unused symbol metadata is dropped; code and data are untouched.Consistency with existing profiles
This aligns the Java release artifact with how the project already treats shipped vs. debuggable builds:
maturin --strip(full strip) in.github/workflows/pypi-publish.yml— the Java JNIcdylibsimply never got the equivalent.[profile.bench]setsstrip = false(keep symbols where you profile);dev/ciusestrip = \"debuginfo\". Stripping the release JNI artifact is the missing counterpart.Debuggability trade-off (considered)
After stripping, a native crash backtrace shows raw addresses rather than function names. In practice the release build already emits no DWARF, so even today it yields function names only (from
.symtab), never line numbers — the same trade-off the Python wheels already accept.If out-of-band symbolication is later desired, the clean path is split debug info rather than shipping the symbol tables in every artifact: set
debug = \"line-tables-only\"+split-debuginfo = \"packed\"+strip = \"symbols\", which produces an identically-sized stripped.soplus a separate.dwpto archive. That is a build-pipeline change (it needsdebugenabled and somewhere to store the.dwp), so it is out of scope here; this PR keeps the minimal, zero-infrastrip = true.