From 82346d2c30d4e70963527bf726cdfb031d86c6e2 Mon Sep 17 00:00:00 2001 From: Andy Grove Date: Tue, 21 Apr 2026 17:11:11 -0600 Subject: [PATCH 1/2] ci: force GNU ld on Linux to fix -ljvm linker error Recent Rust stable defaults to rust-lld as the linker on x86_64-unknown-linux-gnu. rust-lld cannot resolve -ljvm against the Zulu JDK layout installed by actions/setup-java, producing: rust-lld: error: unable to find library -ljvm GNU ld resolves it fine. Add -Clink-arg=-fuse-ld=bfd via workflow-level RUSTFLAGS so every cargo invocation in Linux CI picks GNU ld, and extend the per-step RUSTFLAGS values that already set -Ctarget-cpu to include the same flag (step-level env overrides workflow-level). --- .github/workflows/iceberg_spark_test.yml | 6 +++++- .github/workflows/pr_build_linux.yml | 6 +++++- .github/workflows/spark_sql_test.yml | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/iceberg_spark_test.yml b/.github/workflows/iceberg_spark_test.yml index 4d6200c7ad..67fe2eea55 100644 --- a/.github/workflows/iceberg_spark_test.yml +++ b/.github/workflows/iceberg_spark_test.yml @@ -55,6 +55,10 @@ on: env: RUST_VERSION: stable RUST_BACKTRACE: 1 + # Force GNU ld on Linux: recent Rust stable defaults to rust-lld on + # x86_64-unknown-linux-gnu, and rust-lld cannot resolve -ljvm against the + # Zulu JDK layout installed by setup-java. Keep bfd for all cargo invocations. + RUSTFLAGS: "-Clink-arg=-fuse-ld=bfd" jobs: # Build native library once and share with all test jobs @@ -88,7 +92,7 @@ jobs: run: | cd native && cargo build --profile ci env: - RUSTFLAGS: "-Ctarget-cpu=x86-64-v3" + RUSTFLAGS: "-Ctarget-cpu=x86-64-v3 -Clink-arg=-fuse-ld=bfd" - name: Save Cargo cache uses: actions/cache/save@v5 diff --git a/.github/workflows/pr_build_linux.yml b/.github/workflows/pr_build_linux.yml index d93f85c0fc..4823153f7b 100644 --- a/.github/workflows/pr_build_linux.yml +++ b/.github/workflows/pr_build_linux.yml @@ -49,6 +49,10 @@ on: env: RUST_VERSION: stable RUST_BACKTRACE: 1 + # Force GNU ld on Linux: recent Rust stable defaults to rust-lld on + # x86_64-unknown-linux-gnu, and rust-lld cannot resolve -ljvm against the + # Zulu JDK layout installed by setup-java. Keep bfd for all cargo invocations. + RUSTFLAGS: "-Clink-arg=-fuse-ld=bfd" jobs: @@ -166,7 +170,7 @@ jobs: # (no LTO, parallel codegen) cargo build --profile ci env: - RUSTFLAGS: "-Ctarget-cpu=x86-64-v3" + RUSTFLAGS: "-Ctarget-cpu=x86-64-v3 -Clink-arg=-fuse-ld=bfd" - name: Upload native library uses: actions/upload-artifact@v7 diff --git a/.github/workflows/spark_sql_test.yml b/.github/workflows/spark_sql_test.yml index e1fddda9b0..44780a42bc 100644 --- a/.github/workflows/spark_sql_test.yml +++ b/.github/workflows/spark_sql_test.yml @@ -61,6 +61,10 @@ on: env: RUST_VERSION: stable RUST_BACKTRACE: 1 + # Force GNU ld on Linux: recent Rust stable defaults to rust-lld on + # x86_64-unknown-linux-gnu, and rust-lld cannot resolve -ljvm against the + # Zulu JDK layout installed by setup-java. Keep bfd for all cargo invocations. + RUSTFLAGS: "-Clink-arg=-fuse-ld=bfd" jobs: @@ -95,7 +99,7 @@ jobs: cd native cargo build --profile ci env: - RUSTFLAGS: "-Ctarget-cpu=x86-64-v3" + RUSTFLAGS: "-Ctarget-cpu=x86-64-v3 -Clink-arg=-fuse-ld=bfd" - name: Upload native library uses: actions/upload-artifact@v7 From 5ab84708d63018a96d91e7bbe3bf08d2eb40b3e5 Mon Sep 17 00:00:00 2001 From: Andy Grove Date: Tue, 21 Apr 2026 17:23:55 -0600 Subject: [PATCH 2/2] ci: fix stale macOS Cargo cache baking wrong JVM path into link args The macOS Build Native Library job fails with: ld: warning: search path '.../Java_Zulu_jdk/17.0.18-8/aarch64/lib/server' not found ld: library 'jvm' not found native/fs-hdfs/build.rs resolves JAVA_HOME at build time and emits `cargo:rustc-link-search=native=$JAVA_HOME/lib/server` plus a `-Wl,-rpath,$JAVA_HOME/lib/server` link arg. Those paths are baked into the compiled rlib. Because the build script does not declare any `rerun-if-env-changed=JAVA_HOME`, Cargo has no input that lets it detect a JDK swap, and a cache restored from a previous run (where setup-java installed a different Zulu patch version) keeps the stale paths. Two changes: - native/fs-hdfs/build.rs: add `cargo:rerun-if-env-changed=JAVA_HOME` so Cargo reruns the build script and refreshes link args whenever the resolved JDK changes. This is the robust fix and applies on every host, not just CI. - .github/workflows/pr_build_macos.yml: bump the cache key prefix to `cargo-ci-v2` so the existing macOS cache, built against a JDK path that no longer exists on the runner, is discarded once. After this one-shot bust, the build.rs change handles future JDK updates on its own. --- .github/workflows/pr_build_macos.yml | 6 +++--- native/fs-hdfs/build.rs | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr_build_macos.yml b/.github/workflows/pr_build_macos.yml index deaf595604..6d6ac14ec9 100644 --- a/.github/workflows/pr_build_macos.yml +++ b/.github/workflows/pr_build_macos.yml @@ -89,9 +89,9 @@ jobs: ~/.cargo/registry ~/.cargo/git native/target - key: ${{ runner.os }}-cargo-ci-${{ hashFiles('native/**/Cargo.lock', 'native/**/Cargo.toml') }}-${{ hashFiles('native/**/*.rs') }} + key: ${{ runner.os }}-cargo-ci-v2-${{ hashFiles('native/**/Cargo.lock', 'native/**/Cargo.toml') }}-${{ hashFiles('native/**/*.rs') }} restore-keys: | - ${{ runner.os }}-cargo-ci-${{ hashFiles('native/**/Cargo.lock', 'native/**/Cargo.toml') }}- + ${{ runner.os }}-cargo-ci-v2-${{ hashFiles('native/**/Cargo.lock', 'native/**/Cargo.toml') }}- - name: Build native library (CI profile) run: | @@ -117,7 +117,7 @@ jobs: ~/.cargo/registry ~/.cargo/git native/target - key: ${{ runner.os }}-cargo-ci-${{ hashFiles('native/**/Cargo.lock', 'native/**/Cargo.toml') }}-${{ hashFiles('native/**/*.rs') }} + key: ${{ runner.os }}-cargo-ci-v2-${{ hashFiles('native/**/Cargo.lock', 'native/**/Cargo.toml') }}-${{ hashFiles('native/**/*.rs') }} macos-aarch64-test: needs: build-native diff --git a/native/fs-hdfs/build.rs b/native/fs-hdfs/build.rs index 23f93b7114..73b75e5c74 100644 --- a/native/fs-hdfs/build.rs +++ b/native/fs-hdfs/build.rs @@ -120,6 +120,12 @@ fn get_build_flags() -> Vec { fn get_java_dependency() -> Vec { let mut result = vec![]; + // Re-run when the JDK changes. The resolved jvm_lib_location below is + // baked into the crate's link args, so a cache restored against a previous + // JDK install (e.g. CI runners where setup-java floats Zulu patch + // versions) would otherwise hand the linker -L paths that no longer exist. + println!("cargo:rerun-if-env-changed=JAVA_HOME"); + // Include directories let java_home = java_locator::locate_java_home() .expect("JAVA_HOME could not be found, trying setting the variable manually");