hotspot/make/lib/CompileJvm.gmk
author sadayapalam
Wed, 25 May 2016 19:30:55 +0530
changeset 38604 b65bfa841446
parent 38097 1ca3d6f508b1
child 40010 e32d5e545789
permissions -rw-r--r--
8047024: 7 ANNOT tests in JCK9 test suite fail with an AssertionError for exception_index Summary: Fix incorrect assertion about exception index already being set. Reviewed-by: mcimadamore

#
# Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.  Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

# Include support files that will setup compiler flags due to the selected
# jvm feature set, and specific file overrides.
include lib/JvmFeatures.gmk
include lib/JvmOverrideFiles.gmk

$(eval $(call IncludeCustomExtension, hotspot, lib/CompileJvm.gmk))

################################################################################
# Setup compilation of the main Hotspot native library (libjvm).

JVM_OUTPUTDIR := $(JVM_VARIANT_OUTPUTDIR)/libjvm
JVM_MAPFILE := $(JVM_OUTPUTDIR)/mapfile

################################################################################
# Platform independent setup

# This variable may be added to by a custom extension
JVM_SRC_ROOTS += $(HOTSPOT_TOPDIR)/src

JVM_SRC_DIRS += $(call uniq, $(wildcard $(foreach d, $(JVM_SRC_ROOTS), \
        $d/share/vm \
        $d/os/$(HOTSPOT_TARGET_OS)/vm \
        $d/os/$(HOTSPOT_TARGET_OS_TYPE)/vm \
        $d/cpu/$(HOTSPOT_TARGET_CPU_ARCH)/vm \
        $d/os_cpu/$(HOTSPOT_TARGET_OS)_$(HOTSPOT_TARGET_CPU_ARCH)/vm \
    ))) \
    $(JVM_VARIANT_OUTPUTDIR)/gensrc/jvmtifiles \
    $(JVM_VARIANT_OUTPUTDIR)/gensrc/tracefiles \
    #

JVM_CFLAGS_INCLUDES += \
    $(patsubst %,-I%,$(filter-out $(JVM_VARIANT_OUTPUTDIR)/gensrc/%, $(JVM_SRC_DIRS))) \
    -I$(JVM_VARIANT_OUTPUTDIR)/gensrc \
    -I$(HOTSPOT_TOPDIR)/src/share/vm/precompiled \
    -I$(HOTSPOT_TOPDIR)/src/share/vm/prims \
    #

JVM_CFLAGS_TARGET_DEFINES += \
    -DTARGET_OS_FAMILY_$(HOTSPOT_TARGET_OS) \
    -DTARGET_ARCH_MODEL_$(HOTSPOT_TARGET_CPU) \
    -DTARGET_ARCH_$(HOTSPOT_TARGET_CPU_ARCH) \
    -DTARGET_OS_ARCH_MODEL_$(HOTSPOT_TARGET_OS)_$(HOTSPOT_TARGET_CPU) \
    -DTARGET_OS_ARCH_$(HOTSPOT_TARGET_OS)_$(HOTSPOT_TARGET_CPU_ARCH) \
    -DTARGET_COMPILER_$(HOTSPOT_TOOLCHAIN_TYPE) \
    -D$(HOTSPOT_TARGET_CPU_DEFINE) \
    -DHOTSPOT_LIB_ARCH='"$(OPENJDK_TARGET_CPU_LEGACY_LIB)"' \
    #

ifeq ($(DEBUG_LEVEL), release)
  # For hotspot, release builds differ internally between "optimized" and "product"
  # in that "optimize" does not define PRODUCT.
  ifneq ($(HOTSPOT_DEBUG_LEVEL), optimized)
    JVM_CFLAGS_DEBUGLEVEL := -DPRODUCT
  endif
else ifeq ($(DEBUG_LEVEL), fastdebug)
  JVM_CFLAGS_DEBUGLEVEL := -DASSERT
  ifeq ($(filter $(OPENJDK_TARGET_OS), windows aix), )
    # NOTE: Old build did not define CHECK_UNHANDLED_OOPS on Windows and AIX.
    JVM_CFLAGS_DEBUGLEVEL += -DCHECK_UNHANDLED_OOPS
  endif
else ifeq ($(DEBUG_LEVEL), slowdebug)
  # _NMT_NOINLINE_ informs NMT that no inlining is done by the compiler
  JVM_CFLAGS_DEBUGLEVEL := -DASSERT -D_NMT_NOINLINE_
endif

JVM_CFLAGS += \
    $(JVM_CFLAGS_DEBUGLEVEL) \
    $(JVM_CFLAGS_TARGET_DEFINES) \
    $(JVM_CFLAGS_FEATURES) \
    $(JVM_CFLAGS_INCLUDES) \
    $(EXTRA_CFLAGS) \
    #

JVM_LDFLAGS += \
    $(SHARED_LIBRARY_FLAGS) \
    $(JVM_LDFLAGS_FEATURES) \
    $(EXTRA_LDFLAGS) \
    #

JVM_LIBS += \
    $(JVM_LIBS_FEATURES) \
    #

# These files and directories are always excluded
JVM_EXCLUDE_FILES += jsig.c jvmtiEnvRecommended.cpp jvmtiEnvStub.cpp args.cc
JVM_EXCLUDES += adlc

# Needed by vm_version.cpp
ifeq ($(OPENJDK_TARGET_CPU), x86_64)
  OPENJDK_TARGET_CPU_VM_VERSION := amd64
else ifeq ($(OPENJDK_TARGET_CPU), sparcv9)
  OPENJDK_TARGET_CPU_VM_VERSION := sparc
else
  OPENJDK_TARGET_CPU_VM_VERSION := $(OPENJDK_TARGET_CPU)
endif

CFLAGS_VM_VERSION := \
    $(VERSION_CFLAGS) \
    -DHOTSPOT_VERSION_STRING='"$(VERSION_STRING)"' \
    -DDEBUG_LEVEL='"$(DEBUG_LEVEL)"' \
    -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
    -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
    -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
    #

# -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp.
ifeq ($(USE_PRECOMPILED_HEADER), 0)
  JVM_CFLAGS += -DDONT_USE_PRECOMPILED_HEADER
endif

################################################################################
# Platform specific setup

ifneq ($(filter $(OPENJDK_TARGET_OS), linux macosx windows), )
  JVM_PRECOMPILED_HEADER := $(HOTSPOT_TOPDIR)/src/share/vm/precompiled/precompiled.hpp
endif

ifneq ($(filter $(OPENJDK_TARGET_OS), macosx aix solaris), )
  # On macosx, aix and solaris we have to link with the C++ compiler
  JVM_TOOLCHAIN := TOOLCHAIN_LINK_CXX
else
  JVM_TOOLCHAIN := TOOLCHAIN_DEFAULT
endif

ifeq ($(OPENJDK_TARGET_CPU), x86)
  JVM_EXCLUDE_PATTERNS += x86_64
else ifeq ($(OPENJDK_TARGET_CPU), x86_64)
  JVM_EXCLUDE_PATTERNS += x86_32
endif

# Inline assembly for solaris
ifeq ($(OPENJDK_TARGET_OS), solaris)
  ifeq ($(OPENJDK_TARGET_CPU), x86_64)
    JVM_CFLAGS += $(HOTSPOT_TOPDIR)/src/os_cpu/solaris_x86/vm/solaris_x86_64.il
  else ifeq ($(OPENJDK_TARGET_CPU), sparcv9)
    JVM_CFLAGS += $(HOTSPOT_TOPDIR)/src/os_cpu/solaris_sparc/vm/solaris_sparc.il
  endif
endif

ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), solaris-sparcv9)
  ifeq ($(COMPILE_WITH_DEBUG_SYMBOLS), false)
    # NOTE: In the old build, we weirdly enough set -g/-g0 always, regardless
    # of if debug symbols were needed. Without it, compilation fails on
    # sparc! :-(
    JVM_CFLAGS += -g0
  endif
endif

ifeq ($(OPENJDK_TARGET_OS), windows)
  ifeq ($(OPENJDK_TARGET_CPU_BITS), 64)
    RC_DESC := 64-Bit$(SPACE)
  endif
  JVM_RCFLAGS += -D"HS_FILEDESC=$(HOTSPOT_VM_DISTRO) $(RC_DESC)$(JVM_VARIANT) VM"
endif

ifeq ($(OPENJDK_TARGET_OS), macosx)
  # NOTE: The old build did not strip binaries on macosx.
  JVM_STRIP_SYMBOLS := false
else
  JVM_STRIP_SYMBOLS := true
endif

JVM_OPTIMIZATION ?= HIGHEST_JVM

################################################################################
# Now set up the actual compilation of the main hotspot native library

$(eval $(call SetupNativeCompilation, BUILD_LIBJVM, \
    TOOLCHAIN := $(JVM_TOOLCHAIN), \
    LIBRARY := jvm, \
    OUTPUT_DIR := $(JVM_OUTPUTDIR), \
    SRC := $(JVM_SRC_DIRS), \
    EXCLUDES := $(JVM_EXCLUDES), \
    EXCLUDE_FILES := $(JVM_EXCLUDE_FILES), \
    EXCLUDE_PATTERNS := $(JVM_EXCLUDE_PATTERNS), \
    EXTRA_OBJECT_FILES := $(DTRACE_EXTRA_OBJECT_FILES), \
    CFLAGS := $(JVM_CFLAGS), \
    CFLAGS_DEBUG_SYMBOLS := $(JVM_CFLAGS_SYMBOLS), \
    CXXFLAGS_DEBUG_SYMBOLS := $(JVM_CFLAGS_SYMBOLS), \
    vm_version.cpp_CXXFLAGS := $(CFLAGS_VM_VERSION), \
    DISABLED_WARNINGS_clang := delete-non-virtual-dtor dynamic-class-memaccess \
        empty-body format logical-op-parentheses parentheses \
        parentheses-equality switch tautological-compare, \
    DISABLED_WARNINGS_xlc := 1540-0216 1540-0198 1540-1090 1540-1639 \
        1540-1088 1500-010, \
    ASFLAGS := $(JVM_ASFLAGS), \
    LDFLAGS := $(JVM_LDFLAGS), \
    LIBS := $(JVM_LIBS), \
    OPTIMIZATION := $(JVM_OPTIMIZATION), \
    OBJECT_DIR := $(JVM_OUTPUTDIR)/objs, \
    MAPFILE := $(JVM_MAPFILE), \
    USE_MAPFILE_FOR_SYMBOLS := true, \
    STRIP_SYMBOLS := $(JVM_STRIP_SYMBOLS), \
    EMBED_MANIFEST := true, \
    RC_FLAGS := $(JVM_RCFLAGS), \
    VERSIONINFO_RESOURCE := $(HOTSPOT_TOPDIR)/src/os/windows/vm/version.rc, \
    PRECOMPILED_HEADER := $(JVM_PRECOMPILED_HEADER), \
    PRECOMPILED_HEADER_EXCLUDE := $(JVM_PRECOMPILED_HEADER_EXCLUDE), \
))

# AIX warning explanation:
# 1500-010  : (W) WARNING in ...: Infinite loop.  Program may not stop.
#             There are several infinite loops in the vm, so better suppress.
# 1540-0198 : (W) The omitted keyword "private" is assumed for base class "...".
# 1540-0216 : (W) An expression of type .. cannot be converted to type ..
#             In hotspot this fires for functionpointer to pointer conversions
# 1540-1088 : (W) The exception specification is being ignored.
#             In hotspot this is caused by throw() in declaration of new() in nmethod.hpp.
# 1540-1090 : (I) The destructor of "..." might not be called.
# 1540-1639 : (I) The behavior of long type bit fields has changed ...

# Include mapfile generation. It relies on BUILD_LIBJVM_ALL_OBJS which is only
# defined after the above call to BUILD_LIBJVM. Mapfile will be generated
# after all object files are built, but before the jvm library is linked.
include lib/JvmMapfile.gmk

TARGETS += $(BUILD_LIBJVM)