[PATCH v2] Add a flag for overriding default JNI library search path (original) (raw)
David Holmes david.holmes at oracle.com
Wed Nov 28 20:54:08 UTC 2018
- Previous message (by thread): [PATCH v2] Add a flag for overriding default JNI library search path
- Next message (by thread): [PATCH v3] 8214332: Add a flag for overriding default JNI library search path
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi Jakub,
Are you ready to have this pushed? I can sponsor it if so.
David
On 27/11/2018 1:36 pm, David Holmes wrote:
Hi Jakub,
I have filed: https://bugs.openjdk.java.net/browse/JDK-8214332 for this issue. On 27/11/2018 6:51 am, Jakub Vaněk wrote: Hi all,
I updated the original patch to address some issues. * The option is documented to work only on Linux, BSD, AIX. * Autoconf code now checks if this operation is supported on the target platform* Autoconf code is moved to jdk-options.m4, where it mirrors how --with-cacerts-file option was specified. * The option isn't called --with-hotspot-libpath anymore, but rather --with-jni-libpath, to indicate the intended usage. That all seems fine to me - thanks. I tried using dlinfo() on Ubuntu to get the library path. The results are the following: /lib/x8664-linux-gnu /usr/lib/x8664-linux-gnu /lib /usr/lib This way of doing it looks interesting, because if /jni is appended to the path, a Debian-like path can be synthesized and it could be consistent across distributions. However, dlinfo() is not universally supported: https://www.gnu.org/software/gnulib/manual/htmlnode/dlinfo.html In particular, Android doesn't support it (not counting some BSDs and AIX). This could be avoided by falling back to the old behavior there. Should I try to implement it also that way? Thanks for looking at it. We'd probably have to investigate in a lot more detail before we could switch over to try and use this. May be worth persuing in a future RFE (Request for Enhancement). Thanks, David Thanks, Jakub # HG changeset patch # User Jakub Vaněk <linuxtardis at gmail.com> # Date 1543260470 -3600 # Mon Nov 26 20:27:50 2018 +0100 # Node ID 218a4f07e539efade7404093508e94c7ed02b177 # Parent e017d2f176d0119cdc70c9f2ee98e78c0c13f0c7 Add an option for overriding default JNI library search path diff --git a/doc/building.html b/doc/building.html --- a/doc/building.html +++ b/doc/building.html @@ -464,6 +464,10 @@
+- Use the specified JVM features when building Hotspot. The list of features will be enabled on top of the default list. For the --with-jvm-features=[,...]
custom
JVM variant, this default list is empty. A complete list of available JVM features can be found usingbash
configure --help.binary suitable for running on a --with-target-bits=
- Create a targetplatform. Use this to create 32-bit output on a 64-bit build platform, instead of doing a full cross-compile. (This is known as a reduced build.) +
On Linux, BSD and AIX, it is possible to override where Java by
default searches for runtime/JNI libraries. This can be useful in situations where there is a special shared directory for system JNI libraries. This setting can in turn be overriden at runtime by setting thejava.library.path
property.+
path as a default when searching for runtime libraries. + --with-jni-libpath=
- Use the specifiedConfigure
Arguments for Native Compilation
compilers, tools and resources diff --git a/doc/building.md b/doc/building.md --- a/doc/building.md +++ b/doc/building.md @@ -662,6 +662,14 @@ platform, instead of doing a full cross-compile. (This is known as a reduced build.) +On Linux, BSD and AIX, it is possible to override where Java by default +searches for runtime/JNI libraries. This can be useful in situations where +there is a special shared directory for system JNI libraries. This setting +can in turn be overriden at runtime by setting the --with-devkit=
- Use this devkit forjava.library.path
property. + + *--with-jni-libpath=<path>
- Use the specified path as a default + when searching for runtime libraries. + #### Configure Arguments for Native Compilation *--with-devkit=<path>
- Use this devkit for compilers, tools and resources diff --git a/make/autoconf/jdk-options.m4 b/make/autoconf/jdk-options.m4 --- a/make/autoconf/jdk-options.m4 +++ b/make/autoconf/jdk-options.m4 @@ -244,6 +244,25 @@ COPYRIGHTYEAR=$DATE +'%Y'
fi ACSUBST(COPYRIGHTYEAR) + + # Override default library path + ACARGWITH([jni-libpath], [ASHELPSTRING([--with-jni-libpath], + [override default JNI library search path])]) + ACMSGCHECKING([for jni library path]) + if test "x${withjnilibpath}" == "x"; then + ACMSGRESULT([default]) + else + HOTSPOTOVERRIDELIBPATH=${withjnilibpath} + if test "x$OPENJDKTARGETOS" != "xlinux" && + test "x$OPENJDKTARGETOS" != "xbsd" && + test "x$OPENJDKTARGETOS" != "xaix"; then + ACMSGRESULT([fail]) + ACMSGERROR([Overriding JNI library path is supported only on Linux, BSD and AIX.]) + fi + ACMSGRESULT(${HOTSPOTOVERRIDELIBPATH}) + fi + ACSUBST(HOTSPOTOVERRIDELIBPATH) + ]) ############################################################################### diff --git a/make/autoconf/spec.gmk.in b/make/autoconf/spec.gmk.in --- a/make/autoconf/spec.gmk.in +++ b/make/autoconf/spec.gmk.in @@ -274,6 +274,9 @@ # Control wether Hotspot builds gtest tests BUILDGTEST := @BUILDGTEST@ +# Allow overriding the default hotspot library path +HOTSPOTOVERRIDELIBPATH := @HOTSPOTOVERRIDELIBPATH@ + # Control use of precompiled header in hotspot libjvm build USEPRECOMPILEDHEADER := @USEPRECOMPILEDHEADER@ diff --git a/make/hotspot/lib/JvmFlags.gmk b/make/hotspot/lib/JvmFlags.gmk --- a/make/hotspot/lib/JvmFlags.gmk +++ b/make/hotspot/lib/JvmFlags.gmk @@ -95,3 +95,7 @@ ifeq ($(USEPRECOMPILEDHEADER), false) JVMCFLAGS += -DDONTUSEPRECOMPILEDHEADER endif + +ifneq ($(HOTSPOTOVERRIDELIBPATH), ) + JVMCFLAGS += -DOVERRIDELIBPATH='"$(HOTSPOTOVERRIDELIBPATH)"' +endif diff --git a/src/hotspot/os/aix/osaix.cpp b/src/hotspot/os/aix/osaix.cpp --- a/src/hotspot/os/aix/osaix.cpp +++ b/src/hotspot/os/aix/osaix.cpp @@ -541,7 +541,11 @@ void os::initsystempropertiesvalues() { -#define DEFAULTLIBPATH "/lib:/usr/lib" +#ifndef OVERRIDELIBPATH + #define DEFAULTLIBPATH "/lib:/usr/lib" +#else + #define DEFAULTLIBPATH OVERRIDELIBPATH +#endif #define EXTENSIONSDIR "/lib/ext" // Buffer that fits several sprintfs. diff --git a/src/hotspot/os/bsd/osbsd.cpp b/src/hotspot/os/bsd/osbsd.cpp --- a/src/hotspot/os/bsd/osbsd.cpp +++ b/src/hotspot/os/bsd/osbsd.cpp @@ -316,7 +316,11 @@ // ... // 7: The default directories, normally /lib and /usr/lib. #ifndef DEFAULTLIBPATH - #define DEFAULTLIBPATH "/lib:/usr/lib" + #ifndef OVERRIDELIBPATH + #define DEFAULTLIBPATH "/lib:/usr/lib" + #else + #define DEFAULTLIBPATH OVERRIDELIBPATH + #endif #endif // Base path of extensions installed on the system. diff --git a/src/hotspot/os/linux/oslinux.cpp b/src/hotspot/os/linux/oslinux.cpp --- a/src/hotspot/os/linux/oslinux.cpp +++ b/src/hotspot/os/linux/oslinux.cpp @@ -323,10 +323,14 @@ // 1: ... // ... // 7: The default directories, normally /lib and /usr/lib. -#if defined(AMD64) || (defined(LP64) && defined(SPARC)) || defined(PPC64) || defined(S390) - #define DEFAULTLIBPATH "/usr/lib64:/lib64:/lib:/usr/lib" +#ifndef OVERRIDELIBPATH + #if defined(AMD64) || (defined(LP64) && defined(SPARC)) || defined(PPC64) || defined(S390) + #define DEFAULTLIBPATH "/usr/lib64:/lib64:/lib:/usr/lib" + #else + #define DEFAULTLIBPATH "/lib:/usr/lib" + #endif #else - #define DEFAULTLIBPATH "/lib:/usr/lib" + #define DEFAULTLIBPATH OVERRIDELIBPATH #endif // Base path of extensions installed on the system.
- Previous message (by thread): [PATCH v2] Add a flag for overriding default JNI library search path
- Next message (by thread): [PATCH v3] 8214332: Add a flag for overriding default JNI library search path
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]