8214332: Add a flag for overriding default JNI library search path

Reviewed-by: erikj, dholmes
This commit is contained in:
Jakub Vanek 2018-11-28 22:29:35 -05:00 committed by David Holmes
parent 9aff87efc9
commit b2bf2d252b
8 changed files with 58 additions and 5 deletions

View File

@ -464,6 +464,10 @@ CC: Sun C++ 5.13 SunOS_i386 151846-10 2015/10/30</code></pre>
<li><code>--with-jvm-features=&lt;feature&gt;[,&lt;feature&gt;...]</code> - Use the specified JVM features when building Hotspot. The list of features will be enabled on top of the default list. For the <code>custom</code> JVM variant, this default list is empty. A complete list of available JVM features can be found using <code>bash configure --help</code>.</li> <li><code>--with-jvm-features=&lt;feature&gt;[,&lt;feature&gt;...]</code> - Use the specified JVM features when building Hotspot. The list of features will be enabled on top of the default list. For the <code>custom</code> JVM variant, this default list is empty. A complete list of available JVM features can be found using <code>bash configure --help</code>.</li>
<li><code>--with-target-bits=&lt;bits&gt;</code> - Create a target binary suitable for running on a <code>&lt;bits&gt;</code> 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 <em>reduced</em> build.)</li> <li><code>--with-target-bits=&lt;bits&gt;</code> - Create a target binary suitable for running on a <code>&lt;bits&gt;</code> 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 <em>reduced</em> build.)</li>
</ul> </ul>
<p>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 <code>java.library.path</code> property.</p>
<ul>
<li><code>--with-jni-libpath=&lt;path&gt;</code> - Use the specified path as a default when searching for runtime libraries.</li>
</ul>
<h4 id="configure-arguments-for-native-compilation">Configure Arguments for Native Compilation</h4> <h4 id="configure-arguments-for-native-compilation">Configure Arguments for Native Compilation</h4>
<ul> <ul>
<li><code>--with-devkit=&lt;path&gt;</code> - Use this devkit for compilers, tools and resources</li> <li><code>--with-devkit=&lt;path&gt;</code> - Use this devkit for compilers, tools and resources</li>

View File

@ -662,6 +662,14 @@ features, use `bash configure --help=short` instead.)
platform, instead of doing a full cross-compile. (This is known as a platform, instead of doing a full cross-compile. (This is known as a
*reduced* build.) *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 `java.library.path` property.
* `--with-jni-libpath=<path>` - Use the specified path as a default
when searching for runtime libraries.
#### Configure Arguments for Native Compilation #### Configure Arguments for Native Compilation
* `--with-devkit=<path>` - Use this devkit for compilers, tools and resources * `--with-devkit=<path>` - Use this devkit for compilers, tools and resources

View File

@ -244,6 +244,28 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_JDK_OPTIONS],
COPYRIGHT_YEAR=`$DATE +'%Y'` COPYRIGHT_YEAR=`$DATE +'%Y'`
fi fi
AC_SUBST(COPYRIGHT_YEAR) AC_SUBST(COPYRIGHT_YEAR)
# Override default library path
AC_ARG_WITH([jni-libpath], [AS_HELP_STRING([--with-jni-libpath],
[override default JNI library search path])])
AC_MSG_CHECKING([for jni library path])
if test "x${with_jni_libpath}" = "x" || test "x${with_jni_libpath}" = "xno"; then
AC_MSG_RESULT([default])
elif test "x${with_jni_libpath}" = "xyes"; then
AC_MSG_RESULT([invalid])
AC_MSG_ERROR([The --with-jni-libpath option requires an argument.])
else
HOTSPOT_OVERRIDE_LIBPATH=${with_jni_libpath}
if test "x$OPENJDK_TARGET_OS" != "xlinux" &&
test "x$OPENJDK_TARGET_OS" != "xbsd" &&
test "x$OPENJDK_TARGET_OS" != "xaix"; then
AC_MSG_RESULT([fail])
AC_MSG_ERROR([Overriding JNI library path is supported only on Linux, BSD and AIX.])
fi
AC_MSG_RESULT(${HOTSPOT_OVERRIDE_LIBPATH})
fi
AC_SUBST(HOTSPOT_OVERRIDE_LIBPATH)
]) ])
############################################################################### ###############################################################################

View File

@ -275,6 +275,9 @@ VALID_JVM_VARIANTS := @VALID_JVM_VARIANTS@
# Control wether Hotspot builds gtest tests # Control wether Hotspot builds gtest tests
BUILD_GTEST := @BUILD_GTEST@ BUILD_GTEST := @BUILD_GTEST@
# Allow overriding the default hotspot library path
HOTSPOT_OVERRIDE_LIBPATH := @HOTSPOT_OVERRIDE_LIBPATH@
# Control use of precompiled header in hotspot libjvm build # Control use of precompiled header in hotspot libjvm build
USE_PRECOMPILED_HEADER := @USE_PRECOMPILED_HEADER@ USE_PRECOMPILED_HEADER := @USE_PRECOMPILED_HEADER@

View File

@ -95,3 +95,7 @@ JVM_CFLAGS += \
ifeq ($(USE_PRECOMPILED_HEADER), false) ifeq ($(USE_PRECOMPILED_HEADER), false)
JVM_CFLAGS += -DDONT_USE_PRECOMPILED_HEADER JVM_CFLAGS += -DDONT_USE_PRECOMPILED_HEADER
endif endif
ifneq ($(HOTSPOT_OVERRIDE_LIBPATH), )
JVM_CFLAGS += -DOVERRIDE_LIBPATH='"$(HOTSPOT_OVERRIDE_LIBPATH)"'
endif

View File

@ -541,7 +541,11 @@ query_multipage_support_end:
void os::init_system_properties_values() { void os::init_system_properties_values() {
#ifndef OVERRIDE_LIBPATH
#define DEFAULT_LIBPATH "/lib:/usr/lib" #define DEFAULT_LIBPATH "/lib:/usr/lib"
#else
#define DEFAULT_LIBPATH OVERRIDE_LIBPATH
#endif
#define EXTENSIONS_DIR "/lib/ext" #define EXTENSIONS_DIR "/lib/ext"
// Buffer that fits several sprintfs. // Buffer that fits several sprintfs.

View File

@ -316,7 +316,11 @@ void os::init_system_properties_values() {
// ... // ...
// 7: The default directories, normally /lib and /usr/lib. // 7: The default directories, normally /lib and /usr/lib.
#ifndef DEFAULT_LIBPATH #ifndef DEFAULT_LIBPATH
#ifndef OVERRIDE_LIBPATH
#define DEFAULT_LIBPATH "/lib:/usr/lib" #define DEFAULT_LIBPATH "/lib:/usr/lib"
#else
#define DEFAULT_LIBPATH OVERRIDE_LIBPATH
#endif
#endif #endif
// Base path of extensions installed on the system. // Base path of extensions installed on the system.

View File

@ -323,11 +323,15 @@ void os::init_system_properties_values() {
// 1: ... // 1: ...
// ... // ...
// 7: The default directories, normally /lib and /usr/lib. // 7: The default directories, normally /lib and /usr/lib.
#ifndef OVERRIDE_LIBPATH
#if defined(AMD64) || (defined(_LP64) && defined(SPARC)) || defined(PPC64) || defined(S390) #if defined(AMD64) || (defined(_LP64) && defined(SPARC)) || defined(PPC64) || defined(S390)
#define DEFAULT_LIBPATH "/usr/lib64:/lib64:/lib:/usr/lib" #define DEFAULT_LIBPATH "/usr/lib64:/lib64:/lib:/usr/lib"
#else #else
#define DEFAULT_LIBPATH "/lib:/usr/lib" #define DEFAULT_LIBPATH "/lib:/usr/lib"
#endif #endif
#else
#define DEFAULT_LIBPATH OVERRIDE_LIBPATH
#endif
// Base path of extensions installed on the system. // Base path of extensions installed on the system.
#define SYS_EXT_DIR "/usr/java/packages" #define SYS_EXT_DIR "/usr/java/packages"