1 #
2 # Copyright (c) 2013, 2025, 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, jvmci), true)
100 JVM_CFLAGS_FEATURES += -DINCLUDE_JVMCI=0
101 JVM_EXCLUDES += jvmci
102 JVM_EXCLUDE_FILES += jvmciCodeInstaller_$(HOTSPOT_TARGET_CPU_ARCH).cpp
103 endif
104
105 ifneq ($(call check-jvm-feature, vm-structs), true)
106 JVM_CFLAGS_FEATURES += -DINCLUDE_VM_STRUCTS=0
107 JVM_EXCLUDE_FILES += vmStructs.cpp
108 endif
109
110 ifneq ($(call check-jvm-feature, jni-check), true)
111 JVM_CFLAGS_FEATURES += -DINCLUDE_JNI_CHECK=0
112 JVM_EXCLUDE_FILES += jniCheck.cpp
113 endif
114
115 ifneq ($(call check-jvm-feature, services), true)
116 JVM_CFLAGS_FEATURES += -DINCLUDE_SERVICES=0
117 JVM_EXCLUDE_FILES += heapDumper.cpp heapInspection.cpp \
118 attachListener_$(HOTSPOT_TARGET_OS).cpp attachListener.cpp
119 endif
120
121 ifneq ($(call check-jvm-feature, management), true)
122 JVM_CFLAGS_FEATURES += -DINCLUDE_MANAGEMENT=0
123 endif
124
125 ifneq ($(call check-jvm-feature, cds), true)
126 JVM_CFLAGS_FEATURES += -DINCLUDE_CDS=0
127 JVM_EXCLUDE_FILES += \
128 aotCodeCache.cpp \
129 classLoaderDataShared.cpp \
130 classLoaderExt.cpp \
131 systemDictionaryShared.cpp \
132 trainingData.cpp
133 JVM_EXCLUDE_PATTERNS += cds/
134 endif
135
136 ifneq ($(call check-jvm-feature, g1gc), true)
137 JVM_CFLAGS_FEATURES += -DINCLUDE_G1GC=0
138 JVM_EXCLUDE_PATTERNS += gc/g1
139 endif
140
141 ifneq ($(call check-jvm-feature, parallelgc), true)
142 JVM_CFLAGS_FEATURES += -DINCLUDE_PARALLELGC=0
143 JVM_EXCLUDE_PATTERNS += gc/parallel
144 endif
145
146 ifneq ($(call check-jvm-feature, serialgc), true)
147 JVM_CFLAGS_FEATURES += -DINCLUDE_SERIALGC=0
148 JVM_EXCLUDE_PATTERNS += gc/serial
149 endif
150
151 ifneq ($(call check-jvm-feature, epsilongc), true)
152 JVM_CFLAGS_FEATURES += -DINCLUDE_EPSILONGC=0
153 JVM_EXCLUDE_PATTERNS += gc/epsilon
154 endif
155
156 ifneq ($(call check-jvm-feature, zgc), true)
157 JVM_CFLAGS_FEATURES += -DINCLUDE_ZGC=0
158 JVM_EXCLUDE_PATTERNS += gc/z
159 endif
160
161 ifneq ($(call check-jvm-feature, shenandoahgc), true)
162 JVM_CFLAGS_FEATURES += -DINCLUDE_SHENANDOAHGC=0
163 JVM_EXCLUDE_PATTERNS += gc/shenandoah
164 endif
165
166 ifneq ($(call check-jvm-feature, jfr), true)
167 JVM_CFLAGS_FEATURES += -DINCLUDE_JFR=0
168 JVM_EXCLUDE_PATTERNS += jfr
169 JVM_EXCLUDE_FILES += compilerEvent.cpp
170 endif
171
172 ################################################################################
173
174 ifeq ($(call check-jvm-feature, link-time-opt), true)
175 # Set JVM_OPTIMIZATION directly so other jvm-feature flags can override it
176 # later on if desired
177 JVM_OPTIMIZATION := HIGHEST_JVM
178 ifeq ($(call isCompiler, gcc), true)
179 JVM_CFLAGS_FEATURES += -flto=auto -fuse-linker-plugin -fno-strict-aliasing \
180 -fno-fat-lto-objects
181 JVM_LDFLAGS_FEATURES += $(CXX_O_FLAG_HIGHEST_JVM) -flto=auto \
182 -fuse-linker-plugin -fno-strict-aliasing
183 else ifeq ($(call isCompiler, clang), true)
184 JVM_CFLAGS_FEATURES += -flto -fno-strict-aliasing
185 ifeq ($(call isBuildOs, aix), true)
186 JVM_CFLAGS_FEATURES += -ffat-lto-objects
187 endif
188 JVM_LDFLAGS_FEATURES += $(CXX_O_FLAG_HIGHEST_JVM) -flto -fno-strict-aliasing
189 else ifeq ($(call isCompiler, microsoft), true)
190 JVM_CFLAGS_FEATURES += -GL
191 JVM_LDFLAGS_FEATURES += -LTCG:INCREMENTAL
192 endif
193 else
194 ifeq ($(call isCompiler, gcc), true)
195 JVM_LDFLAGS_FEATURES += -O1
196 endif
197 endif
198
199 ifeq ($(call check-jvm-feature, opt-size), true)
200 JVM_OPTIMIZATION := SIZE
201 OPT_SPEED_SRC := \
202 allocation.cpp \
203 assembler.cpp \
204 barrierSet.cpp \
205 basicLock.cpp \
206 bytecode.cpp \
207 bytecodeInterpreter.cpp \
208 c1_Compilation.cpp \
209 c1_Compiler.cpp \
210 c1_GraphBuilder.cpp \
211 c1_LinearScan.cpp \
212 c1_LIR.cpp \
213 ciEnv.cpp \
214 ciObjectFactory.cpp \
215 codeBlob.cpp \
216 constantPool.cpp \
217 constMethod.cpp \
218 classLoader.cpp \
219 classLoaderData.cpp \
220 classFileParser.cpp \
221 classFileStream.cpp \
222 cpCache.cpp \
223 defNewGeneration.cpp \
224 frame_arm.cpp \
225 frame_aarch64.cpp \
226 frame_ppc.cpp \
227 frame_s390.cpp \
228 frame_x86.cpp \
229 generation.cpp \
230 growableArray.cpp \
231 handles.cpp \
232 heap.cpp \
233 icache.cpp \
234 icache_arm.cpp \
235 icache_aarch64.cpp \
236 icache_ppc.cpp \
237 icache_s390.cpp \
238 icache_x86.cpp \
239 instanceKlass.cpp \
240 invocationCounter.cpp \
241 iterator.cpp \
242 javaCalls.cpp \
243 javaClasses.cpp \
244 jniFastGetField_arm.cpp \
245 jvm.cpp \
246 linkResolver.cpp \
247 klass.cpp \
248 klassVtable.cpp \
249 memRegion.cpp \
250 memoryPool.cpp \
251 method.cpp \
252 methodHandles.cpp \
253 methodHandles_arm.cpp \
254 methodLiveness.cpp \
255 metaspace.cpp \
256 mutex.cpp \
257 mutexLocker.cpp \
258 nativeLookup.cpp \
259 objArrayKlass.cpp \
260 os_linux.cpp \
261 os_linux_arm.cpp \
262 resourceArea.cpp \
263 rewriter.cpp \
264 sharedRuntime.cpp \
265 signature.cpp \
266 space.cpp \
267 stackMapTable.cpp \
268 symbolTable.cpp \
269 systemDictionary.cpp \
270 symbol.cpp \
271 synchronizer.cpp \
272 timer.cpp \
273 typeArrayKlass.cpp \
274 unsafe.cpp \
275 utf8.cpp \
276 vmSymbols.cpp \
277 #
278
279 $(foreach s, $(OPT_SPEED_SRC), \
280 $(eval BUILD_LIBJVM_$s_OPTIMIZATION := HIGHEST_JVM))
281
282 ifneq ($(filter $(TOOLCHAIN_TYPE), gcc clang), )
283 BUILD_LIBJVM_systemDictionary.cpp_CXXFLAGS := -fno-optimize-sibling-calls
284 endif
285 endif
286
287 ################################################################################
288
289 endif # include guard
290 include MakeIncludeEnd.gmk