From b1f784662fe33ad724dc7e6f95d016427b6ce91d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20B=C3=A4sken?= Date: Thu, 19 Sep 2024 10:22:54 +0200 Subject: [PATCH] SapMachine #1823: Import async-profiler into the jdk and jre images --- make/Images.gmk | 35 +++++++++++++++++++++++++++++++++ make/autoconf/jdk-options.m4 | 15 ++++++++++++++ make/autoconf/spec.gmk.template | 4 ++++ make/common/FileUtils.gmk | 24 ++++++++++++++++++++++ 4 files changed, 78 insertions(+) diff --git a/make/Images.gmk b/make/Images.gmk index fb5cb7b4cce..b26d7a4dcbd 100644 --- a/make/Images.gmk +++ b/make/Images.gmk @@ -247,6 +247,41 @@ ifeq ($(GCOV_ENABLED), true) endif +################################################################################ +# SapMachine 2024-09-13: Async profiler import + +ifeq ($(call isTargetOs, linux macosx)+$(ASYNC_PROFILER_IMPORT_ENABLED), true+true) + + $(eval $(call SetupCopyFiles, COPY_ASYNC_PROFILER_BIN_TO_JDK, \ + SRC := $(ASYNC_PROFILER_IMPORT_PATH), \ + DEST := $(JDK_IMAGE_DIR), \ + FILES := bin/asprof lib/libasyncProfiler$(SHARED_LIBRARY_SUFFIX), \ + MACRO := install-file-and-sign, \ + )) + + $(eval $(call SetupCopyFiles, COPY_ASYNC_PROFILER_BIN_TO_JRE, \ + SRC := $(ASYNC_PROFILER_IMPORT_PATH), \ + DEST := $(JRE_IMAGE_DIR), \ + FILES := bin/asprof lib/libasyncProfiler$(SHARED_LIBRARY_SUFFIX), \ + MACRO := install-file-and-sign, \ + )) + + $(eval $(call SetupCopyFiles, COPY_ASYNC_PROFILER_TO_JDK, \ + SRC := $(ASYNC_PROFILER_IMPORT_PATH), \ + DEST := $(JDK_IMAGE_DIR), \ + FILES := lib/async-profiler.jar lib/converter.jar legal/async/CHANGELOG.md legal/async/LICENSE legal/async/README.md, \ + )) + + $(eval $(call SetupCopyFiles, COPY_ASYNC_PROFILER_TO_JRE, \ + SRC := $(ASYNC_PROFILER_IMPORT_PATH), \ + DEST := $(JRE_IMAGE_DIR), \ + FILES := lib/async-profiler.jar lib/converter.jar legal/async/CHANGELOG.md legal/async/LICENSE legal/async/README.md, \ + )) + + JDK_TARGETS += $(COPY_ASYNC_PROFILER_BIN_TO_JDK) $(COPY_ASYNC_PROFILER_TO_JDK) + JRE_TARGETS += $(COPY_ASYNC_PROFILER_BIN_TO_JRE) $(COPY_ASYNC_PROFILER_TO_JRE) +endif + ################################################################################ # Debug symbols # Since debug symbols are not included in the jmod files, they need to be copied diff --git a/make/autoconf/jdk-options.m4 b/make/autoconf/jdk-options.m4 index b5c679d2a8e..d083f82d653 100644 --- a/make/autoconf/jdk-options.m4 +++ b/make/autoconf/jdk-options.m4 @@ -224,6 +224,21 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_JDK_OPTIONS], fi AC_SUBST(COPYRIGHT_YEAR) + # SapMachine 2024-09-13: import async profiler binaries + AC_ARG_WITH(async-profiler-import-path, [AS_HELP_STRING([--with-async-profiler-import-path], + [Set import path for downloaded async profiler binaries])]) + if test "x$with_async_profiler_import_path" != x; then + ASYNC_PROFILER_IMPORT_PATH="$with_async_profiler_import_path" + if test -f "$ASYNC_PROFILER_IMPORT_PATH/bin/asprof"; then + ASYNC_PROFILER_IMPORT_ENABLED=true + AC_MSG_NOTICE([asprof exists, enabling async-profiler import]) + else + AC_MSG_ERROR([async-profiler import path was set, but asprof was not found]) + fi + fi + AC_SUBST(ASYNC_PROFILER_IMPORT_PATH) + AC_SUBST(ASYNC_PROFILER_IMPORT_ENABLED) + # Override default library path AC_ARG_WITH([jni-libpath], [AS_HELP_STRING([--with-jni-libpath], [override default JNI library search path])]) diff --git a/make/autoconf/spec.gmk.template b/make/autoconf/spec.gmk.template index 12c5a9f51f9..3ca18fee844 100644 --- a/make/autoconf/spec.gmk.template +++ b/make/autoconf/spec.gmk.template @@ -449,6 +449,10 @@ CACERTS_SRC := @CACERTS_SRC@ # Enable unlimited crypto policy UNLIMITED_CRYPTO := @UNLIMITED_CRYPTO@ +# SapMachine 2024-09-13: import async profiler binaries +ASYNC_PROFILER_IMPORT_PATH=@ASYNC_PROFILER_IMPORT_PATH@ +ASYNC_PROFILER_IMPORT_ENABLED=@ASYNC_PROFILER_IMPORT_ENABLED@ + GCOV_ENABLED := @GCOV_ENABLED@ JCOV_ENABLED := @JCOV_ENABLED@ JCOV_HOME := @JCOV_HOME@ diff --git a/make/common/FileUtils.gmk b/make/common/FileUtils.gmk index 114f3adefbe..78ffaa5c621 100644 --- a/make/common/FileUtils.gmk +++ b/make/common/FileUtils.gmk @@ -139,11 +139,35 @@ ifeq ($(call isTargetOs, macosx), true) $(XATTR) -cs '$(call DecodeSpace, $@)'; \ fi endef + + # SapMachine 2024-09-13: import async profiler binaries + ifeq ($(MACOSX_CODESIGN_MODE), disabled) + define install-file-and-sign + $(install-file) + $(ECHO) No Async profiler codesigning, codesign mode is $(MACOSX_CODESIGN_MODE) + endef + else + ifeq ($(MACOSX_CODESIGN_MODE), hardened) + CODESIGN_APOPTS="$(MACOSX_CODESIGN_IDENTITY)" --timestamp --options runtime + else ifeq ($(MACOSX_CODESIGN_MODE), debug) + CODESIGN_APOPTS=- + PLIST_APOPT=-debug + endif + define install-file-and-sign + $(install-file) + $(CODESIGN) --remove-signature '$(call DecodeSpace, $@)' + $(CODESIGN) -f -s $(CODESIGN_APOPTS) --entitlements $(TOPDIR)/make/data/macosxsigning/default$(PLIST_APOPT).plist '$(call DecodeSpace, $@)' + endef + endif else define install-file $(call MakeTargetDir) $(CP) -fP '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)' endef + # SapMachine 2024-09-13: import async profiler binaries + define install-file-and-sign + $(install-file) + endef endif # Variant of install file that does not preserve symlinks