[PATCH] Add a flag for overriding default JNI library search path (original) (raw)

Erik Joelsson erik.joelsson at oracle.com
Mon Nov 26 17:06:22 UTC 2018


Hello,

Looks reasonable. In hotspot.m4, we usually add explicit error messages for configure parameters having the values "yes" or "no", which are the default values if the user just provides "--with-hotspot-libpath" or "--without-hotspot-libpath". Then we print something like "--with-hotspot-libpath requires a value".

/Erik

On 2018-11-25 07:51, Jakub Vaněk wrote:

Hi all,

this patch provides a way how to override where Hotspot searches for libraries by default. This specifically affects JNI libraries To achieve this, a new configure flag is added: --with-hotspot-libpath. When this option is specified, the path is passed to the os*.cpp files, where it overrides the existing DEFAULTLIBPATH string. I tried to follow the way FreeType and other flags are specified. The goal of this patch is to eliminate Linux distribution-specific patches targetted at doing this. In particular, this patch was inspired by Debian/Ubuntu solution. For example, this is the libpath that is used on armel: /usr/lib/arm-linux-gnueabi/jni:/lib/arm-linux-gnueabi:/usr/lib/arm- linux-gnueabi:/usr/lib/jni:/lib:/usr/lib For now, it is possible to override the path only on Linux, BSD and AIX. Other platforms don't have the DEFAULTLIBPATH #define. I tried building OpenJDK locally with the flag and it worked. Thanks, Jakub # HG changeset patch # User Jakub Vaněk <linuxtardis at gmail.com> # Date 1543089715 -3600 # Sat Nov 24 21:01:55 2018 +0100 # Node ID 2fbd203937c0a42439a48c9c5b505f239a8832af # Parent 30a02b4e6c06e874ec8735dedb7e894844b1d627 Add a flag 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 @@ -463,6 +463,7 @@

  • --with-jvm-
  • variants=[,...] - Build the specified variant (or variants) of Hotspot. Valid variants are: server, client, minimal, core, zero, custom. Note that not all variants are possible to combine in a single build.
  • --with-jvm-
  • features=[,...] - Use the specified JVM features when building Hotspot. The list of features will be enabled on top of the default list. For the custom JVM variant, this default list is empty. A complete list of available JVM features can be found using bash configure --help.
  • --with-target-bits= - Create a target
  • binary suitable for running on a platform. 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.) +
  • --with-hotspot-libpath= - Override the
  • default runtime library search path. Use this if you want to override where HotSpot searches for JNI libraries by default.

    Configure

    Arguments for Native Compilation
      diff --git a/doc/building.md b/doc/building.md --- a/doc/building.md +++ b/doc/building.md @@ -661,6 +661,9 @@ on a <bits> platform. 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.) + * --with-hotspot-libpath=<path> - Override the default runtime library + search path. Use this if you want to override where HotSpot searches + for JNI libraries by default. #### Configure Arguments for Native Compilation diff --git a/make/autoconf/configure.ac b/make/autoconf/configure.ac --- a/make/autoconf/configure.ac +++ b/make/autoconf/configure.ac @@ -225,6 +225,9 @@ HOTSPOTSETUPJVMFEATURES +# handle custom hotspot library path path +HOTSPOTCUSTOMLIBPATH + ###################################################################### ######### # # We need to do some final tweaking, when everything else is done. diff --git a/make/autoconf/hotspot.m4 b/make/autoconf/hotspot.m4 --- a/make/autoconf/hotspot.m4 +++ b/make/autoconf/hotspot.m4 @@ -615,3 +615,23 @@ ACSUBST(BUILDGTEST) ]) + +###################################################################### ######### +# Set up custom hotspot library path +# +ACDEFUNONCE([HOTSPOTCUSTOMLIBPATH], +[ + ACARGWITH([hotspot-libpath], [ASHELPSTRING([--with-hotspot- libpath], + [Override the default runtime library search path.])]) + + ACMSGCHECKING([for custom hotspot library path]) + if test "x${withhotspotlibpath}" = "x"; then + ACMSGRESULT([no]) + HOTSPOTOVERRIDELIBPATH="" + else + ACMSGRESULT(${withhotspotlibpath}) + HOTSPOTOVERRIDELIBPATH=${withhotspotlibpath} + 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.



      More information about the build-dev mailing list