Skip to content

Commit cd1cdcd

Browse files
committed
8293116: Incremental JDK build could be sped up
Reviewed-by: erikj, vromero, ihse
1 parent e9401e6 commit cd1cdcd

File tree

7 files changed

+590
-24
lines changed

7 files changed

+590
-24
lines changed

make/CompileInterimLangtools.gmk

+28-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
33
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
#
55
# This code is free software; you can redistribute it and/or modify it
@@ -48,6 +48,30 @@ $(BUILDTOOLS_OUTPUTDIR)/gensrc/%.interim/module-info.java: \
4848
TARGETS += $(patsubst %, $(BUILDTOOLS_OUTPUTDIR)/gensrc/%/module-info.java, \
4949
$(INTERIM_LANGTOOLS_MODULES))
5050

51+
################################################################################
52+
# Generate interim versions of the ToolProvider.java files for the interim
53+
# langtools modules, which will allow to load javac from the interim
54+
# jdk.compiler.
55+
56+
INTERIM_TOOL_PROVIDER_PATTERN := \
57+
$(foreach m, $(INTERIM_LANGTOOLS_BASE_MODULES), -e 's/"$m"/"$m.interim"/g')
58+
59+
$(BUILDTOOLS_OUTPUTDIR)/gensrc/java.compiler.interim/javax/tools/ToolProvider.java: \
60+
$(TOPDIR)/src/java.compiler/share/classes/javax/tools/ToolProvider.java
61+
$(call LogInfo, Generating ToolProvider.java for java.compiler.interim)
62+
$(call MakeDir, $(@D))
63+
$(SED) $(INTERIM_TOOL_PROVIDER_PATTERN) $< > $@
64+
65+
java.compiler.interim_EXTRA_FILES := \
66+
$(BUILDTOOLS_OUTPUTDIR)/gensrc/java.compiler.interim/javax/tools/ToolProvider.java
67+
68+
TARGETS += $(BUILDTOOLS_OUTPUTDIR)/gensrc/java.compiler.interim/javax/tools/ToolProvider.java
69+
70+
################################################################################
71+
# Use the up-to-date PreviewFeature.java and NoPreview.java from the current
72+
# sources, instead of the versions from the boot JDK, as javac may be referring
73+
# to constants from the up-to-date versions.
74+
5175
$(eval $(call SetupCopyFiles, COPY_PREVIEW_FEATURES, \
5276
FILES := $(TOPDIR)/src/java.base/share/classes/jdk/internal/javac/PreviewFeature.java \
5377
$(TOPDIR)/src/java.base/share/classes/jdk/internal/javac/NoPreview.java, \
@@ -73,8 +97,10 @@ define SetupInterimModule
7397
$(TOPDIR)/src/$1/share/classes, \
7498
EXCLUDES := sun javax/tools/snippet-files, \
7599
EXCLUDE_FILES := $(TOPDIR)/src/$1/share/classes/module-info.java \
100+
$(TOPDIR)/src/$1/share/classes/javax/tools/ToolProvider.java \
76101
Standard.java, \
77-
EXTRA_FILES := $(BUILDTOOLS_OUTPUTDIR)/gensrc/$1.interim/module-info.java, \
102+
EXTRA_FILES := $(BUILDTOOLS_OUTPUTDIR)/gensrc/$1.interim/module-info.java \
103+
$($1.interim_EXTRA_FILES), \
78104
COPY := .gif .png .xml .css .svg .js .js.template .txt javax.tools.JavaCompilerTool, \
79105
BIN := $(BUILDTOOLS_OUTPUTDIR)/interim_langtools_modules/$1.interim, \
80106
DISABLED_WARNINGS := module options, \

make/CompileJavaModules.gmk

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ TARGETS += $($(MODULE))
121121
# Since the other modules are declared in different invocations of this file,
122122
# use the macro to find the correct target file to depend on.
123123
# Only the javac compilation actually depends on other modules so limit
124-
# dependency declaration to that by using the *_COMPILE_TARGET variable.
125-
$($(MODULE)_COMPILE_TARGET): $(foreach d, $(call FindDepsForModule, $(MODULE)), \
124+
# dependency declaration to that by using the *_MODFILELIST variable.
125+
$($(MODULE)_MODFILELIST): $(foreach d, $(call FindDepsForModule, $(MODULE)), \
126126
$(call SetupJavaCompilationApiTarget, $d, \
127127
$(if $($d_BIN), $($d_BIN), $(JDK_OUTPUTDIR)/modules/$d)))
128128

make/CompileToolsJdk.gmk

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
33
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
#
55
# This code is free software; you can redistribute it and/or modify it
@@ -77,6 +77,13 @@ $(eval $(call SetupJavaCompilation, COMPILE_DEPEND, \
7777
INCLUDES := build/tools/depend, \
7878
BIN := $(BUILDTOOLS_OUTPUTDIR)/depend, \
7979
DISABLED_WARNINGS := options, \
80+
JAVAC_FLAGS := \
81+
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
82+
--add-exports jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED \
83+
--add-exports jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED \
84+
--add-exports jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED \
85+
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
86+
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED, \
8087
))
8188

8289
DEPEND_SERVICE_PROVIDER := $(BUILDTOOLS_OUTPUTDIR)/depend/META-INF/services/com.sun.source.util.Plugin

make/common/JavaCompilation.gmk

+23-2
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,10 @@ define SetupJavaCompilationBody
402402

403403
$1_COMPILE_TARGET := $$($1_BIN)$$($1_MODULE_SUBDIR)/_the.$1_batch
404404
$1_FILELIST := $$($1_BIN)$$($1_MODULE_SUBDIR)/_the.$1_batch.filelist
405+
$1_MODFILELIST := $$($1_BIN)$$($1_MODULE_SUBDIR)/_the.$1_batch.modfiles
405406

406407
$1_API_TARGET := $$($1_BIN)$$($1_MODULE_SUBDIR)/_the.$1_pubapi
408+
$1_API_INTERNAL := $$($1_BIN)$$($1_MODULE_SUBDIR)/_the.$1_internalapi
407409

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

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

457+
# Create a $$($1_MODFILELIST) file with significant modified dependencies
458+
# (either sources files or the other mark dependencies).
459+
# It is then sent using a side-channel
460+
# to the custom Depend plugin. The Depend plugin will check the provided list
461+
# of modified files, and if none of the Java source files is changed in a way
462+
# observable from outside of the file, and the list of modified files does
463+
# not include a non-Java source file, it will only compile the modified files.
464+
# Otherwise, all module's sources will be compiled. If a non-Java file is included,
465+
# it will be considered to be a significant change, and all module source will
466+
# be recompiled
467+
$$($1_MODFILELIST): $$($1_SRCS) $$($1_DEPENDS) \
468+
$$($1_VARDEPS_FILE) $$($1_EXTRA_DEPS) $$($1_JAVAC_SERVER_CONFIG)
469+
$$(eval $1_MODFILES := $$?)
470+
$$(eval $$(call ListPathsSafely, $1_MODFILES, $$($1_MODFILELIST)))
471+
453472
# Do the actual compilation
454473
$$($1_COMPILE_TARGET): $$($1_SRCS) $$($1_FILELIST) $$($1_DEPENDS) \
455-
$$($1_VARDEPS_FILE) $$($1_EXTRA_DEPS) $$($1_JAVAC_SERVER_CONFIG)
474+
$$($1_VARDEPS_FILE) $$($1_EXTRA_DEPS) $$($1_JAVAC_SERVER_CONFIG) \
475+
$$($1_MODFILELIST)
456476
$$(call MakeDir, $$(@D))
457477
$$(call ExecuteWithLog, $$($1_BIN)$$($1_MODULE_SUBDIR)/_the.$$($1_SAFE_NAME)_batch, \
458478
$$($1_JAVAC_CMD) $$($1_FLAGS) \
459479
$$($1_API_DIGEST_FLAGS) \
480+
-XDmodifiedInputs=$$($1_MODFILELIST) \
460481
-d $$($1_BIN) $$($1_HEADERS_ARG) @$$($1_FILELIST)) && \
461482
$(TOUCH) $$@
462483

0 commit comments

Comments
 (0)