--- a/common/autoconf/spec.gmk.in Fri Nov 04 17:52:02 2016 +0000
+++ b/common/autoconf/spec.gmk.in Mon Nov 07 13:25:18 2016 +0100
@@ -788,6 +788,7 @@
SYMBOLS_IMAGE_DIR=$(IMAGES_OUTPUTDIR)/$(SYMBOLS_IMAGE_SUBDIR)
# Interim image
+INTERIM_JMODS_DIR := $(SUPPORT_OUTPUTDIR)/interim-jmods
INTERIM_IMAGE_DIR := $(SUPPORT_OUTPUTDIR)/interim-image
# Docs image
--- a/make/CreateJmods.gmk Fri Nov 04 17:52:02 2016 +0000
+++ b/make/CreateJmods.gmk Mon Nov 07 13:25:18 2016 +0100
@@ -36,6 +36,7 @@
################################################################################
JMODS_DIR := $(IMAGES_OUTPUTDIR)/jmods
+JMODS_TEMPDIR := $(SUPPORT_OUTPUTDIR)/jmods
LIBS_DIR := $(firstword $(wildcard $(addsuffix /$(MODULE), \
$(SUPPORT_OUTPUTDIR)/modules_libs $(IMPORT_MODULES_LIBS))))
@@ -81,16 +82,19 @@
# Add dependencies on other jmod files. Only java.base needs access to other
# jmods.
ifeq ($(MODULE), java.base)
- ALL_UPGRADEABLE_MODULES = $(call FindAllUpgradeableModules)
# When creating a BUILDJDK, we don't need to add hashes to java.base
ifneq ($(CREATING_BUILDJDK), true)
- DEPS += $(patsubst %, $(JMODS_DIR)/%.jmod, \
- $(filter-out java.base $(ALL_UPGRADEABLE_MODULES), $(call FindAllModules)))
+ # When creating interim versions of jmods, skip hashes
+ ifneq ($(INTERIM_JMOD), true)
+ ALL_UPGRADEABLE_MODULES := $(call FindAllUpgradeableModules)
+ DEPS += $(patsubst %, $(JMODS_DIR)/%.jmod, \
+ $(filter-out java.base $(ALL_UPGRADEABLE_MODULES), $(call FindAllModules)))
- EXCLUDE_PATTERN := $(strip $(subst $(SPACE),|,$(strip $(ALL_UPGRADEABLE_MODULES))))
+ EXCLUDE_PATTERN := $(strip $(subst $(SPACE),|,$(strip $(ALL_UPGRADEABLE_MODULES))))
- JMOD_FLAGS += --module-path $(JMODS_DIR) \
- --hash-modules '^(?!$(EXCLUDE_PATTERN))'
+ JMOD_FLAGS += --module-path $(JMODS_DIR) \
+ --hash-modules '^(?!$(EXCLUDE_PATTERN))'
+ endif
endif
endif
@@ -102,13 +106,19 @@
DEPS += $(call CacheFind, $(JDK_OUTPUTDIR)/modules/jdk.jlink/jdk/tools/jmod)
endif
+# If creating interim versions of jmods, certain files need to be filtered out
+# to avoid false incremental rebuilds.
+ifeq ($(INTERIM_JMOD), true)
+ DEPS := $(filter-out $(SUPPORT_OUTPUTDIR)/modules_libs/java.base/classlist, $(DEPS))
+endif
+
# TODO: What about headers?
# Create jmods in a temp dir and then move them into place to keep the
# module path in $(IMAGES_OUTPUTDIR)/jmods valid at all times.
$(JMODS_DIR)/$(MODULE).jmod: $(DEPS)
$(call LogWarn, Creating $(patsubst $(OUTPUT_ROOT)/%, %, $@))
- $(call MakeDir, $(@D) $(SUPPORT_OUTPUTDIR)/jmods)
- $(RM) $@ $(SUPPORT_OUTPUTDIR)/jmods/$(notdir $@)
+ $(call MakeDir, $(JMODS_DIR) $(JMODS_TEMPDIR))
+ $(RM) $@ $(JMODS_TEMPDIR)/$(notdir $@)
$(JMOD) create \
--module-version $(VERSION_SHORT) \
--os-name $(REQUIRED_OS_NAME) \
@@ -116,10 +126,10 @@
--os-version $(REQUIRED_OS_VERSION) \
--module-path $(JMODS_DIR) \
--exclude '**{_the.*,*.diz,*.debuginfo,*.dSYM/**,*.dSYM,*.pdb,*.map}' \
- $(JMOD_FLAGS) $(SUPPORT_OUTPUTDIR)/jmods/$(notdir $@)
- $(MV) $(SUPPORT_OUTPUTDIR)/jmods/$(notdir $@) $@
+ $(JMOD_FLAGS) $(JMODS_TEMPDIR)/$(notdir $@)
+ $(MV) $(JMODS_TEMPDIR)/$(notdir $@) $@
-TARGETS += $(IMAGES_OUTPUTDIR)/jmods/$(MODULE).jmod
+TARGETS += $(JMODS_DIR)/$(MODULE).jmod
################################################################################
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/make/GenerateLinkOptData.gmk Mon Nov 07 13:25:18 2016 +0100
@@ -0,0 +1,88 @@
+#
+# Copyright (c) 2016, 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
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation. Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle 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, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+################################################################################
+# Generate classlist
+################################################################################
+
+default: all
+
+include $(SPEC)
+include MakeBase.gmk
+include JarArchive.gmk
+
+################################################################################
+# Create a jar with our generator class. Using a jar is intentional since it
+# will load more classes
+
+$(eval $(call SetupJarArchive, CLASSLIST_JAR, \
+ SRCS := $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes, \
+ INCLUDES := build/tools/classlist, \
+ JAR := $(SUPPORT_OUTPUTDIR)/classlist.jar, \
+))
+
+TARGETS += $(CLASSLIST_JAR)
+
+################################################################################
+
+LINK_OPT_DIR := $(SUPPORT_OUTPUTDIR)/link_opt
+CLASSLIST_FILE := $(LINK_OPT_DIR)/classlist
+JLI_TRACE_FILE := $(LINK_OPT_DIR)/jli_trace.out
+
+# If an external buildjdk has been supplied, we don't build a separate interim
+# image, so just use the external build jdk instead.
+ifeq ($(EXTERNAL_BUILDJDK), true)
+ INTERIM_IMAGE_DIR := $(BUILD_JDK)
+endif
+
+$(CLASSLIST_FILE): $(INTERIM_IMAGE_DIR)/bin/java$(EXE_SUFFIX) $(CLASSLIST_JAR)
+ $(call MakeDir, $(LINK_OPT_DIR))
+ $(call LogInfo, Generating $(patsubst $(OUTPUT_ROOT)/%, %, $@))
+ $(call LogInfo, Generating $(patsubst $(OUTPUT_ROOT)/%, %, $(JLI_TRACE_FILE)))
+ $(FIXPATH) $(INTERIM_IMAGE_DIR)/bin/java -XX:DumpLoadedClassList=$@ \
+ -Djava.lang.invoke.MethodHandle.TRACE_RESOLVE=true \
+ -cp $(SUPPORT_OUTPUTDIR)/classlist.jar \
+ build.tools.classlist.HelloClasslist \
+ $(LOG_DEBUG) 2>&1 > $(JLI_TRACE_FILE)
+
+# The jli trace is created by the same recipe as classlist. By declaring these
+# dependencies, make will correctly rebuild both jli trace and classlist
+# incrementally using the single recpie above.
+$(CLASSLIST_FILE): $(JLI_TRACE_FILE)
+$(JLI_TRACE_FILE): $(INTERIM_IMAGE_DIR)/bin/java$(EXE_SUFFIX) $(CLASSLIST_JAR)
+
+TARGETS += $(CLASSLIST_FILE) $(JLI_TRACE_FILE)
+
+# Copy the classlist file into java.base libs
+$(eval $(call SetupCopyFiles, COPY_CLASSLIST, \
+ FILES := $(CLASSLIST_FILE), \
+ DEST := $(SUPPORT_OUTPUTDIR)/modules_libs/java.base, \
+))
+
+TARGETS += $(COPY_CLASSLIST)
+
+################################################################################
+
+all: $(TARGETS)
--- a/make/Images.gmk Fri Nov 04 17:52:02 2016 +0000
+++ b/make/Images.gmk Mon Nov 07 13:25:18 2016 +0100
@@ -113,8 +113,8 @@
JLINK_ORDER_RESOURCES := **module-info.class
JLINK_JLI_CLASSES :=
ifeq ($(ENABLE_GENERATE_CLASSLIST), true)
- JLINK_ORDER_RESOURCES += @$(SUPPORT_OUTPUTDIR)/classlist/classlist
- JLINK_JLI_CLASSES := --generate-jli-classes=@$(SUPPORT_OUTPUTDIR)/classlist/jli_trace.out
+ JLINK_ORDER_RESOURCES += @$(SUPPORT_OUTPUTDIR)/link_opt/classlist
+ JLINK_JLI_CLASSES := --generate-jli-classes=@$(SUPPORT_OUTPUTDIR)/link_opt/jli_trace.out
endif
JLINK_ORDER_RESOURCES += \
/java.base/java/** \
@@ -142,7 +142,7 @@
$(ECHO) Creating jdk jimage
$(RM) -r $(JDK_IMAGE_DIR)
$(JLINK_TOOL) --add-modules $(JDK_MODULES_LIST) \
- $(JLINK_JDK_EXTRA_OPTS) \
+ $(JLINK_JDK_EXTRA_OPTS) \
--output $(JDK_IMAGE_DIR)
$(TOUCH) $@
@@ -152,7 +152,7 @@
$(RM) -r $(JRE_IMAGE_DIR)
$(JLINK_TOOL) --add-modules $(JRE_MODULES_LIST) \
$(JLINK_JRE_EXTRA_OPTS) \
- --output $(JRE_IMAGE_DIR)
+ --output $(JRE_IMAGE_DIR)
$(TOUCH) $@
JRE_COMPACT1_IMAGE_DIR := $(JRE_IMAGE_DIR)-compact1
@@ -360,25 +360,6 @@
JDK_TARGETS += $(JDK_IMAGE_DIR)/src.zip
################################################################################
-# classlist
-
-ifeq ($(ENABLE_GENERATE_CLASSLIST), true)
- $(eval $(call SetupCopyFiles, JDK_COPY_CLASSLIST, \
- FILES := $(SUPPORT_OUTPUTDIR)/classlist/classlist, \
- DEST := $(JDK_IMAGE_DIR)/lib, \
- ))
-
- JDK_TARGETS += $(JDK_COPY_CLASSLIST)
-
- $(eval $(call SetupCopyFiles, JRE_COPY_CLASSLIST, \
- FILES := $(SUPPORT_OUTPUTDIR)/classlist/classlist, \
- DEST := $(JRE_IMAGE_DIR)/lib, \
- ))
-
- JRE_TARGETS += $(JRE_COPY_CLASSLIST)
-endif
-
-################################################################################
# /demo dir
# Avoid doing the expensive find unless called with "jdk" as target.
ifneq ($(filter jdk, $(MAKECMDGOALS)), )
--- a/make/InterimImage.gmk Fri Nov 04 17:52:02 2016 +0000
+++ b/make/InterimImage.gmk Mon Nov 07 13:25:18 2016 +0100
@@ -36,15 +36,15 @@
INTERIM_MODULES_LIST := $(call CommaList, $(INTERIM_IMAGE_MODULES))
-JMODS := $(patsubst %, $(IMAGES_OUTPUTDIR)/jmods/%.jmod, $(INTERIM_IMAGE_MODULES))
+JMODS := $(patsubst %, $(INTERIM_JMODS_DIR)/%.jmod, $(INTERIM_IMAGE_MODULES))
JLINK_TOOL := $(JLINK) \
- --module-path $(IMAGES_OUTPUTDIR)/jmods \
+ --module-path $(INTERIM_JMODS_DIR) \
--endian $(OPENJDK_BUILD_CPU_ENDIAN)
$(INTERIM_IMAGE_DIR)/$(JIMAGE_TARGET_FILE): $(JMODS) \
$(call DependOnVariable, INTERIM_MODULES_LIST)
- $(ECHO) Creating interim jimage
+ $(call LogWarn, Creating interim jimage)
$(RM) -r $(INTERIM_IMAGE_DIR)
$(JLINK_TOOL) \
--output $(INTERIM_IMAGE_DIR) \
--- a/make/Main.gmk Fri Nov 04 17:52:02 2016 +0000
+++ b/make/Main.gmk Mon Nov 07 13:25:18 2016 +0100
@@ -376,15 +376,29 @@
# The interim-image is a small jlinked image that is used to generate artifacts
# at build time for use when linking the real images.
+INTERIM_JMOD_TARGETS := $(addsuffix -interim-jmod, $(INTERIM_IMAGE_MODULES))
+
+define DeclareInterimJmodRecipe
+ $1-interim-jmod:
+ +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f CreateJmods.gmk \
+ MODULE=$1 \
+ JMODS_DIR=$(INTERIM_JMODS_DIR) \
+ JMODS_TEMPDIR=$(INTERIM_JMODS_DIR)/temp \
+ INTERIM_JMOD=true \
+ )
+endef
+
+$(foreach m, $(INTERIM_IMAGE_MODULES), $(eval $(call DeclareInterimJmodRecipe,$m)))
+
interim-image:
+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f InterimImage.gmk)
ifeq ($(ENABLE_GENERATE_CLASSLIST), true)
- generate-classlist:
- +($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f GenerateClasslist.gmk)
+ generate-link-opt-data:
+ +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f GenerateLinkOptData.gmk)
endif
-ALL_TARGETS += interim-image generate-classlist
+ALL_TARGETS += $(INTERIM_JMOD_TARGETS) interim-image generate-link-opt-data
################################################################################
# Build tests
@@ -607,13 +621,15 @@
# When creating a BUILDJDK, the java compilation has already been done by the
# normal build and copied in.
ifneq ($(CREATING_BUILDJDK), true)
- $(foreach m, $(JAVA_MODULES), $(eval $m-jmod: $m-java))
+ $(foreach m, $(JAVA_MODULES), $(eval $m_JMOD_DEPS += $m-java))
endif
- $(foreach m, $(GENDATA_MODULES), $(eval $m-jmod: $m-gendata))
- $(foreach m, $(RMIC_MODULES), $(eval $m-jmod: $m-rmic))
- $(foreach m, $(LIBS_MODULES), $(eval $m-jmod: $m-libs))
- $(foreach m, $(LAUNCHER_MODULES), $(eval $m-jmod: $m-launchers))
- $(foreach m, $(COPY_MODULES), $(eval $m-jmod: $m-copy))
+ $(foreach m, $(GENDATA_MODULES), $(eval $m_JMOD_DEPS += $m-gendata))
+ $(foreach m, $(RMIC_MODULES), $(eval $m_JMOD_DEPS += $m-rmic))
+ $(foreach m, $(LIBS_MODULES), $(eval $m_JMOD_DEPS += $m-libs))
+ $(foreach m, $(LAUNCHER_MODULES), $(eval $m_JMOD_DEPS += $m-launchers))
+ $(foreach m, $(COPY_MODULES), $(eval $m_JMOD_DEPS += $m-copy))
+ $(foreach m, $(ALL_MODULES), $(eval $m-jmod: $($(m)_JMOD_DEPS)))
+ $(foreach m, $(INTERIM_IMAGE_MODULES), $(eval $m-interim-jmod: $($(m)_JMOD_DEPS)))
# Jmods cannot be created until we have the jmod tool ready to run. During
# a normal build we run it from the exploded image, but when cross compiling
@@ -636,12 +652,13 @@
buildtools-modules: create-buildjdk
else
# While actually creating the buildjdk, the default deps applies.
- $(JMOD_TARGETS): $(DEFAULT_JMOD_DEPS)
+ $(JMOD_TARGETS) $(INTERIM_JMOD_TARGETS): $(DEFAULT_JMOD_DEPS)
endif
else
# The normal non cross compilation case uses the default deps.
# To avoid races with the optimize target, that also needs to happen first.
- $(JMOD_TARGETS): $(DEFAULT_JMOD_DEPS) exploded-image-optimize
+ $(JMOD_TARGETS) $(INTERIM_JMOD_TARGETS): $(DEFAULT_JMOD_DEPS) \
+ exploded-image-optimize
endif
zip-security: java.base-java java.security.jgss-java java.security.jgss-libs \
@@ -654,16 +671,17 @@
ifeq ($(ENABLE_GENERATE_CLASSLIST), true)
ifeq ($(CREATE_BUILDJDK), true)
# If creating a buildjdk, the interim image needs to be based on that.
- generate-classlist: create-buildjdk
+ generate-link-opt-data: create-buildjdk
else ifeq ($(EXTERNAL_BUILDJDK), false)
# If an external buildjdk has been provided, we skip generating an
# interim-image and just use the external buildjdk for generating
# classlist.
- generate-classlist: interim-image
+ generate-link-opt-data: interim-image
endif
- generate-classlist: buildtools-jdk
+ generate-link-opt-data: buildtools-jdk
- jdk-image jre-image: generate-classlist
+ # The generated classlist needs to go into java.base-jmod.
+ java.base-jmod jdk-image jre-image: generate-link-opt-data
endif
jdk-image: jmods zip-source source-tips demos samples jrtfs-jar
@@ -695,7 +713,7 @@
create-buildjdk-interim-image: create-buildjdk-copy
- interim-image: $(addsuffix -jmod, $(INTERIM_IMAGE_MODULES))
+ interim-image: $(INTERIM_JMOD_TARGETS)
test-make: clean-test-make