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       macroAssembler_common.cpp
 57   JVM_CFLAGS_FEATURES += -DZERO \
 58       -DZERO_LIBARCH='"$(OPENJDK_TARGET_CPU_LEGACY_LIB)"' $(LIBFFI_CFLAGS)
 59   JVM_LIBS_FEATURES += $(LIBFFI_LIBS)
 60   ifeq ($(ENABLE_LIBFFI_BUNDLING), true)
 61     JVM_LDFLAGS_FEATURES += $(call SetExecutableOrigin,/..)
 62   endif
 63 else
 64   JVM_EXCLUDE_PATTERNS += /zero/
 65 endif
 66 
 67 ifeq ($(JVM_VARIANT), core)
 68   JVM_CFLAGS_FEATURES += -DVMTYPE=\"Core\"
 69 endif
 70 
 71 ifeq ($(JVM_VARIANT), custom)
 72   JVM_CFLAGS_FEATURES += -DVMTYPE=\"Custom\"
 73 endif
 74 
 75 ifeq ($(call check-jvm-feature, minimal), true)
 76   JVM_CFLAGS_FEATURES += -DMINIMAL_JVM -DVMTYPE=\"Minimal\"
 77   ifeq ($(call isTargetOs, linux), true)
 78     # Override the default -g with a more liberal strip policy for the
 79     # minimal JVM
 80     JVM_STRIPFLAGS := --strip-unneeded
 81   endif
 82 endif
 83 
 84 ifeq ($(call check-jvm-feature, dtrace), true)
 85   JVM_CFLAGS_FEATURES += -DDTRACE_ENABLED
 86 endif
 87 
 88 ifneq ($(call check-jvm-feature, jvmti), true)
 89   JVM_CFLAGS_FEATURES += -DINCLUDE_JVMTI=0
 90   JVM_EXCLUDE_FILES += jvmtiGetLoadedClasses.cpp jvmtiThreadState.cpp \
 91       jvmtiExtensions.cpp jvmtiImpl.cpp jvmtiManageCapabilities.cpp \
 92       jvmtiRawMonitor.cpp jvmtiUtil.cpp jvmtiTrace.cpp jvmtiCodeBlobEvents.cpp \
 93       jvmtiEnv.cpp jvmtiRedefineClasses.cpp jvmtiEnvBase.cpp \
 94       jvmtiEnvThreadState.cpp jvmtiTagMap.cpp jvmtiEventController.cpp \
 95       evmCompat.cpp jvmtiEnter.xsl jvmtiExport.cpp \
 96       jvmtiClassFileReconstituter.cpp jvmtiTagMapTable.cpp jvmtiAgent.cpp \
 97       jvmtiAgentList.cpp jfrJvmtiAgent.cpp
 98 endif
 99 
100 ifneq ($(call check-jvm-feature, vm-structs), true)
101   JVM_CFLAGS_FEATURES += -DINCLUDE_VM_STRUCTS=0
102   JVM_EXCLUDE_FILES += vmStructs.cpp
103 endif
104 
105 ifneq ($(call check-jvm-feature, jni-check), true)
106   JVM_CFLAGS_FEATURES += -DINCLUDE_JNI_CHECK=0
107   JVM_EXCLUDE_FILES += jniCheck.cpp
108 endif
109 
110 ifneq ($(call check-jvm-feature, services), true)
111   JVM_CFLAGS_FEATURES += -DINCLUDE_SERVICES=0
112   JVM_EXCLUDE_FILES += heapDumper.cpp heapInspection.cpp \
113       attachListener_$(HOTSPOT_TARGET_OS).cpp attachListener.cpp
114 endif
115 
116 ifneq ($(call check-jvm-feature, management), true)
117   JVM_CFLAGS_FEATURES += -DINCLUDE_MANAGEMENT=0
118 endif
119 
120 ifneq ($(call check-jvm-feature, cds), true)
121   JVM_CFLAGS_FEATURES += -DINCLUDE_CDS=0
122   JVM_EXCLUDE_FILES += \
123       aotCodeCache.cpp \
124       classLoaderDataShared.cpp \
125       classLoaderExt.cpp \
126       systemDictionaryShared.cpp \
127       trainingData.cpp
128   JVM_EXCLUDE_PATTERNS += cds/
129 endif
130 
131 ifneq ($(call check-jvm-feature, g1gc), true)
132   JVM_CFLAGS_FEATURES += -DINCLUDE_G1GC=0
133   JVM_EXCLUDE_PATTERNS += gc/g1
134 endif
135 
136 ifneq ($(call check-jvm-feature, parallelgc), true)
137   JVM_CFLAGS_FEATURES += -DINCLUDE_PARALLELGC=0
138   JVM_EXCLUDE_PATTERNS += gc/parallel
139 endif
140 
141 ifneq ($(call check-jvm-feature, serialgc), true)
142   JVM_CFLAGS_FEATURES += -DINCLUDE_SERIALGC=0
143   JVM_EXCLUDE_PATTERNS += gc/serial
144 endif
145 
146 ifneq ($(call check-jvm-feature, epsilongc), true)
147   JVM_CFLAGS_FEATURES += -DINCLUDE_EPSILONGC=0
148   JVM_EXCLUDE_PATTERNS += gc/epsilon
149 endif
150 
151 ifneq ($(call check-jvm-feature, zgc), true)
152   JVM_CFLAGS_FEATURES += -DINCLUDE_ZGC=0
153   JVM_EXCLUDE_PATTERNS += gc/z
154 endif
155 
156 ifneq ($(call check-jvm-feature, shenandoahgc), true)
157   JVM_CFLAGS_FEATURES += -DINCLUDE_SHENANDOAHGC=0
158   JVM_EXCLUDE_PATTERNS += gc/shenandoah
159 endif
160 
161 ifneq ($(call check-jvm-feature, jfr), true)
162   JVM_CFLAGS_FEATURES += -DINCLUDE_JFR=0
163   JVM_EXCLUDE_PATTERNS += jfr
164   JVM_EXCLUDE_FILES += compilerEvent.cpp
165 endif
166 
167 ################################################################################
168 
169 ifeq ($(call check-jvm-feature, link-time-opt), true)
170   # Set JVM_OPTIMIZATION directly so other jvm-feature flags can override it
171   # later on if desired
172   JVM_OPTIMIZATION := HIGHEST_JVM
173   JVM_LTO := true
174   ifneq ($(call isCompiler, microsoft), true)
175     JVM_LDFLAGS_FEATURES += $(CXX_O_FLAG_HIGHEST_JVM)
176   endif
177 else
178   JVM_LTO := false
179   ifeq ($(call isCompiler, gcc), true)
180     JVM_LDFLAGS_FEATURES += -O1
181   endif
182 endif
183 
184 ifeq ($(call check-jvm-feature, opt-size), true)
185   JVM_OPTIMIZATION := SIZE
186   OPT_SPEED_SRC := \
187       allocation.cpp \
188       assembler.cpp \
189       barrierSet.cpp \
190       basicLock.cpp \
191       bytecode.cpp \
192       bytecodeInterpreter.cpp \
193       c1_Compilation.cpp \
194       c1_Compiler.cpp \
195       c1_GraphBuilder.cpp \
196       c1_LinearScan.cpp \
197       c1_LIR.cpp \
198       ciEnv.cpp \
199       ciObjectFactory.cpp \
200       codeBlob.cpp \
201       constantPool.cpp \
202       constMethod.cpp \
203       classLoader.cpp \
204       classLoaderData.cpp \
205       classFileParser.cpp \
206       classFileStream.cpp \
207       cpCache.cpp \
208       defNewGeneration.cpp \
209       frame_arm.cpp \
210       frame_aarch64.cpp \
211       frame_ppc.cpp \
212       frame_s390.cpp \
213       frame_x86.cpp \
214       generation.cpp \
215       growableArray.cpp \
216       handles.cpp \
217       heap.cpp \
218       icache.cpp \
219       icache_arm.cpp \
220       icache_aarch64.cpp \
221       icache_ppc.cpp \
222       icache_s390.cpp \
223       icache_x86.cpp \
224       instanceKlass.cpp \
225       invocationCounter.cpp \
226       iterator.cpp \
227       javaCalls.cpp \
228       javaClasses.cpp \
229       jniFastGetField_arm.cpp \
230       jvm.cpp \
231       linkResolver.cpp \
232       klass.cpp \
233       klassVtable.cpp \
234       memRegion.cpp \
235       memoryPool.cpp \
236       method.cpp \
237       methodHandles.cpp \
238       methodHandles_arm.cpp \
239       methodLiveness.cpp \
240       metaspace.cpp \
241       mutex.cpp \
242       mutexLocker.cpp \
243       nativeLookup.cpp \
244       objArrayKlass.cpp \
245       os_linux.cpp \
246       os_linux_arm.cpp \
247       resourceArea.cpp \
248       rewriter.cpp \
249       sharedRuntime.cpp \
250       signature.cpp \
251       space.cpp \
252       stackMapTable.cpp \
253       symbolTable.cpp \
254       systemDictionary.cpp \
255       symbol.cpp \
256       synchronizer.cpp \
257       timer.cpp \
258       typeArrayKlass.cpp \
259       unsafe.cpp \
260       utf8.cpp \
261       vmSymbols.cpp \
262       #
263 
264   $(foreach s, $(OPT_SPEED_SRC), \
265       $(eval BUILD_LIBJVM_$s_OPTIMIZATION := HIGHEST_JVM))
266 
267   ifneq ($(filter $(TOOLCHAIN_TYPE), gcc clang), )
268     BUILD_LIBJVM_systemDictionary.cpp_CXXFLAGS := -fno-optimize-sibling-calls
269   endif
270 endif
271 
272 ################################################################################
273 
274 endif # include guard
275 include MakeIncludeEnd.gmk