[PATCH] Add a flag for overriding default JNI library search path (original) (raw)
Jakub Vaněk linuxtardis at gmail.com
Sun Nov 25 15:51:32 UTC 2018
- Previous message (by thread): [PATCH] Append assembler flags on ARM targets
- Next message (by thread): [PATCH] Add a flag for overriding default JNI library search path
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 DEFAULT_LIBPATH 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 DEFAULT_LIBPATH #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
--with-hotspot-libpath=<path>
- Override the default runtime library
- search path. Use this if you want to override where HotSpot
- for JNI libraries by default.
- AC_ARG_WITH([hotspot-libpath], [AS_HELP_STRING([--with-hotspot- libpath],
[Override the default runtime library search path.])])
- AC_MSG_CHECKING([for custom hotspot library path])
- if test "x${with_hotspot_libpath}" = "x"; then
- AC_MSG_RESULT([no])
- HOTSPOT_OVERRIDE_LIBPATH=""
- else
- AC_MSG_RESULT(${with_hotspot_libpath})
- HOTSPOT_OVERRIDE_LIBPATH=${with_hotspot_libpath}
- fi
- AC_SUBST(HOTSPOT_OVERRIDE_LIBPATH) +])
- 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 @@
BUILD_GTEST := @BUILD_GTEST@ Control wether Hotspot builds gtest tests
- JVM_CFLAGS += -DOVERRIDE_LIBPATH='"$(HOTSPOT_OVERRIDE_LIBPATH)"' +endif diff --git a/src/hotspot/os/aix/os_aix.cpp b/src/hotspot/os/aix/os_aix.cpp --- a/src/hotspot/os/aix/os_aix.cpp +++ b/src/hotspot/os/aix/os_aix.cpp @@ -541,7 +541,11 @@
- #define DEFAULT_LIBPATH "/lib:/usr/lib"
- #define DEFAULT_LIBPATH OVERRIDE_LIBPATH
- #define DEFAULT_LIBPATH "/lib:/usr/lib"
- #ifndef OVERRIDE_LIBPATH
- #define DEFAULT_LIBPATH "/lib:/usr/lib"
- #else
- #define DEFAULT_LIBPATH OVERRIDE_LIBPATH
- #endif
- #define DEFAULT_LIBPATH "/usr/lib64:/lib64:/lib:/usr/lib"
- #if defined(AMD64) || (defined(_LP64) && defined(SPARC)) ||
- #define DEFAULT_LIBPATH "/usr/lib64:/lib64:/lib:/usr/lib"
- #else
- #define DEFAULT_LIBPATH "/lib:/usr/lib"
- #endif
- #define DEFAULT_LIBPATH "/lib:/usr/lib"
- #define DEFAULT_LIBPATH OVERRIDE_LIBPATH
- Previous message (by thread): [PATCH] Append assembler flags on ARM targets
- Next message (by thread): [PATCH] Add a flag for overriding default JNI library search path
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
<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.)
searches
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 @@
HOTSPOT_SETUP_JVM_FEATURES
+# handle custom hotspot library path path +HOTSPOT_CUSTOM_LIBPATH + ###################################################################### ######### #
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 @@
AC_SUBST(BUILD_GTEST) ]) + +###################################################################### ######### +# Set up custom hotspot library path +# +AC_DEFUN_ONCE([HOTSPOT_CUSTOM_LIBPATH], +[
+# Allow overriding the default hotspot library path +HOTSPOT_OVERRIDE_LIBPATH := @HOTSPOT_OVERRIDE_LIBPATH@ +
Control use of precompiled header in hotspot libjvm build
USE_PRECOMPILED_HEADER := @USE_PRECOMPILED_HEADER@
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 ($(USE_PRECOMPILED_HEADER), false) JVM_CFLAGS += -DDONT_USE_PRECOMPILED_HEADER endif + +ifneq ($(HOTSPOT_OVERRIDE_LIBPATH), )
void os::init_system_properties_values() {
-#define DEFAULT_LIBPATH "/lib:/usr/lib" +#ifndef OVERRIDE_LIBPATH
+#else
+#endif #define EXTENSIONS_DIR "/lib/ext"
// Buffer that fits several sprintfs. diff --git a/src/hotspot/os/bsd/os_bsd.cpp b/src/hotspot/os/bsd/os_bsd.cpp --- a/src/hotspot/os/bsd/os_bsd.cpp +++ b/src/hotspot/os/bsd/os_bsd.cpp @@ -316,7 +316,11 @@ // ... // 7: The default directories, normally /lib and /usr/lib. #ifndef DEFAULT_LIBPATH
#endif
// Base path of extensions installed on the system. diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.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)
+#ifndef OVERRIDE_LIBPATH
defined(PPC64) || defined(S390)
#else
#endif
// Base path of extensions installed on the system.