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 # Include support files that will setup compiler flags due to the selected
  27 # jvm feature set, and specific file overrides.
  28 include lib/JvmFeatures.gmk
  29 include lib/JvmOverrideFiles.gmk
  30 
  31 $(eval $(call IncludeCustomExtension, hotspot, lib/CompileJvm.gmk))
  32 
  33 ################################################################################
  34 # Setup compilation of the main Hotspot native library (libjvm).
  35 
  36 JVM_OUTPUTDIR := $(JVM_VARIANT_OUTPUTDIR)/libjvm
  37 JVM_MAPFILE := $(JVM_OUTPUTDIR)/mapfile
  38 
  39 ################################################################################
  40 # Platform independent setup
  41 
  42 # This variable may be added to by a custom extension
  43 JVM_SRC_ROOTS += $(HOTSPOT_TOPDIR)/src
  44 
  45 JVM_SRC_DIRS += $(call uniq, $(wildcard $(foreach d, $(JVM_SRC_ROOTS), \
  46         $d/share/vm \
  47         $d/os/$(HOTSPOT_TARGET_OS)/vm \
  48         $d/os/$(HOTSPOT_TARGET_OS_TYPE)/vm \
  49         $d/cpu/$(HOTSPOT_TARGET_CPU_ARCH)/vm \
  50         $d/os_cpu/$(HOTSPOT_TARGET_OS)_$(HOTSPOT_TARGET_CPU_ARCH)/vm \
  51     ))) \
  52     $(JVM_VARIANT_OUTPUTDIR)/gensrc/jvmtifiles \
  53     $(JVM_VARIANT_OUTPUTDIR)/gensrc/tracefiles \
  54     #
  55 
  56 JVM_CFLAGS_INCLUDES += \
  57     $(patsubst %,-I%,$(filter-out $(JVM_VARIANT_OUTPUTDIR)/gensrc/%, $(JVM_SRC_DIRS))) \
  58     -I$(JVM_VARIANT_OUTPUTDIR)/gensrc \
  59     -I$(HOTSPOT_TOPDIR)/src/share/vm/precompiled \
  60     -I$(HOTSPOT_TOPDIR)/src/share/vm/prims \
  61     #
  62 
  63 JVM_CFLAGS_TARGET_DEFINES += \
  64     -DTARGET_OS_FAMILY_$(HOTSPOT_TARGET_OS) \
  65     -DTARGET_ARCH_MODEL_$(HOTSPOT_TARGET_CPU) \
  66     -DTARGET_ARCH_$(HOTSPOT_TARGET_CPU_ARCH) \
  67     -DTARGET_OS_ARCH_MODEL_$(HOTSPOT_TARGET_OS)_$(HOTSPOT_TARGET_CPU) \
  68     -DTARGET_OS_ARCH_$(HOTSPOT_TARGET_OS)_$(HOTSPOT_TARGET_CPU_ARCH) \
  69     -DTARGET_COMPILER_$(HOTSPOT_TOOLCHAIN_TYPE) \
  70     -D$(HOTSPOT_TARGET_CPU_DEFINE) \
  71     -DHOTSPOT_LIB_ARCH='"$(OPENJDK_TARGET_CPU_LEGACY_LIB)"' \
  72     #
  73 
  74 ifeq ($(DEBUG_LEVEL), release)
  75   # For hotspot, release builds differ internally between "optimized" and "product"
  76   # in that "optimize" does not define PRODUCT.
  77   ifneq ($(HOTSPOT_DEBUG_LEVEL), optimized)
  78     JVM_CFLAGS_DEBUGLEVEL := -DPRODUCT
  79   endif
  80 else ifeq ($(DEBUG_LEVEL), fastdebug)
  81   JVM_CFLAGS_DEBUGLEVEL := -DASSERT
  82   ifeq ($(filter $(OPENJDK_TARGET_OS), windows aix), )
  83     # NOTE: Old build did not define CHECK_UNHANDLED_OOPS on Windows and AIX.
  84     JVM_CFLAGS_DEBUGLEVEL += -DCHECK_UNHANDLED_OOPS
  85   endif
  86 else ifeq ($(DEBUG_LEVEL), slowdebug)
  87   # _NMT_NOINLINE_ informs NMT that no inlining is done by the compiler
  88   JVM_CFLAGS_DEBUGLEVEL := -DASSERT -D_NMT_NOINLINE_
  89 endif
  90 
  91 JVM_CFLAGS += \
  92     $(JVM_CFLAGS_DEBUGLEVEL) \
  93     $(JVM_CFLAGS_TARGET_DEFINES) \
  94     $(JVM_CFLAGS_FEATURES) \
  95     $(JVM_CFLAGS_INCLUDES) \
  96     $(EXTRA_CFLAGS) \
  97     #
  98 
  99 JVM_LDFLAGS += \
 100     $(SHARED_LIBRARY_FLAGS) \
 101     $(JVM_LDFLAGS_FEATURES) \
 102     $(EXTRA_LDFLAGS) \
 103     #
 104 
 105 JVM_LIBS += \
 106     $(JVM_LIBS_FEATURES) \
 107     #
 108 
 109 # These files and directories are always excluded
 110 JVM_EXCLUDE_FILES += jsig.c jvmtiEnvRecommended.cpp jvmtiEnvStub.cpp args.cc
 111 JVM_EXCLUDES += adlc
 112 
 113 # Needed by vm_version.cpp
 114 ifeq ($(OPENJDK_TARGET_CPU), x86_64)
 115   OPENJDK_TARGET_CPU_VM_VERSION := amd64
 116 else ifeq ($(OPENJDK_TARGET_CPU), sparcv9)
 117   OPENJDK_TARGET_CPU_VM_VERSION := sparc
 118 else
 119   OPENJDK_TARGET_CPU_VM_VERSION := $(OPENJDK_TARGET_CPU)
 120 endif
 121 
 122 CFLAGS_VM_VERSION := \
 123     $(VERSION_CFLAGS) \
 124     -DHOTSPOT_VERSION_STRING='"$(VERSION_STRING)"' \
 125     -DDEBUG_LEVEL='"$(DEBUG_LEVEL)"' \
 126     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
 127     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
 128     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
 129     #
 130 
 131 # -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp.
 132 ifeq ($(USE_PRECOMPILED_HEADER), 0)
 133   JVM_CFLAGS += -DDONT_USE_PRECOMPILED_HEADER
 134 endif
 135 
 136 ################################################################################
 137 # Platform specific setup
 138 
 139 ifneq ($(filter $(OPENJDK_TARGET_OS), linux macosx windows), )
 140   JVM_PRECOMPILED_HEADER := $(HOTSPOT_TOPDIR)/src/share/vm/precompiled/precompiled.hpp
 141 endif
 142 
 143 ifneq ($(filter $(OPENJDK_TARGET_OS), macosx aix solaris), )
 144   # On macosx, aix and solaris we have to link with the C++ compiler
 145   JVM_TOOLCHAIN := TOOLCHAIN_LINK_CXX
 146 else
 147   JVM_TOOLCHAIN := TOOLCHAIN_DEFAULT
 148 endif
 149 
 150 ifeq ($(OPENJDK_TARGET_CPU), x86)
 151   JVM_EXCLUDE_PATTERNS += x86_64
 152 else ifeq ($(OPENJDK_TARGET_CPU), x86_64)
 153   JVM_EXCLUDE_PATTERNS += x86_32
 154 endif
 155 
 156 # Inline assembly for solaris
 157 ifeq ($(OPENJDK_TARGET_OS), solaris)
 158   ifeq ($(OPENJDK_TARGET_CPU), x86_64)
 159     JVM_CFLAGS += $(HOTSPOT_TOPDIR)/src/os_cpu/solaris_x86/vm/solaris_x86_64.il
 160   else ifeq ($(OPENJDK_TARGET_CPU), sparcv9)
 161     JVM_CFLAGS += $(HOTSPOT_TOPDIR)/src/os_cpu/solaris_sparc/vm/solaris_sparc.il
 162   endif
 163 endif
 164 
 165 ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), solaris-sparcv9)
 166   ifeq ($(COMPILE_WITH_DEBUG_SYMBOLS), false)
 167     # NOTE: In the old build, we weirdly enough set -g/-g0 always, regardless
 168     # of if debug symbols were needed. Without it, compilation fails on
 169     # sparc! :-(
 170     JVM_CFLAGS += -g0
 171   endif
 172 endif
 173 
 174 ifeq ($(OPENJDK_TARGET_OS), windows)
 175   ifeq ($(OPENJDK_TARGET_CPU_BITS), 64)
 176     RC_DESC := 64-Bit$(SPACE)
 177   endif
 178   JVM_RCFLAGS += -D"HS_FILEDESC=$(HOTSPOT_VM_DISTRO) $(RC_DESC)$(JVM_VARIANT) VM"
 179 endif
 180 
 181 ifeq ($(OPENJDK_TARGET_OS), macosx)
 182   # NOTE: The old build did not strip binaries on macosx.
 183   JVM_STRIP_SYMBOLS := false
 184 else
 185   JVM_STRIP_SYMBOLS := true
 186 endif
 187 
 188 JVM_OPTIMIZATION ?= HIGHEST_JVM
 189 
 190 ################################################################################
 191 # Now set up the actual compilation of the main hotspot native library
 192 
 193 $(eval $(call SetupNativeCompilation, BUILD_LIBJVM, \
 194     TOOLCHAIN := $(JVM_TOOLCHAIN), \
 195     LIBRARY := jvm, \
 196     OUTPUT_DIR := $(JVM_OUTPUTDIR), \
 197     SRC := $(JVM_SRC_DIRS), \
 198     EXCLUDES := $(JVM_EXCLUDES), \
 199     EXCLUDE_FILES := $(JVM_EXCLUDE_FILES), \
 200     EXCLUDE_PATTERNS := $(JVM_EXCLUDE_PATTERNS), \
 201     EXTRA_OBJECT_FILES := $(DTRACE_EXTRA_OBJECT_FILES), \
 202     CFLAGS := $(JVM_CFLAGS), \
 203     CFLAGS_DEBUG_SYMBOLS := $(JVM_CFLAGS_SYMBOLS), \
 204     CXXFLAGS_DEBUG_SYMBOLS := $(JVM_CFLAGS_SYMBOLS), \
 205     vm_version.cpp_CXXFLAGS := $(CFLAGS_VM_VERSION), \
 206     DISABLED_WARNINGS_clang := delete-non-virtual-dtor dynamic-class-memaccess \
 207         empty-body format logical-op-parentheses parentheses \
 208         parentheses-equality switch tautological-compare, \
 209     DISABLED_WARNINGS_xlc := 1540-0216 1540-0198 1540-1090 1540-1639 \
 210         1540-1088 1500-010, \
 211     ASFLAGS := $(JVM_ASFLAGS), \
 212     LDFLAGS := $(JVM_LDFLAGS), \
 213     LIBS := $(JVM_LIBS), \
 214     OPTIMIZATION := $(JVM_OPTIMIZATION), \
 215     OBJECT_DIR := $(JVM_OUTPUTDIR)/objs, \
 216     MAPFILE := $(JVM_MAPFILE), \
 217     USE_MAPFILE_FOR_SYMBOLS := true, \
 218     STRIP_SYMBOLS := $(JVM_STRIP_SYMBOLS), \
 219     EMBED_MANIFEST := true, \
 220     RC_FLAGS := $(JVM_RCFLAGS), \
 221     VERSIONINFO_RESOURCE := $(HOTSPOT_TOPDIR)/src/os/windows/vm/version.rc, \
 222     PRECOMPILED_HEADER := $(JVM_PRECOMPILED_HEADER), \
 223     PRECOMPILED_HEADER_EXCLUDE := $(JVM_PRECOMPILED_HEADER_EXCLUDE), \
 224 ))
 225 
 226 # AIX warning explanation:
 227 # 1500-010  : (W) WARNING in ...: Infinite loop.  Program may not stop.
 228 #             There are several infinite loops in the vm, so better suppress.
 229 # 1540-0198 : (W) The omitted keyword "private" is assumed for base class "...".
 230 # 1540-0216 : (W) An expression of type .. cannot be converted to type ..
 231 #             In hotspot this fires for functionpointer to pointer conversions
 232 # 1540-1088 : (W) The exception specification is being ignored.
 233 #             In hotspot this is caused by throw() in declaration of new() in nmethod.hpp.
 234 # 1540-1090 : (I) The destructor of "..." might not be called.
 235 # 1540-1639 : (I) The behavior of long type bit fields has changed ...
 236 
 237 # Include mapfile generation. It relies on BUILD_LIBJVM_ALL_OBJS which is only
 238 # defined after the above call to BUILD_LIBJVM. Mapfile will be generated
 239 # after all object files are built, but before the jvm library is linked.
 240 include lib/JvmMapfile.gmk
 241 
 242 TARGETS += $(BUILD_LIBJVM)