1 #
  2 # Copyright (c) 2013, 2024, 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 $(eval $(call IncludeCustomExtension, hotspot/lib/JvmFeatures.gmk))
 27 
 28 ################################################################################
 29 # Setup CFLAGS and EXCLUDES for the libjvm compilation, depending on which
 30 # jvm features are selected for this jvm variant.
 31 
 32 ifeq ($(call check-jvm-feature, compiler1), true)
 33   JVM_CFLAGS_FEATURES += -DCOMPILER1
 34 else
 35   JVM_EXCLUDE_PATTERNS += c1_ c1/
 36 endif
 37 
 38 ifeq ($(call check-jvm-feature, compiler2), true)
 39   JVM_CFLAGS_FEATURES += -DCOMPILER2
 40   JVM_SRC_DIRS += $(JVM_VARIANT_OUTPUTDIR)/gensrc/adfiles
 41 else
 42   JVM_EXCLUDES += opto libadt
 43   JVM_EXCLUDE_FILES += bcEscapeAnalyzer.cpp ciTypeFlow.cpp
 44   JVM_EXCLUDE_PATTERNS += c2_ runtime_ /c2/
 45 endif
 46 
 47 ifeq ($(call check-jvm-feature, zero), true)
 48   JVM_EXCLUDES += opto libadt
 49   JVM_EXCLUDE_PATTERNS += c1_ c1/ c2_ runtime_ /c2/
 50   JVM_EXCLUDE_FILES += templateInterpreter.cpp \
 51       templateInterpreterGenerator.cpp bcEscapeAnalyzer.cpp ciTypeFlow.cpp
 52   JVM_CFLAGS_FEATURES += -DZERO \
 53       -DZERO_LIBARCH='"$(OPENJDK_TARGET_CPU_LEGACY_LIB)"' $(LIBFFI_CFLAGS)
 54   JVM_LIBS_FEATURES += $(LIBFFI_LIBS)
 55   ifeq ($(ENABLE_LIBFFI_BUNDLING), true)
 56     JVM_LDFLAGS_FEATURES += $(call SET_EXECUTABLE_ORIGIN,/..)
 57   endif
 58 else
 59   JVM_EXCLUDE_PATTERNS += /zero/
 60 endif
 61 
 62 ifeq ($(JVM_VARIANT), core)
 63   JVM_CFLAGS_FEATURES += -DVMTYPE=\"Core\"
 64 endif
 65 
 66 ifeq ($(JVM_VARIANT), custom)
 67   JVM_CFLAGS_FEATURES += -DVMTYPE=\"Custom\"
 68 endif
 69 
 70 ifeq ($(call check-jvm-feature, minimal), true)
 71   JVM_CFLAGS_FEATURES += -DMINIMAL_JVM -DVMTYPE=\"Minimal\"
 72   ifeq ($(call isTargetOs, linux), true)
 73     # Override the default -g with a more liberal strip policy for the
 74     # minimal JVM
 75     JVM_STRIPFLAGS := --strip-unneeded
 76   endif
 77 endif
 78 
 79 ifeq ($(call check-jvm-feature, dtrace), true)
 80   JVM_CFLAGS_FEATURES += -DDTRACE_ENABLED
 81 endif
 82 
 83 ifneq ($(call check-jvm-feature, jvmti), true)
 84   JVM_CFLAGS_FEATURES += -DINCLUDE_JVMTI=0
 85   JVM_EXCLUDE_FILES += jvmtiGetLoadedClasses.cpp jvmtiThreadState.cpp \
 86       jvmtiExtensions.cpp jvmtiImpl.cpp jvmtiManageCapabilities.cpp \
 87       jvmtiRawMonitor.cpp jvmtiUtil.cpp jvmtiTrace.cpp jvmtiCodeBlobEvents.cpp \
 88       jvmtiEnv.cpp jvmtiRedefineClasses.cpp jvmtiEnvBase.cpp \
 89       jvmtiEnvThreadState.cpp jvmtiTagMap.cpp jvmtiEventController.cpp \
 90       evmCompat.cpp jvmtiEnter.xsl jvmtiExport.cpp \
 91       jvmtiClassFileReconstituter.cpp jvmtiTagMapTable.cpp jvmtiAgent.cpp \
 92       jvmtiAgentList.cpp jfrJvmtiAgent.cpp
 93 endif
 94 
 95 ifneq ($(call check-jvm-feature, jvmci), true)
 96   JVM_CFLAGS_FEATURES += -DINCLUDE_JVMCI=0
 97   JVM_EXCLUDES += jvmci
 98   JVM_EXCLUDE_FILES += jvmciCodeInstaller_$(HOTSPOT_TARGET_CPU_ARCH).cpp
 99 endif
100 
101 ifneq ($(call check-jvm-feature, vm-structs), true)
102   JVM_CFLAGS_FEATURES += -DINCLUDE_VM_STRUCTS=0
103   JVM_EXCLUDE_FILES += vmStructs.cpp
104 endif
105 
106 ifneq ($(call check-jvm-feature, jni-check), true)
107   JVM_CFLAGS_FEATURES += -DINCLUDE_JNI_CHECK=0
108   JVM_EXCLUDE_FILES += jniCheck.cpp
109 endif
110 
111 ifneq ($(call check-jvm-feature, services), true)
112   JVM_CFLAGS_FEATURES += -DINCLUDE_SERVICES=0
113   JVM_EXCLUDE_FILES += heapDumper.cpp heapInspection.cpp \
114       attachListener_$(HOTSPOT_TARGET_OS).cpp attachListener.cpp
115 endif
116 
117 ifneq ($(call check-jvm-feature, management), true)
118   JVM_CFLAGS_FEATURES += -DINCLUDE_MANAGEMENT=0
119 endif
120 
121 ifneq ($(call check-jvm-feature, cds), true)
122   JVM_CFLAGS_FEATURES += -DINCLUDE_CDS=0
123   JVM_EXCLUDE_FILES += \
124       classLoaderDataShared.cpp \
125       classLoaderExt.cpp \
126       systemDictionaryShared.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   JVM_EXCLUDE_PATTERNS += gc/x
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   ifeq ($(call isCompiler, gcc), true)
174     JVM_CFLAGS_FEATURES += -flto=auto -fuse-linker-plugin -fno-strict-aliasing \
175         -fno-fat-lto-objects
176     JVM_LDFLAGS_FEATURES += $(CXX_O_FLAG_HIGHEST_JVM) -flto=auto \
177         -fuse-linker-plugin -fno-strict-aliasing
178   else ifeq ($(call isCompiler, microsoft), true)
179     JVM_CFLAGS_FEATURES += -GL
180     JVM_LDFLAGS_FEATURES += -LTCG:INCREMENTAL
181   endif
182 else
183   ifeq ($(call isCompiler, gcc), true)
184     JVM_LDFLAGS_FEATURES += -O1
185   endif
186 endif
187 
188 ifeq ($(call check-jvm-feature, opt-size), true)
189   JVM_OPTIMIZATION := SIZE
190   OPT_SPEED_SRC := \
191       allocation.cpp \
192       assembler.cpp \
193       barrierSet.cpp \
194       basicLock.cpp \
195       bytecode.cpp \
196       bytecodeInterpreter.cpp \
197       c1_Compilation.cpp \
198       c1_Compiler.cpp \
199       c1_GraphBuilder.cpp \
200       c1_LinearScan.cpp \
201       c1_LIR.cpp \
202       ciEnv.cpp \
203       ciObjectFactory.cpp \
204       codeBlob.cpp \
205       constantPool.cpp \
206       constMethod.cpp \
207       classLoader.cpp \
208       classLoaderData.cpp \
209       classFileParser.cpp \
210       classFileStream.cpp \
211       cpCache.cpp \
212       defNewGeneration.cpp \
213       frame_arm.cpp \
214       frame_aarch64.cpp \
215       frame_ppc.cpp \
216       frame_s390.cpp \
217       frame_x86.cpp \
218       genCollectedHeap.cpp \
219       generation.cpp \
220       growableArray.cpp \
221       handles.cpp \
222       hashtable.cpp \
223       heap.cpp \
224       icache.cpp \
225       icache_arm.cpp \
226       icache_aarch64.cpp \
227       icache_ppc.cpp \
228       icache_s390.cpp \
229       icache_x86.cpp \
230       instanceKlass.cpp \
231       invocationCounter.cpp \
232       iterator.cpp \
233       javaCalls.cpp \
234       javaClasses.cpp \
235       jniFastGetField_arm.cpp \
236       jvm.cpp \
237       linkResolver.cpp \
238       klass.cpp \
239       klassVtable.cpp \
240       markSweep.cpp \
241       memRegion.cpp \
242       memoryPool.cpp \
243       method.cpp \
244       methodHandles.cpp \
245       methodHandles_arm.cpp \
246       methodLiveness.cpp \
247       metaspace.cpp \
248       mutex.cpp \
249       mutexLocker.cpp \
250       nativeLookup.cpp \
251       objArrayKlass.cpp \
252       os_linux.cpp \
253       os_linux_arm.cpp \
254       resourceArea.cpp \
255       rewriter.cpp \
256       sharedRuntime.cpp \
257       signature.cpp \
258       space.cpp \
259       stackMapTable.cpp \
260       symbolTable.cpp \
261       systemDictionary.cpp \
262       symbol.cpp \
263       synchronizer.cpp \
264       timer.cpp \
265       typeArrayKlass.cpp \
266       unsafe.cpp \
267       utf8.cpp \
268       vmSymbols.cpp \
269       #
270 
271   $(foreach s, $(OPT_SPEED_SRC), \
272       $(eval BUILD_LIBJVM_$s_OPTIMIZATION := HIGHEST_JVM))
273 
274   ifneq ($(filter $(TOOLCHAIN_TYPE), gcc clang), )
275     BUILD_LIBJVM_systemDictionary.cpp_CXXFLAGS := -fno-optimize-sibling-calls
276   endif
277 endif