Skip to content

Conversation

EmilyFlarionIO
Copy link

This resolves an issue where header files are not found when compiling using the default JDK8 installation on Ubuntu(A problem which plague any JDK8 installation that does not set JAVA_HOME, I would presume), since java-locator was searching for the Java Runtime binary, which on JDK8 was in the jre subfolder instead of the JDK root, whose bin folder only held a symlink.
Using the locate-jdk-only feature, java-locator searches for the javac binary instead of java, which resolves this problem.
In order to not break the build for systems that only have the JRE installed and just want to link against libhdfs, I've attached the locate-jdk-only feature to the vendored feature, where we would need the JDK anyway.
This leaves an issue where the problem could still occur if libhdfs is not found and we only build it as a fallback, I've added a warning message there recommending enabling the "vendored" feature in case of header troubles.

You can read more in the java-locator PR:
astonbitecode/java-locator#7

@EmilyFlarionIO
Copy link
Author

@Xuanwo I have fixed the CI checks, if needed I can split the changes

@@ -28,11 +28,16 @@ fn find_jvm() -> Result<()> {
println!("cargo:rustc-link-lib=jvm");
println!("cargo:rustc-link-search=native={jvm_path}");

// Add JVM to rpath
println!("cargo:rustc-link-arg=-Wl,-rpath,{jvm_path}");
Copy link
Author

@EmilyFlarionIO EmilyFlarionIO Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rust specs ensures this does not propagate upwards(unless it is a cdylib, which will then have this in its RPATH), so this is not a security concern, only relevant for tests and/or binaries from this crate.

It is also why we export the used path as metadata below, if another crate does need it, it can use it directly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant