CompileJvm.gmk revision 13184:7903df1b0c4f
1113828Simp#
2113828Simp# Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
3113828Simp# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4113828Simp#
5113828Simp# This code is free software; you can redistribute it and/or modify it
6113828Simp# under the terms of the GNU General Public License version 2 only, as
7113828Simp# published by the Free Software Foundation.  Oracle designates this
8113828Simp# particular file as subject to the "Classpath" exception as provided
9113828Simp# by Oracle in the LICENSE file that accompanied this code.
10113828Simp#
11113828Simp# This code is distributed in the hope that it will be useful, but WITHOUT
12113828Simp# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13113828Simp# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14113828Simp# version 2 for more details (a copy is included in the LICENSE file that
15113828Simp# accompanied this code).
16113828Simp#
17113828Simp# You should have received a copy of the GNU General Public License version
18113828Simp# 2 along with this work; if not, write to the Free Software Foundation,
19113828Simp# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20113828Simp#
21113828Simp# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22113828Simp# or visit www.oracle.com if you need additional information or have any
23113828Simp# questions.
24113828Simp#
25113828Simp
26113828Simp# Include support files that will setup compiler flags due to the selected
27113828Simp# jvm feature set, and specific file overrides.
28113828Simpinclude lib/JvmFeatures.gmk
29113828Simpinclude lib/JvmOverrideFiles.gmk
30113828Simp
31113828Simp$(eval $(call IncludeCustomExtension, hotspot, lib/CompileJvm.gmk))
32113828Simp
33113828Simp################################################################################
34113828Simp# Setup compilation of the main Hotspot native library (libjvm).
35115418Sru
36115418SruJVM_OUTPUTDIR := $(JVM_VARIANT_OUTPUTDIR)/libjvm
37113828SimpJVM_MAPFILE := $(JVM_OUTPUTDIR)/mapfile
38113828Simp
39113828Simp################################################################################
40122173Sdes# Platform independent setup
41113828Simp
42122173Sdes# This variable may be added to by a custom extension
43113828SimpJVM_SRC_ROOTS += $(HOTSPOT_TOPDIR)/src
44113828Simp
45115418SruJVM_SRC_DIRS += $(call uniq, $(wildcard $(foreach d, $(JVM_SRC_ROOTS), \
46113828Simp        $d/share/vm \
47115418Sru        $d/os/$(HOTSPOT_TARGET_OS)/vm \
48113828Simp        $d/os/$(HOTSPOT_TARGET_OS_TYPE)/vm \
49115418Sru        $d/cpu/$(HOTSPOT_TARGET_CPU_ARCH)/vm \
50113828Simp        $d/os_cpu/$(HOTSPOT_TARGET_OS)_$(HOTSPOT_TARGET_CPU_ARCH)/vm \
51115418Sru    ))) \
52113828Simp    $(JVM_VARIANT_OUTPUTDIR)/gensrc/jvmtifiles \
53113828Simp    $(JVM_VARIANT_OUTPUTDIR)/gensrc/tracefiles \
54113828Simp    #
55121414Shmp
56113828SimpJVM_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# INCLUDE_SUFFIX_* is only meant for including the proper
64# platform files. Don't use it to guard code. Use the value of
65# HOTSPOT_TARGET_CPU_DEFINE etc. instead.
66# Remaining TARGET_ARCH_* is needed to select the cpu specific
67# sources for 64-bit ARM ports (arm versus aarch64).
68JVM_CFLAGS_TARGET_DEFINES += \
69    -DTARGET_ARCH_$(HOTSPOT_TARGET_CPU_ARCH) \
70    -DINCLUDE_SUFFIX_OS=_$(HOTSPOT_TARGET_OS) \
71    -DINCLUDE_SUFFIX_CPU=_$(HOTSPOT_TARGET_CPU_ARCH) \
72    -DINCLUDE_SUFFIX_COMPILER=_$(HOTSPOT_TOOLCHAIN_TYPE) \
73    -DTARGET_COMPILER_$(HOTSPOT_TOOLCHAIN_TYPE) \
74    -D$(HOTSPOT_TARGET_CPU_DEFINE) \
75    -DHOTSPOT_LIB_ARCH='"$(OPENJDK_TARGET_CPU_LEGACY_LIB)"' \
76    #
77
78ifeq ($(DEBUG_LEVEL), release)
79  # For hotspot, release builds differ internally between "optimized" and "product"
80  # in that "optimize" does not define PRODUCT.
81  ifneq ($(HOTSPOT_DEBUG_LEVEL), optimized)
82    JVM_CFLAGS_DEBUGLEVEL := -DPRODUCT
83  endif
84else ifeq ($(DEBUG_LEVEL), fastdebug)
85  JVM_CFLAGS_DEBUGLEVEL := -DASSERT
86  ifeq ($(filter $(OPENJDK_TARGET_OS), windows aix), )
87    # NOTE: Old build did not define CHECK_UNHANDLED_OOPS on Windows and AIX.
88    JVM_CFLAGS_DEBUGLEVEL += -DCHECK_UNHANDLED_OOPS
89  endif
90else ifeq ($(DEBUG_LEVEL), slowdebug)
91  # _NMT_NOINLINE_ informs NMT that no inlining is done by the compiler
92  JVM_CFLAGS_DEBUGLEVEL := -DASSERT -D_NMT_NOINLINE_
93endif
94
95JVM_CFLAGS += \
96    $(JVM_CFLAGS_DEBUGLEVEL) \
97    $(JVM_CFLAGS_TARGET_DEFINES) \
98    $(JVM_CFLAGS_FEATURES) \
99    $(JVM_CFLAGS_INCLUDES) \
100    $(EXTRA_CFLAGS) \
101    #
102
103JVM_LDFLAGS += \
104    $(SHARED_LIBRARY_FLAGS) \
105    $(JVM_LDFLAGS_FEATURES) \
106    $(EXTRA_LDFLAGS) \
107    #
108
109JVM_LIBS += \
110    $(JVM_LIBS_FEATURES) \
111    #
112
113# These files and directories are always excluded
114JVM_EXCLUDE_FILES += jsig.c jvmtiEnvRecommended.cpp jvmtiEnvStub.cpp args.cc
115JVM_EXCLUDES += adlc
116
117# Needed by vm_version.cpp
118ifeq ($(OPENJDK_TARGET_CPU), x86_64)
119  OPENJDK_TARGET_CPU_VM_VERSION := amd64
120else ifeq ($(OPENJDK_TARGET_CPU), sparcv9)
121  OPENJDK_TARGET_CPU_VM_VERSION := sparc
122else ifeq ($(HOTSPOT_TARGET_CPU_ARCH), arm)
123  ifeq ($(OPENJDK_TARGET_CPU), aarch64)
124    # This sets the Oracle Aarch64 port to use arm64
125    # while the original Aarch64 port uses aarch64
126    OPENJDK_TARGET_CPU_VM_VERSION := arm64
127  endif
128else
129  OPENJDK_TARGET_CPU_VM_VERSION := $(OPENJDK_TARGET_CPU)
130endif
131
132CFLAGS_VM_VERSION := \
133    $(VERSION_CFLAGS) \
134    -DHOTSPOT_VERSION_STRING='"$(VERSION_STRING)"' \
135    -DDEBUG_LEVEL='"$(DEBUG_LEVEL)"' \
136    -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
137    -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
138    -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
139    #
140
141# -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp.
142ifeq ($(USE_PRECOMPILED_HEADER), false)
143  JVM_CFLAGS += -DDONT_USE_PRECOMPILED_HEADER
144endif
145
146################################################################################
147# Platform specific setup
148
149# ARM source selection
150
151ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), linux-arm)
152  JVM_EXCLUDE_PATTERNS += arm_64
153
154else ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), linux-aarch64)
155  # For 64-bit arm builds, we use the 64 bit hotspot/src/cpu/arm
156  # hotspot sources if HOTSPOT_TARGET_CPU_ARCH is set to arm.
157  # Exclude the aarch64 and 32 bit arm files for this build.
158  ifeq ($(HOTSPOT_TARGET_CPU_ARCH), arm)
159    JVM_EXCLUDE_PATTERNS += arm_32 aarch64
160  endif
161endif
162
163ifneq ($(filter $(OPENJDK_TARGET_OS), linux macosx windows), )
164  JVM_PRECOMPILED_HEADER := $(HOTSPOT_TOPDIR)/src/share/vm/precompiled/precompiled.hpp
165endif
166
167ifeq ($(OPENJDK_TARGET_CPU), x86)
168  JVM_EXCLUDE_PATTERNS += x86_64
169else ifeq ($(OPENJDK_TARGET_CPU), x86_64)
170  JVM_EXCLUDE_PATTERNS += x86_32
171endif
172
173# Inline assembly for solaris
174ifeq ($(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
180endif
181
182ifeq ($(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
189endif
190
191ifeq ($(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"
196endif
197
198JVM_OPTIMIZATION ?= HIGHEST_JVM
199
200# Need to set JVM_STRIPFLAGS to the default value from SPEC since the STRIPFLAGS
201# parameter to SetupNativeCompilation allows an empty value to override the
202# default.
203JVM_STRIPFLAGS ?= $(STRIPFLAGS)
204
205################################################################################
206# Now set up the actual compilation of the main hotspot native library
207
208$(eval $(call SetupNativeCompilation, BUILD_LIBJVM, \
209    TOOLCHAIN := TOOLCHAIN_LINK_CXX, \
210    LIBRARY := jvm, \
211    OUTPUT_DIR := $(JVM_LIB_OUTPUTDIR), \
212    SRC := $(JVM_SRC_DIRS), \
213    EXCLUDES := $(JVM_EXCLUDES), \
214    EXCLUDE_FILES := $(JVM_EXCLUDE_FILES), \
215    EXCLUDE_PATTERNS := $(JVM_EXCLUDE_PATTERNS), \
216    EXTRA_OBJECT_FILES := $(DTRACE_EXTRA_OBJECT_FILES), \
217    CFLAGS := $(JVM_CFLAGS), \
218    CFLAGS_DEBUG_SYMBOLS := $(JVM_CFLAGS_SYMBOLS), \
219    CXXFLAGS_DEBUG_SYMBOLS := $(JVM_CFLAGS_SYMBOLS), \
220    vm_version.cpp_CXXFLAGS := $(CFLAGS_VM_VERSION), \
221    DISABLED_WARNINGS_clang := delete-non-virtual-dtor dynamic-class-memaccess \
222        empty-body format logical-op-parentheses parentheses \
223        parentheses-equality switch tautological-compare, \
224    DISABLED_WARNINGS_xlc := 1540-0216 1540-0198 1540-1090 1540-1639 \
225        1540-1088 1500-010, \
226    ASFLAGS := $(JVM_ASFLAGS), \
227    LDFLAGS := $(JVM_LDFLAGS), \
228    LIBS := $(JVM_LIBS), \
229    OPTIMIZATION := $(JVM_OPTIMIZATION), \
230    OBJECT_DIR := $(JVM_OUTPUTDIR)/objs, \
231    MAPFILE := $(JVM_MAPFILE), \
232    USE_MAPFILE_FOR_SYMBOLS := true, \
233    STRIPFLAGS := $(JVM_STRIPFLAGS), \
234    EMBED_MANIFEST := true, \
235    RC_FLAGS := $(JVM_RCFLAGS), \
236    VERSIONINFO_RESOURCE := $(HOTSPOT_TOPDIR)/src/os/windows/vm/version.rc, \
237    PRECOMPILED_HEADER := $(JVM_PRECOMPILED_HEADER), \
238    PRECOMPILED_HEADER_EXCLUDE := $(JVM_PRECOMPILED_HEADER_EXCLUDE), \
239))
240
241ifeq ($(OPENJDK_TARGET_OS), windows)
242  # It doesn't matter which jvm.lib file gets exported, but we need
243  # to pick just one.
244  ifeq ($(JVM_VARIANT), $(firstword $(JVM_VARIANTS)))
245    $(eval $(call SetupCopyFiles, COPY_JVM_LIB, \
246        DEST := $(LIB_OUTPUTDIR), \
247        FILES :=$(JVM_VARIANT_OUTPUTDIR)/libjvm/objs/jvm.lib, \
248    ))
249    TARGETS += $(COPY_JVM_LIB)
250  endif
251endif
252
253# AIX warning explanation:
254# 1500-010  : (W) WARNING in ...: Infinite loop.  Program may not stop.
255#             There are several infinite loops in the vm, so better suppress.
256# 1540-0198 : (W) The omitted keyword "private" is assumed for base class "...".
257# 1540-0216 : (W) An expression of type .. cannot be converted to type ..
258#             In hotspot this fires for functionpointer to pointer conversions
259# 1540-1088 : (W) The exception specification is being ignored.
260#             In hotspot this is caused by throw() in declaration of new() in nmethod.hpp.
261# 1540-1090 : (I) The destructor of "..." might not be called.
262# 1540-1639 : (I) The behavior of long type bit fields has changed ...
263
264# Include mapfile generation. It relies on BUILD_LIBJVM_ALL_OBJS which is only
265# defined after the above call to BUILD_LIBJVM. Mapfile will be generated
266# after all object files are built, but before the jvm library is linked.
267include lib/JvmMapfile.gmk
268
269TARGETS += $(BUILD_LIBJVM)
270