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