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