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 # 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 += $(TOPDIR)/src/hotspot
  44 
  45 JVM_SRC_DIRS += $(call uniq, $(wildcard $(foreach d, $(JVM_SRC_ROOTS), \
  46         $d/share \
  47         $d/os/$(HOTSPOT_TARGET_OS) \
  48         $d/os/$(HOTSPOT_TARGET_OS_TYPE) \
  49         $d/cpu/$(HOTSPOT_TARGET_CPU_ARCH) \
  50         $d/os_cpu/$(HOTSPOT_TARGET_OS)_$(HOTSPOT_TARGET_CPU_ARCH) \
  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$(TOPDIR)/src/hotspot/share/precompiled \
  60     -I$(TOPDIR)/src/java.base/share/native/include \
  61     -I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/include \
  62     -I$(TOPDIR)/src/java.management/share/native/include \
  63     -I$(TOPDIR)/src/java.base/share/native/libjimage \
  64     #
  65 
  66 # INCLUDE_SUFFIX_* is only meant for including the proper
  67 # platform files. Don't use it to guard code. Use the value of
  68 # HOTSPOT_TARGET_CPU_DEFINE etc. instead.
  69 # Remaining TARGET_ARCH_* is needed to select the cpu specific
  70 # sources for 64-bit ARM ports (arm versus aarch64).
  71 JVM_CFLAGS_TARGET_DEFINES += \
  72     -DTARGET_ARCH_$(HOTSPOT_TARGET_CPU_ARCH) \
  73     -DINCLUDE_SUFFIX_OS=_$(HOTSPOT_TARGET_OS) \
  74     -DINCLUDE_SUFFIX_CPU=_$(HOTSPOT_TARGET_CPU_ARCH) \
  75     -DINCLUDE_SUFFIX_COMPILER=_$(HOTSPOT_TOOLCHAIN_TYPE) \
  76     -DTARGET_COMPILER_$(HOTSPOT_TOOLCHAIN_TYPE) \
  77     -D$(HOTSPOT_TARGET_CPU_DEFINE) \
  78     -DHOTSPOT_LIB_ARCH='"$(OPENJDK_TARGET_CPU_LEGACY_LIB)"' \
  79     #
  80 
  81 ifeq ($(DEBUG_LEVEL), release)
  82   # For hotspot, release builds differ internally between "optimized" and "product"
  83   # in that "optimize" does not define PRODUCT.
  84   ifneq ($(HOTSPOT_DEBUG_LEVEL), optimized)
  85     JVM_CFLAGS_DEBUGLEVEL := -DPRODUCT
  86   endif
  87 else ifeq ($(DEBUG_LEVEL), fastdebug)
  88   JVM_CFLAGS_DEBUGLEVEL := -DASSERT
  89   ifeq ($(filter $(OPENJDK_TARGET_OS), windows aix), )
  90     # NOTE: Old build did not define CHECK_UNHANDLED_OOPS on Windows and AIX.
  91     JVM_CFLAGS_DEBUGLEVEL += -DCHECK_UNHANDLED_OOPS
  92   endif
  93 else ifeq ($(DEBUG_LEVEL), slowdebug)
  94   # _NMT_NOINLINE_ informs NMT that no inlining is done by the compiler
  95   JVM_CFLAGS_DEBUGLEVEL := -DASSERT -D_NMT_NOINLINE_
  96 endif
  97 
  98 JVM_CFLAGS += \
  99     $(JVM_CFLAGS_DEBUGLEVEL) \
 100     $(JVM_CFLAGS_TARGET_DEFINES) \
 101     $(JVM_CFLAGS_FEATURES) \
 102     $(JVM_CFLAGS_INCLUDES) \
 103     $(EXTRA_CFLAGS) \
 104     #
 105 
 106 JVM_LDFLAGS += \
 107     $(SHARED_LIBRARY_FLAGS) \
 108     $(JVM_LDFLAGS_FEATURES) \
 109     $(EXTRA_LDFLAGS) \
 110     #
 111 
 112 JVM_LIBS += \
 113     $(JVM_LIBS_FEATURES) \
 114     #
 115 
 116 # These files and directories are always excluded
 117 JVM_EXCLUDE_FILES += args.cc
 118 JVM_EXCLUDES += adlc
 119 
 120 # Needed by vm_version.cpp
 121 ifeq ($(OPENJDK_TARGET_CPU), x86_64)
 122   OPENJDK_TARGET_CPU_VM_VERSION := amd64
 123 else ifeq ($(OPENJDK_TARGET_CPU), sparcv9)
 124   OPENJDK_TARGET_CPU_VM_VERSION := sparc
 125 else ifeq ($(HOTSPOT_TARGET_CPU_ARCH), arm)
 126   ifeq ($(OPENJDK_TARGET_CPU), aarch64)
 127     # This sets the Oracle Aarch64 port to use arm64
 128     # while the original Aarch64 port uses aarch64
 129     OPENJDK_TARGET_CPU_VM_VERSION := arm64
 130   endif
 131 else
 132   OPENJDK_TARGET_CPU_VM_VERSION := $(OPENJDK_TARGET_CPU)
 133 endif
 134 
 135 CFLAGS_VM_VERSION := \
 136     $(VERSION_CFLAGS) \
 137     -DHOTSPOT_VERSION_STRING='"$(VERSION_STRING)"' \
 138     -DDEBUG_LEVEL='"$(DEBUG_LEVEL)"' \
 139     -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
 140     -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
 141     -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
 142     #
 143 
 144 # -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp.
 145 ifeq ($(USE_PRECOMPILED_HEADER), false)
 146   JVM_CFLAGS += -DDONT_USE_PRECOMPILED_HEADER
 147 endif
 148 
 149 ################################################################################
 150 # Platform specific setup
 151 
 152 # ARM source selection
 153 
 154 ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), linux-arm)
 155   JVM_EXCLUDE_PATTERNS += arm_64
 156 
 157 else ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), linux-aarch64)
 158   # For 64-bit arm builds, we use the 64 bit hotspot/src/cpu/arm
 159   # hotspot sources if HOTSPOT_TARGET_CPU_ARCH is set to arm.
 160   # Exclude the aarch64 and 32 bit arm files for this build.
 161   ifeq ($(HOTSPOT_TARGET_CPU_ARCH), arm)
 162     JVM_EXCLUDE_PATTERNS += arm_32 aarch64
 163   endif
 164 endif
 165 
 166 ifneq ($(filter $(OPENJDK_TARGET_OS), linux macosx windows), )
 167   JVM_PRECOMPILED_HEADER := $(TOPDIR)/src/hotspot/share/precompiled/precompiled.hpp
 168 endif
 169 
 170 ifeq ($(OPENJDK_TARGET_CPU), x86)
 171   JVM_EXCLUDE_PATTERNS += x86_64
 172 else ifeq ($(OPENJDK_TARGET_CPU), x86_64)
 173   JVM_EXCLUDE_PATTERNS += x86_32
 174 endif
 175 
 176 # Inline assembly for solaris
 177 ifeq ($(OPENJDK_TARGET_OS), solaris)
 178   ifeq ($(OPENJDK_TARGET_CPU), x86_64)
 179     JVM_CFLAGS += $(TOPDIR)/src/hotspot/os_cpu/solaris_x86/solaris_x86_64.il
 180   else ifeq ($(OPENJDK_TARGET_CPU), sparcv9)
 181     JVM_CFLAGS += $(TOPDIR)/src/hotspot/os_cpu/solaris_sparc/solaris_sparc.il
 182   endif
 183 endif
 184 
 185 ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), solaris-sparcv9)
 186   ifeq ($(COMPILE_WITH_DEBUG_SYMBOLS), false)
 187     # NOTE: In the old build, we weirdly enough set -g/-g0 always, regardless
 188     # of if debug symbols were needed. Without it, compilation fails on
 189     # sparc! :-(
 190     JVM_CFLAGS += -g0
 191   endif
 192 endif
 193 
 194 ifeq ($(OPENJDK_TARGET_OS), windows)
 195   ifeq ($(OPENJDK_TARGET_CPU_BITS), 64)
 196     RC_DESC := 64-Bit$(SPACE)
 197   endif
 198   JVM_RCFLAGS += -D"HS_FILEDESC=$(HOTSPOT_VM_DISTRO) $(RC_DESC)$(JVM_VARIANT) VM"
 199 endif
 200 
 201 JVM_OPTIMIZATION ?= HIGHEST_JVM
 202 
 203 # Need to set JVM_STRIPFLAGS to the default value from SPEC since the STRIPFLAGS
 204 # parameter to SetupNativeCompilation allows an empty value to override the
 205 # default.
 206 JVM_STRIPFLAGS ?= $(STRIPFLAGS)
 207 
 208 ################################################################################
 209 # Now set up the actual compilation of the main hotspot native library
 210 
 211 $(eval $(call SetupNativeCompilation, BUILD_LIBJVM, \
 212     TOOLCHAIN := TOOLCHAIN_LINK_CXX, \
 213     LIBRARY := jvm, \
 214     OUTPUT_DIR := $(JVM_LIB_OUTPUTDIR), \
 215     SRC := $(JVM_SRC_DIRS), \
 216     EXCLUDES := $(JVM_EXCLUDES), \
 217     EXCLUDE_FILES := $(JVM_EXCLUDE_FILES), \
 218     EXCLUDE_PATTERNS := $(JVM_EXCLUDE_PATTERNS), \
 219     EXTRA_OBJECT_FILES := $(DTRACE_EXTRA_OBJECT_FILES), \
 220     CFLAGS := $(JVM_CFLAGS), \
 221     CFLAGS_DEBUG_SYMBOLS := $(JVM_CFLAGS_SYMBOLS), \
 222     CXXFLAGS_DEBUG_SYMBOLS := $(JVM_CFLAGS_SYMBOLS), \
 223     vm_version.cpp_CXXFLAGS := $(CFLAGS_VM_VERSION), \
 224     DISABLED_WARNINGS_clang := tautological-compare, \
 225     DISABLED_WARNINGS_xlc := 1540-0216 1540-0198 1540-1090 1540-1639 \
 226         1540-1088 1500-010, \
 227     ASFLAGS := $(JVM_ASFLAGS), \
 228     LDFLAGS := $(JVM_LDFLAGS), \
 229     LIBS := $(JVM_LIBS), \
 230     OPTIMIZATION := $(JVM_OPTIMIZATION), \
 231     OBJECT_DIR := $(JVM_OUTPUTDIR)/objs, \
 232     MAPFILE := $(JVM_MAPFILE), \
 233     USE_MAPFILE_FOR_SYMBOLS := true, \
 234     STRIPFLAGS := $(JVM_STRIPFLAGS), \
 235     EMBED_MANIFEST := true, \
 236     RC_FLAGS := $(JVM_RCFLAGS), \
 237     VERSIONINFO_RESOURCE := $(TOPDIR)/src/hotspot/os/windows/version.rc, \
 238     PRECOMPILED_HEADER := $(JVM_PRECOMPILED_HEADER), \
 239     PRECOMPILED_HEADER_EXCLUDE := $(JVM_PRECOMPILED_HEADER_EXCLUDE), \
 240 ))
 241 
 242 ifeq ($(OPENJDK_TARGET_OS), windows)
 243   # It doesn't matter which jvm.lib file gets exported, but we need
 244   # to pick just one.
 245   ifeq ($(JVM_VARIANT), $(firstword $(JVM_VARIANTS)))
 246     $(eval $(call SetupCopyFiles, COPY_JVM_LIB, \
 247         DEST := $(LIB_OUTPUTDIR), \
 248         FILES :=$(JVM_VARIANT_OUTPUTDIR)/libjvm/objs/jvm.lib, \
 249     ))
 250     TARGETS += $(COPY_JVM_LIB)
 251   endif
 252 endif
 253 
 254 # AIX warning explanation:
 255 # 1500-010  : (W) WARNING in ...: Infinite loop.  Program may not stop.
 256 #             There are several infinite loops in the vm, so better suppress.
 257 # 1540-0198 : (W) The omitted keyword "private" is assumed for base class "...".
 258 # 1540-0216 : (W) An expression of type .. cannot be converted to type ..
 259 #             In hotspot this fires for functionpointer to pointer conversions
 260 # 1540-1088 : (W) The exception specification is being ignored.
 261 #             In hotspot this is caused by throw() in declaration of new() in nmethod.hpp.
 262 # 1540-1090 : (I) The destructor of "..." might not be called.
 263 # 1540-1639 : (I) The behavior of long type bit fields has changed ...
 264 
 265 # Include mapfile generation. It relies on BUILD_LIBJVM_ALL_OBJS which is only
 266 # defined after the above call to BUILD_LIBJVM. Mapfile will be generated
 267 # after all object files are built, but before the jvm library is linked.
 268 include lib/JvmMapfile.gmk
 269 
 270 TARGETS += $(BUILD_LIBJVM)