From 365e5f132f91d6fdd095181508f9719c7a6d2751 Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Thu, 8 Jun 2023 17:20:37 -0400 Subject: [PATCH] Integrate OpenJCEPlus into Semeru OpenJDK module openjceplus MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tao Liu Integrate the building of OpenJCEPlus with Semeru OpenJDK as a module “openjceplus”. The java codes will be built with Semeru OpenJDK as a jmod, and the native codes will be built as a “.so” or ".dll" library. --- .gitignore | 1 + closed/JPP.gmk | 4 ++ closed/autoconf/custom-hook.m4 | 15 +++++ closed/autoconf/custom-spec.gmk.in | 5 ++ closed/custom/Main.gmk | 2 + closed/custom/common/Modules.gmk | 6 +- closed/get_j9_source.sh | 67 ++++++++++++++++++++ closed/make/modules/openjceplus/Copy.gmk | 49 ++++++++++++++ closed/make/modules/openjceplus/Lib.gmk | 64 +++++++++++++++++++ get_source.sh | 27 +++++++- src/java.base/share/classes/module-info.java | 2 +- 11 files changed, 238 insertions(+), 4 deletions(-) create mode 100644 closed/make/modules/openjceplus/Copy.gmk create mode 100644 closed/make/modules/openjceplus/Lib.gmk diff --git a/.gitignore b/.gitignore index b9a4f673906..310d1e14ec2 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ # exclude all source directories /omr /openj9 +/OpenJCEPlus /openssl # exclude optional eclipse project file /.project diff --git a/closed/JPP.gmk b/closed/JPP.gmk index 18012f82bd8..f491abff318 100644 --- a/closed/JPP.gmk +++ b/closed/JPP.gmk @@ -30,6 +30,10 @@ ifeq (true,$(OPENJ9_ENABLE_CRIU_SUPPORT)) JPP_TAGS += CRIU_SUPPORT endif # OPENJ9_ENABLE_CRIU_SUPPORT +ifeq (true,$(BUILD_OPENJCEPLUS)) + JPP_TAGS += OPENJCEPLUS_SUPPORT +endif # BUILD_OPENJCEPLUS + ifeq (true,$(OPENJ9_ENABLE_INLINE_TYPES)) JPP_TAGS += INLINE-TYPES endif # OPENJ9_ENABLE_INLINE_TYPES diff --git a/closed/autoconf/custom-hook.m4 b/closed/autoconf/custom-hook.m4 index da658cf95b0..d7065867f4b 100644 --- a/closed/autoconf/custom-hook.m4 +++ b/closed/autoconf/custom-hook.m4 @@ -52,6 +52,7 @@ AC_DEFUN_ONCE([CUSTOM_EARLY_HOOK], OPENJ9_CONFIGURE_INLINE_TYPES OPENJ9_THIRD_PARTY_REQUIREMENTS OPENJ9_CHECK_NASM_VERSION + OPENJCEPLUS_SETUP ]) AC_DEFUN([OPENJ9_CONFIGURE_CMAKE], @@ -818,3 +819,17 @@ AC_DEFUN([OPENJ9_GENERATE_TOOL_WRAPPERS], OPENJ9_GENERATE_TOOL_WRAPPER([nasm], [$NASM]) OPENJ9_GENERATE_TOOL_WRAPPER([rc], [$RC]) ]) + +AC_DEFUN([OPENJCEPLUS_SETUP], +[ + AC_MSG_CHECKING([for OpenJCEPlus]) + if test -d "$TOPDIR/OpenJCEPlus" ; then + BUILD_OPENJCEPLUS=true + AC_MSG_RESULT([yes]) + else + BUILD_OPENJCEPLUS=false + AC_MSG_RESULT([no]) + fi + + AC_SUBST(BUILD_OPENJCEPLUS) +]) diff --git a/closed/autoconf/custom-spec.gmk.in b/closed/autoconf/custom-spec.gmk.in index 9b8063fd454..8e1d92a10ed 100644 --- a/closed/autoconf/custom-spec.gmk.in +++ b/closed/autoconf/custom-spec.gmk.in @@ -52,6 +52,7 @@ WARNING_MODULES := \ openj9.dtfj \ openj9.dtfjview \ openj9.traceformat \ + openjceplus \ # ifneq (,$(filter $(WARNING_MODULES),$(MODULE))) @@ -182,3 +183,7 @@ J9JCL_SOURCES_DONEFILE := $(MAKESUPPORT_OUTPUTDIR)/j9jcl.done # Disable all hotspot features. JVM_FEATURES_server := + +# Required by OpenJCEPlus. +BUILD_OPENJCEPLUS := @BUILD_OPENJCEPLUS@ +OPENJCEPLUS_TOPDIR := $(TOPDIR)/OpenJCEPlus diff --git a/closed/custom/Main.gmk b/closed/custom/Main.gmk index 48d2169c400..4ae5a28972c 100644 --- a/closed/custom/Main.gmk +++ b/closed/custom/Main.gmk @@ -119,3 +119,5 @@ ifneq (,$(HEALTHCENTER_JAR)) # The content must be extracted before module-info can be compiled. ibm.healthcenter-java : ibm.healthcenter-copy endif # HEALTHCENTER_JAR + +openjceplus-copy : openjceplus-libs diff --git a/closed/custom/common/Modules.gmk b/closed/custom/common/Modules.gmk index fc0a05a0a67..394236b8885 100644 --- a/closed/custom/common/Modules.gmk +++ b/closed/custom/common/Modules.gmk @@ -1,5 +1,5 @@ # =========================================================================== -# (c) Copyright IBM Corp. 2017, 2022 All Rights Reserved +# (c) Copyright IBM Corp. 2017, 2023 All Rights Reserved # =========================================================================== # This code is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License version 2 only, as @@ -56,6 +56,10 @@ TOP_SRC_DIRS += \ $(J9JCL_SOURCES_DIR) \ # +ifeq (true,$(BUILD_OPENJCEPLUS)) + TOP_SRC_DIRS += $(OPENJCEPLUS_TOPDIR)/src/main +endif + .PHONY : generate-j9jcl-sources generate-j9jcl-sources $(J9JCL_SOURCES_DONEFILE) : diff --git a/closed/get_j9_source.sh b/closed/get_j9_source.sh index c5754c82a79..c330103e1a9 100644 --- a/closed/get_j9_source.sh +++ b/closed/get_j9_source.sh @@ -39,6 +39,13 @@ usage() { echo " -omr-branch the OpenJ9/omr git branch: openj9" echo " -omr-sha a commit SHA for the omr repository" echo " -omr-reference a local repo to use as a clone reference" + echo " -openjceplus-repo the OpenJCEPlus repository url" + echo " -openjceplus-branch the OpenJCEPlus git branch" + echo " -openjceplus-sha a commit SHA for the OpenJCEPlus repository" + echo " -openjceplus-reference a local repo to use as a clone reference" + echo " -with-gskit-bin the GSKit binary url" + echo " -with-gskit-sdk-bin the GSKIT SDK binary url" + echo " -with-gskit-bin-credential the credential for downloading the GSKit binaries" echo " -parallel (boolean) if 'true' then the clone j9 repository commands run in parallel, default is false" echo "" exit 1 @@ -108,6 +115,34 @@ for i in "$@" ; do references[omr]="${i#*=}" ;; + -openjceplus-repo=* ) + git_urls[OpenJCEPlus]="${i#*=}" + ;; + + -openjceplus-branch=* ) + branches[OpenJCEPlus]="${i#*=}" + ;; + + -openjceplus-sha=* ) + shas[OpenJCEPlus]="${i#*=}" + ;; + + -openjceplus-reference=* ) + references[OpenJCEPlus]="${i#*=}" + ;; + + -gskit-bin=* ) + gskit_bin="${i#*=}" + ;; + + -gskit-sdk-bin=* ) + gskit_sdk_bin="${i#*=}" + ;; + + -gskit-credential=* ) + gskit_credential="${i#*=}" + ;; + -parallel=* ) pflag="${i#*=}" ;; @@ -173,6 +208,38 @@ if [ ${pflag} = true ] ; then wait fi +# Download ICC binaries and create Java module folder +openjceplus_source=OpenJCEPlus +if [ -n "${git_urls[$openjceplus_source]}" ] ; then + + echo + echo "$openjceplus_source exists, download ICC binaries" + echo + + cd $openjceplus_source + mkdir -p icc/jgsk_sdk/lib64 + + if [ $gskit_credential ]; then + # Download GSKit binaries from artifactory + curl -vk -u "$gskit_credential" -X GET $gskit_bin > ./icc/jgsk_crypto.tar + curl -vk -u "$gskit_credential" -X GET $gskit_sdk_bin > ./icc/jgsk_crypto_sdk.tar + else + echo + echo "GSKit binaries are needed for compiling $openjceplus_source" + echo "Please set -with-gskit-bin, -with-gskit-sdk-bin, and -with-gskit-bin-credential" + exit 1 + fi + + tar -xf ./icc/jgsk_crypto_sdk.tar -C ./icc/ + tar -xf ./icc/jgsk_crypto.tar -C ./icc/jgsk_sdk/lib64/ + + # Create OpenJCEPlus Java module folder + mkdir -p ./src/main/openjceplus/share/classes/ + cp -r ./src/main/java/* ./src/main/openjceplus/share/classes/ + + cd .. +fi + END_TIME=$(date +%s) date "+[%F %T] OpenJ9 clone repositories finished in $(($END_TIME - $START_TIME)) seconds" diff --git a/closed/make/modules/openjceplus/Copy.gmk b/closed/make/modules/openjceplus/Copy.gmk new file mode 100644 index 00000000000..888c68e31ed --- /dev/null +++ b/closed/make/modules/openjceplus/Copy.gmk @@ -0,0 +1,49 @@ +# =========================================================================== +# (c) Copyright IBM Corp. 2023, 2023 All Rights Reserved +# =========================================================================== +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. +# +# IBM designates this particular file as subject to the "Classpath" exception +# as provided by IBM in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, see . +# =========================================================================== + +include $(TOPDIR)/closed/CopySupport.gmk + +ifeq (true,$(BUILD_OPENJCEPLUS)) + # Copy OpenJCEPlus native libraries + $(eval $(call SetupCopyFiles, COPY_JGSKIT_LIBS, \ + SRC := $(OPENJCEPLUS_TOPDIR)/target, \ + FILES := $(filter %.dll %.so %.x, $(call FindFiles, $(OPENJCEPLUS_TOPDIR)/target)), \ + FLATTEN := true, \ + DEST := $(LIB_DST_DIR), \ + )) + + TARGETS += $(COPY_JGSKIT_LIBS) + + # Bundle GSKIT library + ICC_DIR := $(TOPDIR)/OpenJCEPlus/icc/jgsk_sdk/lib64 + ifeq ($(call isTargetOs, windows), true) + ICC_SUB_DIR := modules_cmds + else + ICC_SUB_DIR := modules_libs + endif + + $(eval $(call SetupCopyFiles, COPY_ICC, \ + SRC := $(ICC_DIR), \ + DEST := $(SUPPORT_OUTPUTDIR)/$(ICC_SUB_DIR)/$(MODULE), \ + FILES := $(call FindFiles, $(ICC_DIR)), \ + )) + + TARGETS += $(COPY_ICC) +endif # BUILD_OPENJCEPLUS diff --git a/closed/make/modules/openjceplus/Lib.gmk b/closed/make/modules/openjceplus/Lib.gmk new file mode 100644 index 00000000000..e0bb12d969f --- /dev/null +++ b/closed/make/modules/openjceplus/Lib.gmk @@ -0,0 +1,64 @@ +# =========================================================================== +# (c) Copyright IBM Corp. 2023, 2023 All Rights Reserved +# =========================================================================== +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. +# +# IBM designates this particular file as subject to the "Classpath" exception +# as provided by IBM in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, see . +# =========================================================================== + +include LibCommon.gmk + +ifeq (true,$(BUILD_OPENJCEPLUS)) + +# Identify the desired JGSKIT target platform. +GSKIT_HOME := $(TOPDIR)/OpenJCEPlus/icc/jgsk_sdk +JGSKIT_TARGET := +JGSKIT_MAKE := jgskit.mak +JGSKIT_MAKE_PATH := $(OPENJCEPLUS_TOPDIR)/src/main/native/ +JCE_CLASSPATH := $(OPENJCEPLUS_TOPDIR)/src/main/java:$(TOPDIR)/src/java.base/share/classes + +ifeq ($(call isTargetOs, aix), true) + JGSKIT_TARGET := ppc-aix64 +else ifeq ($(call isTargetOs, linux), true) + ifeq ($(call isTargetCpu, x86_64), true) + JGSKIT_TARGET := x86-linux64 + else ifeq ($(call isTargetCpu, ppc64le), true) + JGSKIT_TARGET := ppcle-linux64 + endif +else ifeq ($(call isTargetOs, windows), true) + ifeq ($(call isTargetCpu, x86_64), true) + JGSKIT_TARGET := win64 + JGSKIT_MAKE := jgskit.win64.mak + JCE_CLASSPATH := "$(call MixedPath,$(OPENJCEPLUS_TOPDIR)/src/main/java)\;$(call MixedPath,$(TOPDIR)/src/java.base/share/classes)" + GSKIT_HOME := $(call MixedPath,$(GSKIT_HOME)) + BOOT_JDK := $(call MixedPath,$(BOOT_JDK)) + endif +endif + +ifeq (,$(JGSKIT_TARGET)) + $(error Unsupported platform $(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU)) +endif # JGSKIT_TARGET + +.PHONY : compile-libs + +compile-libs : + @$(ECHO) Compiling OpenJCEPlus native + export PLATFORM=$(JGSKIT_TARGET) JAVA_HOME=$(BOOT_JDK) GSKIT_HOME=$(GSKIT_HOME) JCE_CLASSPATH=$(JCE_CLASSPATH) \ + && $(MAKE) -j1 -C $(JGSKIT_MAKE_PATH) -f $(JGSKIT_MAKE) all + @$(ECHO) OpenJCEplus compile complete + +TARGETS += compile-libs + +endif # BUILD_OPENJCEPLUS diff --git a/get_source.sh b/get_source.sh index 90756e803f2..7fcaec15b56 100644 --- a/get_source.sh +++ b/get_source.sh @@ -1,6 +1,6 @@ #!/bin/bash # =========================================================================== -# (c) Copyright IBM Corp. 2017, 2022 All Rights Reserved +# (c) Copyright IBM Corp. 2017, 2023 All Rights Reserved # =========================================================================== # # This code is free software; you can redistribute it and/or modify it @@ -40,6 +40,13 @@ usage() { echo " -omr-branch the OpenJ9/omr git branch: openj9" echo " -omr-sha a commit SHA for the omr repository" echo " -omr-reference a local repo to use as a clone reference" + echo " -openjceplus-repo the OpenJCEPlus repository url" + echo " -openjceplus-branch the OpenJCEPlus git branch" + echo " -openjceplus-sha a commit SHA for the OpenJCEPlus repository" + echo " -openjceplus-reference a local repo to use as a clone reference" + echo " -gskit-bin the GSKit binary url" + echo " -gskit-sdk-bin the GSKIT SDK binary url" + echo " -gskit-credential the credential for downloading the GSKit and GSKit SDK" echo " -parallel (boolean) if 'true' then the clone j9 repository commands run in parallel, default is false" echo " --openssl-repo Specify the OpenSSL repository to download from" echo " --openssl-version Specify the version of OpenSSL source to download" @@ -57,7 +64,23 @@ for i in "$@" ; do usage ;; - -openj9-repo=* | -openj9-branch=* | -openj9-sha=* | -openj9-reference=* | -omr-repo=* | -omr-branch=* | -omr-sha=* | -omr-reference=* | -parallel=* ) + -gskit-bin=* \ + | -gskit-credential=* \ + | -gskit-sdk-bin=* \ + | -omr-branch=* \ + | -omr-reference=* \ + | -omr-repo=* \ + | -omr-sha=* \ + | -openj9-branch=* \ + | -openj9-reference=* \ + | -openj9-repo=* \ + | -openj9-sha=* \ + | -openjceplus-branch=* \ + | -openjceplus-reference=* \ + | -openjceplus-repo=* \ + | -openjceplus-sha=* \ + | -parallel=* \ + ) j9options="${j9options} ${i}" ;; diff --git a/src/java.base/share/classes/module-info.java b/src/java.base/share/classes/module-info.java index 644c1a6e13b..5744ac8922b 100644 --- a/src/java.base/share/classes/module-info.java +++ b/src/java.base/share/classes/module-info.java @@ -25,7 +25,7 @@ /* * =========================================================================== - * (c) Copyright IBM Corp. 2022, 2022 All Rights Reserved + * (c) Copyright IBM Corp. 2022, 2023 All Rights Reserved * =========================================================================== */