Skip to content

8352044: Add --with-import-jvms to configure #24063

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion make/autoconf/configure.ac
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -95,6 +95,7 @@ JDKOPT_SETUP_OPEN_OR_CUSTOM
# These are needed to be able to create a configuration name (and thus the output directory)
JDKOPT_SETUP_DEBUG_LEVEL
HOTSPOT_SETUP_JVM_VARIANTS
HOTSPOT_SETUP_IMPORT_JVMS

# With basic setup done, call the custom early hook.
CUSTOM_EARLY_HOOK
Expand Down
45 changes: 44 additions & 1 deletion make/autoconf/hotspot.m4
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -102,6 +102,49 @@ AC_DEFUN_ONCE([HOTSPOT_SETUP_JVM_VARIANTS],
AC_SUBST(JVM_VARIANT_MAIN)
])

################################################################################
# Setup an optional list of additional JVMs that should be included during
# build.
#
AC_DEFUN_ONCE([HOTSPOT_SETUP_IMPORT_JVMS],
[
UTIL_ARG_WITH(NAME: import-jvms, TYPE: string,
DEFAULT: [],
DESC: [Additional JVMs to import, on the format <name>:<path to jvm lib>, separated by commas],
OPTIONAL: true)

IMPORT_JVMS=
IMPORT_JVM_NAMES=
AC_MSG_CHECKING([for import JVMs])
# Create a nicely formatted list of import JVM names
[ import_jvm_names="`$ECHO $with_import_jvms | $SED -E -e 's/([^:,]+):[^,]+/\1/g; s/,/, /g'`" ]
if test "x$import_jvm_names" = x; then
AC_MSG_RESULT([none])
else
AC_MSG_RESULT([$import_jvm_names])

import_jvms="`$ECHO $with_import_jvms | $SED -e 's/,/ /g'`"

for import_jvm in $import_jvms; do
import_jvm_name=`$ECHO $import_jvm | $CUT -d: -f1`
import_jvm_lib=`$ECHO $import_jvm | $CUT -d: -f2`
if test "x$import_jvm_name" = "x$JVM_VARIANT_MAIN"; then
AC_MSG_ERROR([JVM name '$JVM_VARIANT_MAIN' is not allowed for an import JVM])
fi
if ! test -e $import_jvm_lib; then
AC_MSG_ERROR([Import JVM '$import_jvm_name' not found at $import_jvm_lib])
fi

UTIL_FIXUP_PATH(import_jvm_lib)
AC_MSG_NOTICE([Importing JVM '$import_jvm_name' from $import_jvm_lib])
IMPORT_JVM_NAMES="$IMPORT_JVM_NAMES $import_jvm_name"
IMPORT_JVMS="$IMPORT_JVMS $import_jvm_name:$import_jvm_lib"
done
fi
AC_SUBST(IMPORT_JVMS)
AC_SUBST(IMPORT_JVM_NAMES)
])

################################################################################
# Misc hotspot setup that does not fit elsewhere.
#
Expand Down
5 changes: 4 additions & 1 deletion make/autoconf/spec.gmk.template
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -323,6 +323,9 @@ JVM_FEATURES_custom := @JVM_FEATURES_custom@
VALID_JVM_FEATURES := @VALID_JVM_FEATURES@
VALID_JVM_VARIANTS := @VALID_JVM_VARIANTS@

IMPORT_JVMS := @IMPORT_JVMS@
IMPORT_JVM_NAMES := @IMPORT_JVM_NAMES@

# Allow overriding the default hotspot library path
HOTSPOT_OVERRIDE_LIBPATH := @HOTSPOT_OVERRIDE_LIBPATH@

Expand Down
31 changes: 25 additions & 6 deletions make/modules/java.base/Copy.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,17 @@ ifeq ($(call isTargetOs, windows)+$(CREATING_BUILDJDK), true+false)
endif

################################################################################
# In jvm.cfg, the first listed KNOWN variant is the default. On most build
# configurations, that is the server variant.
ifeq ($(call And, $(call isTargetOs, windows) $(call isTargetCpu, x86)), true)
DEFAULT_CFG_VARIANT ?= client
endif
DEFAULT_CFG_VARIANT ?= server
# In jvm.cfg, the first listed KNOWN variant is the default.
DEFAULT_CFG_VARIANT := $(JVM_VARIANT_MAIN)

# Change the order to put the default variant first if present.
ORDERED_CFG_VARIANTS := \
$(if $(filter $(DEFAULT_CFG_VARIANT), $(JVM_VARIANTS)), $(DEFAULT_CFG_VARIANT)) \
$(filter-out $(DEFAULT_CFG_VARIANT), $(JVM_VARIANTS))

# Append imported JVMs
ORDERED_CFG_VARIANTS += $(IMPORT_JVM_NAMES)

JVMCFG := $(LIB_DST_DIR)/jvm.cfg

define print-cfg-line
Expand All @@ -118,6 +117,26 @@ $(JVMCFG): $(call DependOnVariable, ORDERED_CFG_VARIANTS)

TARGETS += $(JVMCFG)

################################################################################
# Copy import JVMs into place, if any
#
ifneq ($(IMPORT_JVM_NAMES),)
rename_to_libjvm = $(LIBRARY_PREFIX)jvm$(SHARED_LIBRARY_SUFFIX)

$(foreach import_jvm, $(IMPORT_JVM_NAMES), \
$(eval $(import_jvm)_path := $(patsubst $(import_jvm):%,%,$(filter $(import_jvm):%, $(IMPORT_JVMS)))) \
$(eval $(call MakeDir, $(LIB_DST_DIR)/$(import_jvm))) \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you really need to call MakeDir outside of a recipe? Won't SetupCopyFiles recipes create this directory?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assumed it would, but it failed, and I looked at the code and found no clear evidence that it does, so I added this. It might have been some other issue, so I can double-check again, if you are certain that SetupCopyFiles should create needed directories.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SetupCopyFiles uses install-file by default and that macro calls MakeTargetDir.

$(eval $(call SetupCopyFiles, IMPORT_JVM_$(import_jvm), \
FILES := $($(import_jvm)_path), \
DEST := $(LIB_DST_DIR)/$(import_jvm), \
FLATTEN := true, \
NAME_MACRO := rename_to_libjvm, \
LOG_ACTION := Copying import JVM '$(import_jvm)', \
)) \
$(eval TARGETS += $(IMPORT_JVM_$(import_jvm))) \
)
endif

################################################################################

# CACERTS_FILE is optionally set in configure to override the default cacerts
Expand Down