Skip to content

Commit 9986587

Browse files
authored
ci: force GNU ld on Linux to fix -ljvm linker error (#4024)
1 parent dae02c0 commit 9986587

5 files changed

Lines changed: 24 additions & 6 deletions

File tree

.github/workflows/iceberg_spark_test.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ on:
5555
env:
5656
RUST_VERSION: stable
5757
RUST_BACKTRACE: 1
58+
# Force GNU ld on Linux: recent Rust stable defaults to rust-lld on
59+
# x86_64-unknown-linux-gnu, and rust-lld cannot resolve -ljvm against the
60+
# Zulu JDK layout installed by setup-java. Keep bfd for all cargo invocations.
61+
RUSTFLAGS: "-Clink-arg=-fuse-ld=bfd"
5862

5963
jobs:
6064
# Build native library once and share with all test jobs
@@ -88,7 +92,7 @@ jobs:
8892
run: |
8993
cd native && cargo build --profile ci
9094
env:
91-
RUSTFLAGS: "-Ctarget-cpu=x86-64-v3"
95+
RUSTFLAGS: "-Ctarget-cpu=x86-64-v3 -Clink-arg=-fuse-ld=bfd"
9296

9397
- name: Save Cargo cache
9498
uses: actions/cache/save@v5

.github/workflows/pr_build_linux.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ on:
4949
env:
5050
RUST_VERSION: stable
5151
RUST_BACKTRACE: 1
52+
# Force GNU ld on Linux: recent Rust stable defaults to rust-lld on
53+
# x86_64-unknown-linux-gnu, and rust-lld cannot resolve -ljvm against the
54+
# Zulu JDK layout installed by setup-java. Keep bfd for all cargo invocations.
55+
RUSTFLAGS: "-Clink-arg=-fuse-ld=bfd"
5256

5357
jobs:
5458

@@ -166,7 +170,7 @@ jobs:
166170
# (no LTO, parallel codegen)
167171
cargo build --profile ci
168172
env:
169-
RUSTFLAGS: "-Ctarget-cpu=x86-64-v3"
173+
RUSTFLAGS: "-Ctarget-cpu=x86-64-v3 -Clink-arg=-fuse-ld=bfd"
170174

171175
- name: Upload native library
172176
uses: actions/upload-artifact@v7

.github/workflows/pr_build_macos.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ jobs:
8989
~/.cargo/registry
9090
~/.cargo/git
9191
native/target
92-
key: ${{ runner.os }}-cargo-ci-${{ hashFiles('native/**/Cargo.lock', 'native/**/Cargo.toml') }}-${{ hashFiles('native/**/*.rs') }}
92+
key: ${{ runner.os }}-cargo-ci-v2-${{ hashFiles('native/**/Cargo.lock', 'native/**/Cargo.toml') }}-${{ hashFiles('native/**/*.rs') }}
9393
restore-keys: |
94-
${{ runner.os }}-cargo-ci-${{ hashFiles('native/**/Cargo.lock', 'native/**/Cargo.toml') }}-
94+
${{ runner.os }}-cargo-ci-v2-${{ hashFiles('native/**/Cargo.lock', 'native/**/Cargo.toml') }}-
9595
9696
- name: Build native library (CI profile)
9797
run: |
@@ -117,7 +117,7 @@ jobs:
117117
~/.cargo/registry
118118
~/.cargo/git
119119
native/target
120-
key: ${{ runner.os }}-cargo-ci-${{ hashFiles('native/**/Cargo.lock', 'native/**/Cargo.toml') }}-${{ hashFiles('native/**/*.rs') }}
120+
key: ${{ runner.os }}-cargo-ci-v2-${{ hashFiles('native/**/Cargo.lock', 'native/**/Cargo.toml') }}-${{ hashFiles('native/**/*.rs') }}
121121

122122
macos-aarch64-test:
123123
needs: build-native

.github/workflows/spark_sql_test.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ on:
6161
env:
6262
RUST_VERSION: stable
6363
RUST_BACKTRACE: 1
64+
# Force GNU ld on Linux: recent Rust stable defaults to rust-lld on
65+
# x86_64-unknown-linux-gnu, and rust-lld cannot resolve -ljvm against the
66+
# Zulu JDK layout installed by setup-java. Keep bfd for all cargo invocations.
67+
RUSTFLAGS: "-Clink-arg=-fuse-ld=bfd"
6468

6569
jobs:
6670

@@ -95,7 +99,7 @@ jobs:
9599
cd native
96100
cargo build --profile ci
97101
env:
98-
RUSTFLAGS: "-Ctarget-cpu=x86-64-v3"
102+
RUSTFLAGS: "-Ctarget-cpu=x86-64-v3 -Clink-arg=-fuse-ld=bfd"
99103

100104
- name: Upload native library
101105
uses: actions/upload-artifact@v7

native/fs-hdfs/build.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ fn get_build_flags() -> Vec<String> {
120120
fn get_java_dependency() -> Vec<String> {
121121
let mut result = vec![];
122122

123+
// Re-run when the JDK changes. The resolved jvm_lib_location below is
124+
// baked into the crate's link args, so a cache restored against a previous
125+
// JDK install (e.g. CI runners where setup-java floats Zulu patch
126+
// versions) would otherwise hand the linker -L paths that no longer exist.
127+
println!("cargo:rerun-if-env-changed=JAVA_HOME");
128+
123129
// Include directories
124130
let java_home = java_locator::locate_java_home()
125131
.expect("JAVA_HOME could not be found, trying setting the variable manually");

0 commit comments

Comments
 (0)