From e93369995e29a7805b987efd1eb7ed32a28713fd Mon Sep 17 00:00:00 2001 From: Annabelle Huo Date: Wed, 27 Nov 2019 03:01:33 +0000 Subject: [PATCH] Add OpenSSL related settings to CUSTOM_COMPILER_ENV_VARS `JITServer` needs to be built with `libssl`. By default, it is built against the `OpenSSL` installed on the build machine. The same as when `--enable-jitserver --with-openssl=system` is specified. This change passes the `OpenSSL` build flags from OpenJDK to JIT build environment. - Add `OPENSSL_DIR`, `OPENSSL_CFLAGS`, and `OPENSSL_BUNDLE_LIB_PATH` to `CUSTOM_COMPILER_ENV_VARS` and `CMAKE_ARGS`. - Bundle `libssl` if `--with-openssl=fetched --enable-openssl-bundling` is set. Examples on the supported flags: --enable-jitserver --with-openssl=fetched --enable-jitserver --with-openssl=fetched --enable-openssl-bundling --enable-jitserver --with-openssl=system The JIT build change is addressed in: eclipse/openj9#5789, eclipse/openj9#7846 This is a similar change as ibmruntimes/openj9-openjdk-jdk8#303 Issue: eclipse/openj9#5720 Signed-off-by: Annabelle Huo --- closed/OpenJ9.gmk | 16 ++++++++++++++-- closed/autoconf/custom-hook.m4 | 14 ++++++++++++++ closed/make/copy/Copy-java.base.gmk | 23 ++++++++++++++++++++++- 3 files changed, 50 insertions(+), 3 deletions(-) diff --git a/closed/OpenJ9.gmk b/closed/OpenJ9.gmk index fc193bd0d86..84543e137c9 100644 --- a/closed/OpenJ9.gmk +++ b/closed/OpenJ9.gmk @@ -450,8 +450,20 @@ endif ifeq (true,$(OPENJ9_ENABLE_JITSERVER)) ifneq (true,$(OPENJ9_ENABLE_CMAKE)) CUSTOM_COMPILER_ENV_VARS += JITSERVER_SUPPORT=1 - endif -endif + + ifneq (,$(OPENSSL_CFLAGS)) + CUSTOM_COMPILER_ENV_VARS += OPENSSL_CFLAGS="$(OPENSSL_CFLAGS)" + endif + + ifneq (,$(OPENSSL_DIR)) + CUSTOM_COMPILER_ENV_VARS += OPENSSL_DIR="$(OPENSSL_DIR)" + endif + + ifneq (,$(OPENSSL_BUNDLE_LIB_PATH)) + CUSTOM_COMPILER_ENV_VARS += OPENSSL_BUNDLE_LIB_PATH="$(OPENSSL_BUNDLE_LIB_PATH)" + endif + endif # OPENJ9_ENABLE_CMAKE +endif # OPENJ9_ENABLE_JITSERVER run-preprocessors-j9 : stage-j9 \ $(OUTPUTDIR)/vm/omr/OMR_VERSION_STRING \ diff --git a/closed/autoconf/custom-hook.m4 b/closed/autoconf/custom-hook.m4 index 7fc38b6c54d..1432421801c 100644 --- a/closed/autoconf/custom-hook.m4 +++ b/closed/autoconf/custom-hook.m4 @@ -615,6 +615,20 @@ AC_DEFUN([CONFIGURE_OPENSSL], AC_MSG_CHECKING([if we should bundle openssl]) AC_MSG_RESULT([$BUNDLE_OPENSSL]) + + if test "x$OPENJ9_ENABLE_JITSERVER" = xtrue ; then + if test "x$OPENJDK_TARGET_OS" = xlinux ; then + if test "x$OPENSSL_DIR" != x ; then + AC_MSG_CHECKING([if the required OPENSSL API exists for JITServer in $OPENSSL_DIR]) + if $GREP -q -w SSL_CTX_set_ecdh_auto "$OPENSSL_DIR/include/openssl/ssl.h" 2> /dev/null ; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + AC_MSG_ERROR([SSL_CTX_set_ecdh_auto is required by JITServer]) + fi + fi + fi + fi fi AC_SUBST(OPENSSL_BUNDLE_LIB_PATH) diff --git a/closed/make/copy/Copy-java.base.gmk b/closed/make/copy/Copy-java.base.gmk index b8cafd219e9..ed33d42baf0 100644 --- a/closed/make/copy/Copy-java.base.gmk +++ b/closed/make/copy/Copy-java.base.gmk @@ -87,5 +87,26 @@ ifneq ($(OPENSSL_BUNDLE_LIB_PATH), ) ifeq ($(OPENJDK_BUILD_OS), windows) $(CHMOD) a+rx $@ endif -endif + + ifeq (true,$(OPENJ9_ENABLE_JITSERVER)) + # Copy OpenSSL SSL Lbrary + # To bundle first search for libssl 1.1.x library, if not found, search for 1.0.x + ifeq ($(OPENJDK_TARGET_OS), linux) + OPENSSL_SSL_LIB_NAME = libssl.so.1.1 + ifeq ("$(wildcard $(OPENSSL_BUNDLE_LIB_PATH)/$(OPENSSL_SSL_LIB_NAME))", "") + OPENSSL_SSL_LIB_NAME = libssl.so.1.0.0 + ifeq ("$(wildcard $(OPENSSL_BUNDLE_LIB_PATH)/$(OPENSSL_SSL_LIB_NAME))", "") + OPENSSL_SSL_LIB_NAME = + endif + endif + + ifneq ($(OPENSSL_SSL_LIB_NAME), ) + OPENSSL_SSL_TARGET_LIB = $(LIB_DST_DIR)/$(OPENSSL_SSL_LIB_NAME) + TARGETS += $(OPENSSL_SSL_TARGET_LIB) + $(OPENSSL_SSL_TARGET_LIB) : $(OPENSSL_BUNDLE_LIB_PATH)/$(OPENSSL_SSL_LIB_NAME) + $(call install-file) + endif # OPENSSL_SSL_LIB_NAME + endif # OPENJDK_TARGET_OS + endif # OPENJ9_ENABLE_JITSERVER +endif # OPENSSL_BUNDLE_LIB_PATH ################################################################################