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