Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
8293116: Incremental JDK build could be sped up
Browse files Browse the repository at this point in the history
Reviewed-by: erikj, vromero, ihse
  • Loading branch information
lahodaj committed Sep 21, 2022
1 parent e9401e6 commit cd1cdcd
Show file tree
Hide file tree
Showing 7 changed files with 590 additions and 24 deletions.
30 changes: 28 additions & 2 deletions make/CompileInterimLangtools.gmk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2014, 2022, 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 @@ -48,6 +48,30 @@ $(BUILDTOOLS_OUTPUTDIR)/gensrc/%.interim/module-info.java: \
TARGETS += $(patsubst %, $(BUILDTOOLS_OUTPUTDIR)/gensrc/%/module-info.java, \
$(INTERIM_LANGTOOLS_MODULES))

################################################################################
# Generate interim versions of the ToolProvider.java files for the interim
# langtools modules, which will allow to load javac from the interim
# jdk.compiler.

INTERIM_TOOL_PROVIDER_PATTERN := \
$(foreach m, $(INTERIM_LANGTOOLS_BASE_MODULES), -e 's/"$m"/"$m.interim"/g')

$(BUILDTOOLS_OUTPUTDIR)/gensrc/java.compiler.interim/javax/tools/ToolProvider.java: \
$(TOPDIR)/src/java.compiler/share/classes/javax/tools/ToolProvider.java
$(call LogInfo, Generating ToolProvider.java for java.compiler.interim)
$(call MakeDir, $(@D))
$(SED) $(INTERIM_TOOL_PROVIDER_PATTERN) $< > $@

java.compiler.interim_EXTRA_FILES := \
$(BUILDTOOLS_OUTPUTDIR)/gensrc/java.compiler.interim/javax/tools/ToolProvider.java

TARGETS += $(BUILDTOOLS_OUTPUTDIR)/gensrc/java.compiler.interim/javax/tools/ToolProvider.java

################################################################################
# Use the up-to-date PreviewFeature.java and NoPreview.java from the current
# sources, instead of the versions from the boot JDK, as javac may be referring
# to constants from the up-to-date versions.

$(eval $(call SetupCopyFiles, COPY_PREVIEW_FEATURES, \
FILES := $(TOPDIR)/src/java.base/share/classes/jdk/internal/javac/PreviewFeature.java \
$(TOPDIR)/src/java.base/share/classes/jdk/internal/javac/NoPreview.java, \
Expand All @@ -73,8 +97,10 @@ define SetupInterimModule
$(TOPDIR)/src/$1/share/classes, \
EXCLUDES := sun javax/tools/snippet-files, \
EXCLUDE_FILES := $(TOPDIR)/src/$1/share/classes/module-info.java \
$(TOPDIR)/src/$1/share/classes/javax/tools/ToolProvider.java \
Standard.java, \
EXTRA_FILES := $(BUILDTOOLS_OUTPUTDIR)/gensrc/$1.interim/module-info.java, \
EXTRA_FILES := $(BUILDTOOLS_OUTPUTDIR)/gensrc/$1.interim/module-info.java \
$($1.interim_EXTRA_FILES), \
COPY := .gif .png .xml .css .svg .js .js.template .txt javax.tools.JavaCompilerTool, \
BIN := $(BUILDTOOLS_OUTPUTDIR)/interim_langtools_modules/$1.interim, \
DISABLED_WARNINGS := module options, \
Expand Down
4 changes: 2 additions & 2 deletions make/CompileJavaModules.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ TARGETS += $($(MODULE))
# Since the other modules are declared in different invocations of this file,
# use the macro to find the correct target file to depend on.
# Only the javac compilation actually depends on other modules so limit
# dependency declaration to that by using the *_COMPILE_TARGET variable.
$($(MODULE)_COMPILE_TARGET): $(foreach d, $(call FindDepsForModule, $(MODULE)), \
# dependency declaration to that by using the *_MODFILELIST variable.
$($(MODULE)_MODFILELIST): $(foreach d, $(call FindDepsForModule, $(MODULE)), \
$(call SetupJavaCompilationApiTarget, $d, \
$(if $($d_BIN), $($d_BIN), $(JDK_OUTPUTDIR)/modules/$d)))

Expand Down
9 changes: 8 additions & 1 deletion make/CompileToolsJdk.gmk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2022, 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 @@ -77,6 +77,13 @@ $(eval $(call SetupJavaCompilation, COMPILE_DEPEND, \
INCLUDES := build/tools/depend, \
BIN := $(BUILDTOOLS_OUTPUTDIR)/depend, \
DISABLED_WARNINGS := options, \
JAVAC_FLAGS := \
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED, \
))

DEPEND_SERVICE_PROVIDER := $(BUILDTOOLS_OUTPUTDIR)/depend/META-INF/services/com.sun.source.util.Plugin
Expand Down
25 changes: 23 additions & 2 deletions make/common/JavaCompilation.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,10 @@ define SetupJavaCompilationBody

$1_COMPILE_TARGET := $$($1_BIN)$$($1_MODULE_SUBDIR)/_the.$1_batch
$1_FILELIST := $$($1_BIN)$$($1_MODULE_SUBDIR)/_the.$1_batch.filelist
$1_MODFILELIST := $$($1_BIN)$$($1_MODULE_SUBDIR)/_the.$1_batch.modfiles

$1_API_TARGET := $$($1_BIN)$$($1_MODULE_SUBDIR)/_the.$1_pubapi
$1_API_INTERNAL := $$($1_BIN)$$($1_MODULE_SUBDIR)/_the.$1_internalapi

# Put headers in a temp dir to filter out those that actually
# changed before copying them to the real header dir.
Expand Down Expand Up @@ -437,6 +439,8 @@ define SetupJavaCompilationBody
$1_API_DIGEST_FLAGS := \
-classpath $$(BUILDTOOLS_OUTPUTDIR)/depend \
-Xplugin:"depend $$($1_API_TARGET)" \
"-XDinternalAPIPath=$$($1_API_INTERNAL)" \
"-XDLOG_LEVEL=$(LOG_LEVEL)" \
#

$1_EXTRA_DEPS := $$(BUILDTOOLS_OUTPUTDIR)/depend/_the.COMPILE_DEPEND_batch
Expand All @@ -447,16 +451,33 @@ define SetupJavaCompilationBody
# list of files.
$$($1_FILELIST): $$($1_SRCS) $$($1_VARDEPS_FILE)
$$(call MakeDir, $$(@D))
$$(call LogWarn, Compiling $$(words $$($1_SRCS)) files for $1)
$$(call LogWarn, Compiling up to $$(words $$($1_SRCS)) files for $1)
$$(eval $$(call ListPathsSafely, $1_SRCS, $$($1_FILELIST)))

# Create a $$($1_MODFILELIST) file with significant modified dependencies
# (either sources files or the other mark dependencies).
# It is then sent using a side-channel
# to the custom Depend plugin. The Depend plugin will check the provided list
# of modified files, and if none of the Java source files is changed in a way
# observable from outside of the file, and the list of modified files does
# not include a non-Java source file, it will only compile the modified files.
# Otherwise, all module's sources will be compiled. If a non-Java file is included,
# it will be considered to be a significant change, and all module source will
# be recompiled
$$($1_MODFILELIST): $$($1_SRCS) $$($1_DEPENDS) \
$$($1_VARDEPS_FILE) $$($1_EXTRA_DEPS) $$($1_JAVAC_SERVER_CONFIG)
$$(eval $1_MODFILES := $$?)
$$(eval $$(call ListPathsSafely, $1_MODFILES, $$($1_MODFILELIST)))

# Do the actual compilation
$$($1_COMPILE_TARGET): $$($1_SRCS) $$($1_FILELIST) $$($1_DEPENDS) \
$$($1_VARDEPS_FILE) $$($1_EXTRA_DEPS) $$($1_JAVAC_SERVER_CONFIG)
$$($1_VARDEPS_FILE) $$($1_EXTRA_DEPS) $$($1_JAVAC_SERVER_CONFIG) \
$$($1_MODFILELIST)
$$(call MakeDir, $$(@D))
$$(call ExecuteWithLog, $$($1_BIN)$$($1_MODULE_SUBDIR)/_the.$$($1_SAFE_NAME)_batch, \
$$($1_JAVAC_CMD) $$($1_FLAGS) \
$$($1_API_DIGEST_FLAGS) \
-XDmodifiedInputs=$$($1_MODFILELIST) \
-d $$($1_BIN) $$($1_HEADERS_ARG) @$$($1_FILELIST)) && \
$(TOUCH) $$@

Expand Down
Loading

0 comments on commit cd1cdcd

Please sign in to comment.