1 #
   2 # Copyright (c) 2013, 2020, 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_CFLAGS_FEATURES += -DZERO -DCC_INTERP -DZERO_LIBARCH='"$(OPENJDK_TARGET_CPU_LEGACY_LIB)"' $(LIBFFI_CFLAGS)
  49   JVM_LIBS_FEATURES += $(LIBFFI_LIBS)
  50   ifeq ($(ENABLE_LIBFFI_BUNDLING), true)
  51     JVM_LDFLAGS_FEATURES += $(call SET_EXECUTABLE_ORIGIN,/..)
  52   endif
  53 endif
  54 
  55 ifeq ($(JVM_VARIANT), custom)
  56   JVM_CFLAGS_FEATURES += -DVMTYPE=\"Custom\"
  57 endif
  58 
  59 ifeq ($(call check-jvm-feature, minimal), true)
  60   JVM_CFLAGS_FEATURES += -DMINIMAL_JVM -DVMTYPE=\"Minimal\"
  61   ifeq ($(call isTargetOs, linux), true)
  62     # Override the default -g with a more liberal strip policy for the minimal JVM
  63     JVM_STRIPFLAGS := --strip-unneeded
  64   endif
  65 endif
  66 
  67 ifeq ($(call check-jvm-feature, dtrace), true)
  68   JVM_CFLAGS_FEATURES += -DDTRACE_ENABLED
  69 endif
  70 
  71 ifeq ($(call check-jvm-feature, static-build), true)
  72   JVM_CFLAGS_FEATURES += -DSTATIC_BUILD=1
  73 endif
  74 
  75 ifneq ($(call check-jvm-feature, jvmti), true)
  76   JVM_CFLAGS_FEATURES += -DINCLUDE_JVMTI=0
  77   JVM_EXCLUDE_FILES += jvmtiGetLoadedClasses.cpp jvmtiThreadState.cpp jvmtiExtensions.cpp \
  78       jvmtiImpl.cpp jvmtiManageCapabilities.cpp jvmtiRawMonitor.cpp jvmtiUtil.cpp jvmtiTrace.cpp \
  79       jvmtiCodeBlobEvents.cpp jvmtiEnv.cpp jvmtiRedefineClasses.cpp jvmtiEnvBase.cpp jvmtiEnvThreadState.cpp \
  80       jvmtiTagMap.cpp jvmtiEventController.cpp evmCompat.cpp jvmtiEnter.xsl jvmtiExport.cpp \
  81       jvmtiClassFileReconstituter.cpp
  82 endif
  83 
  84 ifneq ($(call check-jvm-feature, jvmci), true)
  85   JVM_CFLAGS_FEATURES += -DINCLUDE_JVMCI=0
  86   JVM_EXCLUDES += jvmci
  87   JVM_EXCLUDE_FILES += jvmciCodeInstaller_$(HOTSPOT_TARGET_CPU_ARCH).cpp
  88 endif
  89 
  90 ifneq ($(call check-jvm-feature, vm-structs), true)
  91   JVM_CFLAGS_FEATURES += -DINCLUDE_VM_STRUCTS=0
  92   JVM_EXCLUDE_FILES += vmStructs.cpp
  93 endif
  94 
  95 ifneq ($(call check-jvm-feature, jni-check), true)
  96   JVM_CFLAGS_FEATURES += -DINCLUDE_JNI_CHECK=0
  97   JVM_EXCLUDE_FILES += jniCheck.cpp
  98 endif
  99 
 100 ifneq ($(call check-jvm-feature, services), true)
 101   JVM_CFLAGS_FEATURES += -DINCLUDE_SERVICES=0
 102   JVM_EXCLUDE_FILES += heapDumper.cpp heapInspection.cpp \
 103       attachListener_$(HOTSPOT_TARGET_OS).cpp attachListener.cpp
 104 endif
 105 
 106 ifneq ($(call check-jvm-feature, management), true)
 107   JVM_CFLAGS_FEATURES += -DINCLUDE_MANAGEMENT=0
 108 endif
 109 
 110 ifneq ($(call check-jvm-feature, cds), true)
 111   JVM_CFLAGS_FEATURES += -DINCLUDE_CDS=0
 112   JVM_EXCLUDE_FILES += \
 113       classListParser.cpp \
 114       classLoaderExt.cpp \
 115       dynamicArchive.cpp \
 116       filemap.cpp \
 117       heapShared.cpp \
 118       metaspaceShared.cpp \
 119       metaspaceShared_$(HOTSPOT_TARGET_CPU).cpp \
 120       metaspaceShared_$(HOTSPOT_TARGET_CPU_ARCH).cpp \
 121       sharedClassUtil.cpp \
 122       sharedPathsMiscInfo.cpp \
 123       systemDictionaryShared.cpp \
 124       #
 125 endif
 126 
 127 ifneq ($(call check-jvm-feature, nmt), true)
 128   JVM_CFLAGS_FEATURES += -DINCLUDE_NMT=0
 129   JVM_EXCLUDE_FILES += \
 130       memBaseline.cpp memReporter.cpp mallocTracker.cpp virtualMemoryTracker.cpp nmtCommon.cpp \
 131       memTracker.cpp nmtDCmd.cpp mallocSiteTable.cpp threadStackTracker.cpp
 132 endif
 133 
 134 ifneq ($(call check-jvm-feature, aot), true)
 135   JVM_CFLAGS_FEATURES += -DINCLUDE_AOT=0
 136   JVM_EXCLUDE_FILES += \
 137       compiledIC_aot_x86_64.cpp compiledIC_aot_aarch64.cpp      \
 138       compilerRuntime.cpp aotCodeHeap.cpp aotCompiledMethod.cpp \
 139       aotLoader.cpp compiledIC_aot.cpp
 140 endif
 141 
 142 ifneq ($(call check-jvm-feature, g1gc), true)
 143   JVM_CFLAGS_FEATURES += -DINCLUDE_G1GC=0
 144   JVM_EXCLUDE_PATTERNS += gc/g1
 145 endif
 146 
 147 ifneq ($(call check-jvm-feature, parallelgc), true)
 148   JVM_CFLAGS_FEATURES += -DINCLUDE_PARALLELGC=0
 149   JVM_EXCLUDE_PATTERNS += gc/parallel
 150 endif
 151 
 152 ifneq ($(call check-jvm-feature, serialgc), true)
 153   JVM_CFLAGS_FEATURES += -DINCLUDE_SERIALGC=0
 154   JVM_EXCLUDE_PATTERNS += gc/serial
 155 endif
 156 
 157 ifneq ($(call check-jvm-feature, epsilongc), true)
 158   JVM_CFLAGS_FEATURES += -DINCLUDE_EPSILONGC=0
 159   JVM_EXCLUDE_PATTERNS += gc/epsilon
 160 endif
 161 
 162 ifneq ($(call check-jvm-feature, zgc), true)
 163   JVM_CFLAGS_FEATURES += -DINCLUDE_ZGC=0
 164   JVM_EXCLUDE_PATTERNS += gc/z
 165 endif
 166 
 167 ifneq ($(call check-jvm-feature, shenandoahgc), true)
 168   JVM_CFLAGS_FEATURES += -DINCLUDE_SHENANDOAHGC=0
 169   JVM_EXCLUDE_PATTERNS += gc/shenandoah
 170 endif
 171 
 172 ifneq ($(call check-jvm-feature, jfr), true)
 173   JVM_CFLAGS_FEATURES += -DINCLUDE_JFR=0
 174   JVM_EXCLUDE_PATTERNS += jfr
 175   JVM_EXCLUDE_FILES += compilerEvent.cpp
 176 endif
 177 
 178 ################################################################################
 179 
 180 ifeq ($(call check-jvm-feature, link-time-opt), true)
 181   # NOTE: Disable automatic opimization level and let the explicit cflag control
 182   # optimization level instead. This activates O3 on slowdebug builds, just
 183   # like the old build, but it's probably not right.
 184   JVM_OPTIMIZATION :=
 185   JVM_CFLAGS_FEATURES += -O3 -flto
 186   JVM_LDFLAGS_FEATURES += -O3 -flto -fuse-linker-plugin -fno-strict-aliasing
 187 endif
 188 
 189 ifeq ($(call check-jvm-feature, opt-size), true)
 190   JVM_OPTIMIZATION := SIZE
 191   OPT_SPEED_SRC := \
 192       allocation.cpp \
 193       assembler.cpp \
 194       barrierSet.cpp \
 195       basicLock.cpp \
 196       biasedLocking.cpp \
 197       bytecode.cpp \
 198       bytecodeInterpreter.cpp \
 199       c1_Compilation.cpp \
 200       c1_Compiler.cpp \
 201       c1_GraphBuilder.cpp \
 202       c1_LinearScan.cpp \
 203       c1_LIR.cpp \
 204       ciEnv.cpp \
 205       ciObjectFactory.cpp \
 206       codeBlob.cpp \
 207       constantPool.cpp \
 208       constMethod.cpp \
 209       classLoader.cpp \
 210       classLoaderData.cpp \
 211       classFileParser.cpp \
 212       classFileStream.cpp \
 213       cpCache.cpp \
 214       defNewGeneration.cpp \
 215       frame_arm.cpp \
 216       frame_aarch64.cpp \
 217       frame_ppc.cpp \
 218       frame_s390.cpp \
 219       frame_x86.cpp \
 220       genCollectedHeap.cpp \
 221       generation.cpp \
 222       genMarkSweep.cpp \
 223       growableArray.cpp \
 224       handles.cpp \
 225       hashtable.cpp \
 226       heap.cpp \
 227       icache.cpp \
 228       icache_arm.cpp \
 229       icache_aarch64.cpp \
 230       icache_ppc.cpp \
 231       icache_s390.cpp \
 232       icache_x86.cpp \
 233       instanceKlass.cpp \
 234       invocationCounter.cpp \
 235       iterator.cpp \
 236       javaCalls.cpp \
 237       javaClasses.cpp \
 238       jniFastGetField_arm.cpp \
 239       jvm.cpp \
 240       linkResolver.cpp \
 241       klass.cpp \
 242       klassVtable.cpp \
 243       markSweep.cpp \
 244       memRegion.cpp \
 245       memoryPool.cpp \
 246       method.cpp \
 247       methodHandles.cpp \
 248       methodHandles_arm.cpp \
 249       methodLiveness.cpp \
 250       metaspace.cpp \
 251       mutex.cpp \
 252       mutexLocker.cpp \
 253       nativeLookup.cpp \
 254       objArrayKlass.cpp \
 255       os_linux.cpp \
 256       os_linux_arm.cpp \
 257       resourceArea.cpp \
 258       rewriter.cpp \
 259       sharedRuntime.cpp \
 260       signature.cpp \
 261       space.cpp \
 262       stackMapTable.cpp \
 263       symbolTable.cpp \
 264       systemDictionary.cpp \
 265       symbol.cpp \
 266       synchronizer.cpp \
 267       timer.cpp \
 268       typeArrayKlass.cpp \
 269       unsafe.cpp \
 270       utf8.cpp \
 271       vmSymbols.cpp \
 272       #
 273 
 274   $(foreach s, $(OPT_SPEED_SRC), \
 275       $(eval BUILD_LIBJVM_$s_OPTIMIZATION := HIGHEST_JVM))
 276 
 277   ifneq ($(filter $(TOOLCHAIN_TYPE), gcc clang), )
 278     BUILD_LIBJVM_systemDictionary.cpp_CXXFLAGS := -fno-optimize-sibling-calls
 279   endif
 280 endif