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