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