-
Notifications
You must be signed in to change notification settings - Fork 117
/
Copy pathDDR.gmk
180 lines (150 loc) · 7.37 KB
/
DDR.gmk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# ===========================================================================
# (c) Copyright IBM Corp. 2018, 2025 All Rights Reserved
# ===========================================================================
# 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.
#
# IBM designates this particular file as subject to the "Classpath" exception
# as provided by IBM 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, see <http://www.gnu.org/licenses/>.
# ===========================================================================
# ===========================================================================
# Overview:
# - generate
# * compile tools
# * generate java pointer source files
# * generate java structure stub source files
# * generate pointer and structure stub class files
# - compile_check
# * compile DDR_VM source with the generated class files from above
# ===========================================================================
.PHONY : no_default generate
no_default :
$(error DDR.gmk has no default target)
# ignore warnings in Java code - see SetupJavaCompilers.gmk
JAVAC_WARNINGS := -Xlint:-removal
include $(SPEC)
include $(TOPDIR)/make/common/MakeBase.gmk
include $(TOPDIR)/make/common/JavaCompilation.gmk
include $(TOPDIR)/make/common/SetupJavaCompilers.gmk
# The main source directory.
DDR_VM_SRC_ROOT := $(J9JCL_SOURCES_DIR)/openj9.dtfj/share/classes
# The top-level directory for intermediate artifacts.
DDR_SUPPORT_DIR := $(SUPPORT_OUTPUTDIR)/ddr
# The blob and superset files are built with the VM.
DDR_BLOB_FILE := $(OPENJ9_VM_BUILD_DIR)/j9ddr.dat
DDR_SUPERSET_FILE := $(OUTPUTDIR)/vm/superset.dat
# Where to write class files.
DDR_CLASSES_BIN := $(DDR_SUPPORT_DIR)/classes
DDR_TEST_BIN := $(DDR_SUPPORT_DIR)/test
DDR_TOOLS_BIN := $(DDR_SUPPORT_DIR)/tools
# Where to write generated source files.
DDR_GENSRC_DIR := $(SUPPORT_OUTPUTDIR)/gensrc/openj9.dtfj
# Marker files signalling that derived artifacts are up-to-date.
DDR_CLASSES_MARKER := $(DDR_SUPPORT_DIR)/classes.done
DDR_POINTERS_MARKER := $(DDR_SUPPORT_DIR)/gensrc-pointers.done
DDR_STRUCTURES_MARKER := $(DDR_SUPPORT_DIR)/gensrc-structures.done
#############################################################################
# Build the tools we will need.
$(eval $(call SetupJavaCompilation,BUILD_DDR_TOOLS, \
SETUP := GENERATE_OLDBYTECODE, \
BIN := $(DDR_TOOLS_BIN), \
CLASSPATH := $(JDK_OUTPUTDIR)/modules/java.base, \
SRC := $(DDR_VM_SRC_ROOT), \
INCLUDE_FILES := \
com/ibm/j9ddr/BytecodeGenerator.java \
com/ibm/j9ddr/CTypeParser.java \
com/ibm/j9ddr/StructureHeader.java \
com/ibm/j9ddr/StructureReader.java \
com/ibm/j9ddr/StructureTypeManager.java \
com/ibm/j9ddr/logging/LoggerNames.java \
com/ibm/j9ddr/tools/ClassGenerator.java \
com/ibm/j9ddr/tools/FlagStructureList.java \
com/ibm/j9ddr/tools/PointerGenerator.java \
com/ibm/j9ddr/tools/StructureStubGenerator.java \
com/ibm/j9ddr/tools/store/J9DDRStructureStore.java \
com/ibm/j9ddr/tools/store/StructureKey.java \
com/ibm/j9ddr/tools/store/StructureMismatchError.java \
))
# Any new references to constants must be paired with additions to the compatibility
# list unless those constants were defined long ago.
DDR_COMPATIBILITY_FILE := $(DDR_VM_SRC_ROOT)/com/ibm/j9ddr/CompatibilityConstants29.dat
#############################################################################
# When StructureReader opens the blob, it must be able to find AuxFieldInfo29.dat
# and StructureAliases*.dat, so they must be on the classpath for a non-openj9
# bootjdk. When using an openj9 bootjdk, we don't want to use old versions that
# might be included: Patching openj9.dtfj fixes that. We use FixPath because
# fixpath.sh would only fix the first entry of the path.
DDR_PATH_SEP := $(if $(filter $(OPENJDK_BUILD_OS),windows),;,:)
DDR_TOOLS_PATHLIST := "$(call FixPath,$(DDR_TOOLS_BIN))$(DDR_PATH_SEP)$(call FixPath,$(DDR_VM_SRC_ROOT))"
DDR_TOOLS_OPTIONS := \
-cp $(DDR_TOOLS_PATHLIST) \
--patch-module=openj9.dtfj=$(DDR_TOOLS_PATHLIST)
# Only fields listed in this file can be directly accessed by hand-written DDR code;
# its contents influence the generated class files.
DDR_FIELDS_FILE := $(DDR_VM_SRC_ROOT)/com/ibm/j9ddr/AuxFieldInfo29.dat
$(DDR_CLASSES_MARKER) : $(DDR_BLOB_FILE) $(DDR_COMPATIBILITY_FILE) $(DDR_FIELDS_FILE) $(BUILD_DDR_TOOLS)
@$(ECHO) Generating DDR pointer and structure class files
@$(RM) -rf $(DDR_CLASSES_BIN)
@$(JAVA) $(DDR_TOOLS_OPTIONS) com.ibm.j9ddr.tools.ClassGenerator \
--blob=$(DDR_BLOB_FILE) \
--out=$(DDR_CLASSES_BIN)
@$(TOUCH) $@
$(DDR_POINTERS_MARKER) : $(DDR_SUPERSET_FILE) $(DDR_FIELDS_FILE) $(BUILD_DDR_TOOLS)
@$(ECHO) Generating DDR pointer class source files
@$(JAVA) $(DDR_TOOLS_OPTIONS) com.ibm.j9ddr.tools.PointerGenerator \
-a $(DDR_FIELDS_FILE) \
-f $(dir $(DDR_SUPERSET_FILE)) \
-s $(notdir $(DDR_SUPERSET_FILE)) \
-p com.ibm.j9ddr.vm29.pointer.generated \
-v 29 \
-o $(DDR_GENSRC_DIR)
@$(TOUCH) $@
DDR_RESTRICT_FILE := $(OPENJ9_TOPDIR)/debugtools/DDR_VM/data/superset-constants.dat
$(DDR_STRUCTURES_MARKER) : $(DDR_SUPERSET_FILE) $(DDR_RESTRICT_FILE) $(DDR_COMPATIBILITY_FILE) $(DDR_FIELDS_FILE) $(BUILD_DDR_TOOLS)
@$(ECHO) Generating DDR structure stub source files
@$(JAVA) $(DDR_TOOLS_OPTIONS) com.ibm.j9ddr.tools.StructureStubGenerator \
-f $(dir $(DDR_SUPERSET_FILE)) \
-s $(notdir $(DDR_SUPERSET_FILE)) \
-p com.ibm.j9ddr.vm29.structure \
-r $(DDR_RESTRICT_FILE) \
-c $(DDR_COMPATIBILITY_FILE) \
-a $(DDR_FIELDS_FILE) \
-o $(DDR_GENSRC_DIR)
@$(TOUCH) $@
# The occasional build has been seen to fail when $(CP) thinks it must create
# a directory only to discover that another process (i.e. PointerGenerator
# or StructureStubGenerator) has already done so:
# /usr/bin/cp: cannot create directory 'support/gensrc/openj9.dtfj/com/ibm/j9ddr/vm29': File exists
# To avoid that problem, we insist that $(CP) runs before the other tasks.
$(DDR_POINTERS_MARKER) $(DDR_STRUCTURES_MARKER) : $(call FindFiles,$(DDR_VM_SRC_ROOT))
generate : $(DDR_CLASSES_MARKER) $(DDR_POINTERS_MARKER) $(DDR_STRUCTURES_MARKER)
#############################################################################
# SetupJavaCompilation requires that SRC directories exist: the 'generate' target,
# which creates $(DDR_GENSRC_DIR), must have been built previously.
ifneq (,$(wildcard $(DDR_GENSRC_DIR)))
# Compile DDR code again, to ensure compatibility with class files
# as they would be dynamically generated from the blob.
$(eval $(call SetupJavaCompilation,BUILD_J9DDR_TEST_CLASSES, \
SETUP := GENERATE_JDKBYTECODE, \
DEPENDS := $(DDR_CLASSES_MARKER), \
ADD_JAVAC_FLAGS := \
--patch-module openj9.dtfj=$(DDR_CLASSES_BIN) \
--upgrade-module-path $(JDK_OUTPUTDIR)/modules \
--system none, \
BIN := $(DDR_TEST_BIN), \
CLASSPATH := $(DDR_CLASSES_BIN), \
SRC := $(DDR_VM_SRC_ROOT) \
))
.PHONY : compile_check
compile_check : $(BUILD_J9DDR_TEST_CLASSES)
endif # DDR_GENSRC_DIR