1 #
2 # Copyright (c) 2013, 2026, Oracle and/or its affiliates. All rights reserved.
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 #
5 # This code is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License version 2 only, as
7 # published by the Free Software Foundation. Oracle designates this
8 # particular file as subject to the "Classpath" exception as provided
9 # by Oracle in the LICENSE file that accompanied this code.
10 #
11 # This code is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 # version 2 for more details (a copy is included in the LICENSE file that
15 # accompanied this code).
16 #
17 # You should have received a copy of the GNU General Public License version
18 # 2 along with this work; if not, write to the Free Software Foundation,
19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 #
21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 # or visit www.oracle.com if you need additional information or have any
23 # questions.
24 #
25
26 ################################################################################
27
28 include MakeIncludeStart.gmk
29 ifeq ($(INCLUDE), true)
30
31 ################################################################################
32 # Setup CFLAGS and EXCLUDES for the libjvm compilation, depending on which
33 # jvm features are selected for this jvm variant.
34 ################################################################################
35
36 ifeq ($(call check-jvm-feature, compiler1), true)
37 JVM_CFLAGS_FEATURES += -DCOMPILER1
38 else
39 JVM_EXCLUDE_PATTERNS += c1_ c1/
40 endif
41
42 ifeq ($(call check-jvm-feature, compiler2), true)
43 JVM_CFLAGS_FEATURES += -DCOMPILER2
44 JVM_SRC_DIRS += $(JVM_VARIANT_OUTPUTDIR)/gensrc/adfiles
45 else
46 JVM_EXCLUDES += opto libadt
47 JVM_EXCLUDE_FILES += bcEscapeAnalyzer.cpp ciTypeFlow.cpp
48 JVM_EXCLUDE_PATTERNS += c2_ runtime_ /c2/
49 endif
50
51 ifeq ($(call check-jvm-feature, zero), true)
52 JVM_EXCLUDES += opto libadt
53 JVM_EXCLUDE_PATTERNS += c1_ c1/ c2_ runtime_ /c2/
54 JVM_EXCLUDE_FILES += templateInterpreter.cpp \
55 templateInterpreterGenerator.cpp bcEscapeAnalyzer.cpp ciTypeFlow.cpp
56 JVM_CFLAGS_FEATURES += -DZERO \
57 -DZERO_LIBARCH='"$(OPENJDK_TARGET_CPU_LEGACY_LIB)"' $(LIBFFI_CFLAGS)
58 JVM_LIBS_FEATURES += $(LIBFFI_LIBS)
59 ifeq ($(ENABLE_LIBFFI_BUNDLING), true)
60 JVM_LDFLAGS_FEATURES += $(call SetExecutableOrigin,/..)
61 endif
62 else
63 JVM_EXCLUDE_PATTERNS += /zero/
64 endif
65
66 ifeq ($(JVM_VARIANT), core)
67 JVM_CFLAGS_FEATURES += -DVMTYPE=\"Core\"
68 endif
69
70 ifeq ($(JVM_VARIANT), custom)
71 JVM_CFLAGS_FEATURES += -DVMTYPE=\"Custom\"
72 endif
73
74 ifeq ($(call check-jvm-feature, minimal), true)
75 JVM_CFLAGS_FEATURES += -DMINIMAL_JVM -DVMTYPE=\"Minimal\"
76 ifeq ($(call isTargetOs, linux), true)
77 # Override the default -g with a more liberal strip policy for the
78 # minimal JVM
79 JVM_STRIPFLAGS := --strip-unneeded
80 endif
81 endif
82
83 ifeq ($(call check-jvm-feature, dtrace), true)
84 JVM_CFLAGS_FEATURES += -DDTRACE_ENABLED
85 endif
86
87 ifneq ($(call check-jvm-feature, jvmti), true)
88 JVM_CFLAGS_FEATURES += -DINCLUDE_JVMTI=0
89 JVM_EXCLUDE_FILES += jvmtiGetLoadedClasses.cpp jvmtiThreadState.cpp \
90 jvmtiExtensions.cpp jvmtiImpl.cpp jvmtiManageCapabilities.cpp \
91 jvmtiRawMonitor.cpp jvmtiUtil.cpp jvmtiTrace.cpp jvmtiCodeBlobEvents.cpp \
92 jvmtiEnv.cpp jvmtiRedefineClasses.cpp jvmtiEnvBase.cpp \
93 jvmtiEnvThreadState.cpp jvmtiTagMap.cpp jvmtiEventController.cpp \
94 evmCompat.cpp jvmtiEnter.xsl jvmtiExport.cpp \
95 jvmtiClassFileReconstituter.cpp jvmtiTagMapTable.cpp jvmtiAgent.cpp \
96 jvmtiAgentList.cpp jfrJvmtiAgent.cpp
97 endif
98
99 ifneq ($(call check-jvm-feature, vm-structs), true)
100 JVM_CFLAGS_FEATURES += -DINCLUDE_VM_STRUCTS=0
101 JVM_EXCLUDE_FILES += vmStructs.cpp
102 endif
103
104 ifneq ($(call check-jvm-feature, jni-check), true)
105 JVM_CFLAGS_FEATURES += -DINCLUDE_JNI_CHECK=0
106 JVM_EXCLUDE_FILES += jniCheck.cpp
107 endif
108
109 ifneq ($(call check-jvm-feature, services), true)
110 JVM_CFLAGS_FEATURES += -DINCLUDE_SERVICES=0
111 JVM_EXCLUDE_FILES += heapDumper.cpp heapInspection.cpp \
112 attachListener_$(HOTSPOT_TARGET_OS).cpp attachListener.cpp
113 endif
114
115 ifneq ($(call check-jvm-feature, management), true)
116 JVM_CFLAGS_FEATURES += -DINCLUDE_MANAGEMENT=0
117 endif
118
119 ifneq ($(call check-jvm-feature, cds), true)
120 JVM_CFLAGS_FEATURES += -DINCLUDE_CDS=0
121 JVM_EXCLUDE_FILES += \
122 aotCodeCache.cpp \
123 classLoaderDataShared.cpp \
124 classLoaderExt.cpp \
125 systemDictionaryShared.cpp \
126 trainingData.cpp
127 JVM_EXCLUDE_PATTERNS += cds/
128 endif
129
130 ifneq ($(call check-jvm-feature, g1gc), true)
131 JVM_CFLAGS_FEATURES += -DINCLUDE_G1GC=0
132 JVM_EXCLUDE_PATTERNS += gc/g1
133 endif
134
135 ifneq ($(call check-jvm-feature, parallelgc), true)
136 JVM_CFLAGS_FEATURES += -DINCLUDE_PARALLELGC=0
137 JVM_EXCLUDE_PATTERNS += gc/parallel
138 endif
139
140 ifneq ($(call check-jvm-feature, serialgc), true)
141 JVM_CFLAGS_FEATURES += -DINCLUDE_SERIALGC=0
142 JVM_EXCLUDE_PATTERNS += gc/serial
143 endif
144
145 ifneq ($(call check-jvm-feature, epsilongc), true)
146 JVM_CFLAGS_FEATURES += -DINCLUDE_EPSILONGC=0
147 JVM_EXCLUDE_PATTERNS += gc/epsilon
148 endif
149
150 ifneq ($(call check-jvm-feature, zgc), true)
151 JVM_CFLAGS_FEATURES += -DINCLUDE_ZGC=0
152 JVM_EXCLUDE_PATTERNS += gc/z
153 endif
154
155 ifneq ($(call check-jvm-feature, shenandoahgc), true)
156 JVM_CFLAGS_FEATURES += -DINCLUDE_SHENANDOAHGC=0
157 JVM_EXCLUDE_PATTERNS += gc/shenandoah
158 endif
159
160 ifneq ($(call check-jvm-feature, jfr), true)
161 JVM_CFLAGS_FEATURES += -DINCLUDE_JFR=0
162 JVM_EXCLUDE_PATTERNS += jfr
163 JVM_EXCLUDE_FILES += compilerEvent.cpp
164 endif
165
166 ################################################################################
167
168 ifeq ($(call check-jvm-feature, link-time-opt), true)
169 # Set JVM_OPTIMIZATION directly so other jvm-feature flags can override it
170 # later on if desired
171 JVM_OPTIMIZATION := HIGHEST_JVM
172 JVM_LTO := true
173 ifneq ($(call isCompiler, microsoft), true)
174 JVM_LDFLAGS_FEATURES += $(CXX_O_FLAG_HIGHEST_JVM)
175 endif
176 else
177 JVM_LTO := false
178 ifeq ($(call isCompiler, gcc), true)
179 JVM_LDFLAGS_FEATURES += -O1
180 endif
181 endif
182
183 ifeq ($(call check-jvm-feature, opt-size), true)
184 JVM_OPTIMIZATION := SIZE
185 OPT_SPEED_SRC := \
186 allocation.cpp \
187 assembler.cpp \
188 barrierSet.cpp \
189 basicLock.cpp \
190 bytecode.cpp \
191 bytecodeInterpreter.cpp \
192 c1_Compilation.cpp \
193 c1_Compiler.cpp \
194 c1_GraphBuilder.cpp \
195 c1_LinearScan.cpp \
196 c1_LIR.cpp \
197 ciEnv.cpp \
198 ciObjectFactory.cpp \
199 codeBlob.cpp \
200 constantPool.cpp \
201 constMethod.cpp \
202 classLoader.cpp \
203 classLoaderData.cpp \
204 classFileParser.cpp \
205 classFileStream.cpp \
206 cpCache.cpp \
207 defNewGeneration.cpp \
208 frame_arm.cpp \
209 frame_aarch64.cpp \
210 frame_ppc.cpp \
211 frame_s390.cpp \
212 frame_x86.cpp \
213 generation.cpp \
214 growableArray.cpp \
215 handles.cpp \
216 heap.cpp \
217 icache.cpp \
218 icache_arm.cpp \
219 icache_aarch64.cpp \
220 icache_ppc.cpp \
221 icache_s390.cpp \
222 icache_x86.cpp \
223 instanceKlass.cpp \
224 invocationCounter.cpp \
225 iterator.cpp \
226 javaCalls.cpp \
227 javaClasses.cpp \
228 jniFastGetField_arm.cpp \
229 jvm.cpp \
230 linkResolver.cpp \
231 klass.cpp \
232 klassVtable.cpp \
233 memRegion.cpp \
234 memoryPool.cpp \
235 method.cpp \
236 methodHandles.cpp \
237 methodHandles_arm.cpp \
238 methodLiveness.cpp \
239 metaspace.cpp \
240 mutex.cpp \
241 mutexLocker.cpp \
242 nativeLookup.cpp \
243 objArrayKlass.cpp \
244 os_linux.cpp \
245 os_linux_arm.cpp \
246 resourceArea.cpp \
247 rewriter.cpp \
248 sharedRuntime.cpp \
249 signature.cpp \
250 space.cpp \
251 stackMapTable.cpp \
252 symbolTable.cpp \
253 systemDictionary.cpp \
254 symbol.cpp \
255 synchronizer.cpp \
256 timer.cpp \
257 typeArrayKlass.cpp \
258 unsafe.cpp \
259 utf8.cpp \
260 vmSymbols.cpp \
261 #
262
263 $(foreach s, $(OPT_SPEED_SRC), \
264 $(eval BUILD_LIBJVM_$s_OPTIMIZATION := HIGHEST_JVM))
265
266 ifneq ($(filter $(TOOLCHAIN_TYPE), gcc clang), )
267 BUILD_LIBJVM_systemDictionary.cpp_CXXFLAGS := -fno-optimize-sibling-calls
268 endif
269 endif
270
271 ################################################################################
272
273 endif # include guard
274 include MakeIncludeEnd.gmk