fix: emit JDK libjvm search path from core build script to fix -ljvm CI link failures#4868
Merged
Merged
Conversation
The hdfs-sys dependency (pulled in by the default hdfs-opendal feature) links libjvm and bakes an absolute -L path to the JDK libjvm directory into its build-script output, which cargo caches and replays when only downstream crates change. On CI runners where setup-java floats the Zulu patch version, that cached path can disappear and linking libcomet.so fails with "cannot find -ljvm". Add a build script to core (the final cdylib) that emits a search path for the currently resolved JDK, so the linker finds libjvm regardless of a stale path replayed from a dependency's cached build script. Re-run when JAVA_HOME or the resolved directory changes so it self-heals across JDK swaps.
mbutrovich
approved these changes
Jul 8, 2026
mbutrovich
left a comment
Contributor
There was a problem hiding this comment.
I was just starting to look at what broke the builds. Thanks @andygrove!
Contributor
|
Do we still need |
Contributor
Related? #4867 |
Contributor
Currently not used. |
comphead
approved these changes
Jul 8, 2026
comphead
left a comment
Contributor
There was a problem hiding this comment.
Thanks @andygrove hdfs-sys really need JVM runtime lib path, jvmlib.so, wondering how come the path is flaky 🤔 we need to keep in mind to drop this file once we decide to remove local hdfs crate
Member
Author
|
Merged. Thanks @mbutrovich @comphead |
Contributor
If we are going to then we should probably remove it before 1.0 |
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.
Which issue does this PR close?
No dedicated issue. This addresses a repo-wide CI failure where native builds fail at link time with:
It has been hitting
PR Build (Linux),Iceberg Spark SQL Tests, andSpark SQL Testsjobs across open PRs.Rationale for this change
The
hdfs-sysdependency (pulled in by the defaulthdfs-opendalfeature) linkslibjvmand, from its build script, bakes an absolute-Lsearch path to the JDK'slibjvmdirectory. Cargo caches that build-script output and replays it when only downstream crates change, without re-running the build script.CI caches
native/targetkeyed onhashFiles('native/**/*.rs', ...Cargo.toml/lock). When a change does not touch native sources, the same cache is restored. If the runner's JDK has moved in the meantime (setup-javafloats the Zulu patch version, soJAVA_HOME's value can stay the same while the underlying install is swapped), the replayed-Lpath points at a directory that no longer exists, and the final link oflibcomet.sofails withcannot find -ljvm.coreis the crate that produces the finalcdylib, so the fix belongs there: emit a-Lsearch path for the currently resolved JDK at build time. The linker then findslibjvmregardless of any stale path replayed from a dependency's cached build script.What changes are included in this PR?
native/core/build.rsthat:cargo:rustc-link-search=native=$JAVA_HOME/lib/server(thelibjvmlocation for every supported JDK, 11+), andcargo:rerun-if-env-changed=JAVA_HOMEandcargo:rerun-if-changed=<that dir>so the search path is refreshed automatically whenever the JDK is swapped, rather than relying on a cache invalidation.No workflow or dependency changes are needed; the fix is self-contained in the crate that performs the final link, so it applies to every native-build job.
How are these changes tested?
Verbose local build (
cargo build -p datafusion-comet -vv) confirms the core build script now contributes the search path alongside the dependency's:so
-ljvmresolves against the current JDK even when a dependency replays a stale path. The existing native-build and Spark SQL CI jobs exercise the link path that was failing.