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, specific file overrides, and general flags.
28 include lib/JvmFeatures.gmk
29 include lib/JvmOverrideFiles.gmk
30 include lib/JvmFlags.gmk
31
32 # Include support files that will setup DTRACE_EXTRA_OBJECT_FILES.
33 include lib/JvmDtraceObjects.gmk
34
35 ################################################################################
36 # Setup compilation of the main Hotspot native library (libjvm).
37
38 JVM_OUTPUTDIR := $(JVM_VARIANT_OUTPUTDIR)/libjvm
39 JVM_MAPFILE := $(JVM_OUTPUTDIR)/mapfile
40
41 ################################################################################
42 # Platform independent setup
43
44 JVM_LDFLAGS += \
45 $(SHARED_LIBRARY_FLAGS) \
46 $(JVM_LDFLAGS_FEATURES) \
47 $(EXTRA_LDFLAGS) \
48 #
49
50 JVM_ASFLAGS += $(EXTRA_ASFLAGS)
51
52 JVM_LIBS += \
53 $(JVM_LIBS_FEATURES) \
54 #
55
56 # These files and directories are always excluded
57 JVM_EXCLUDE_FILES += args.cc
58 JVM_EXCLUDES += adlc
59
60 # Needed by abstract_vm_version.cpp
61 ifeq ($(call isTargetCpu, x86_64), true)
62 OPENJDK_TARGET_CPU_VM_VERSION := amd64
63 else ifeq ($(call isTargetCpu, sparcv9), true)
64 OPENJDK_TARGET_CPU_VM_VERSION := sparc
65 else
66 OPENJDK_TARGET_CPU_VM_VERSION := $(OPENJDK_TARGET_CPU)
67 endif
68
69 CFLAGS_VM_VERSION := \
70 $(VERSION_CFLAGS) \
71 -DHOTSPOT_VERSION_STRING='"$(VERSION_STRING)"' \
72 -DDEBUG_LEVEL='"$(DEBUG_LEVEL)"' \
73 -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
74 -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
75 -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
76 #
77
78 ifneq ($(HOTSPOT_BUILD_TIME), )
79 CFLAGS_VM_VERSION += -DHOTSPOT_BUILD_TIME='"$(HOTSPOT_BUILD_TIME)"'
80 endif
81
82 ################################################################################
83 # Disabled warnings
84
85 DISABLED_WARNINGS_gcc := parentheses comment unknown-pragmas address \
86 delete-non-virtual-dtor char-subscripts array-bounds int-in-bool-context \
87 ignored-qualifiers missing-field-initializers implicit-fallthrough \
88 empty-body strict-overflow sequence-point maybe-uninitialized \
89 misleading-indentation cast-function-type
90
91 ifeq ($(call check-jvm-feature, zero), true)
92 DISABLED_WARNINGS_gcc += return-type switch clobbered
93 endif
94
95 DISABLED_WARNINGS_clang := tautological-compare \
96 undefined-var-template sometimes-uninitialized unknown-pragmas \
97 delete-non-virtual-dtor missing-braces char-subscripts \
98 ignored-qualifiers missing-field-initializers mismatched-tags
99
100 DISABLED_WARNINGS_solstudio := labelnotused hidef w_novirtualdescr inlafteruse \
101 unknownpragma doubunder w_enumnotused w_toomanyenumnotused \
102 wvarhidenmem wunreachable wnoretvalue notemsource
103
104 DISABLED_WARNINGS_xlc := tautological-compare shift-negative-value
105
106 DISABLED_WARNINGS_microsoft :=
107
108
109
110 ################################################################################
111 # Platform specific setup
112
113 # ARM source selection
114
115 ifeq ($(call And, $(call isTargetOs, linux) $(call isTargetCpu, arm)), true)
116 JVM_EXCLUDE_PATTERNS += arm_64
117
118 else ifeq ($(call And, $(call isTargetOs, linux) $(call isTargetCpu, aarch64)), true)
119 # For 64-bit arm builds, we use the 64 bit hotspot/src/cpu/arm
120 # hotspot sources if HOTSPOT_TARGET_CPU_ARCH is set to arm.
121 # Exclude the aarch64 and 32 bit arm files for this build.
122 ifeq ($(HOTSPOT_TARGET_CPU_ARCH), arm)
123 JVM_EXCLUDE_PATTERNS += arm_32 aarch64
124 endif
125 endif
126
127 ifeq ($(call isTargetOs, linux macosx windows), true)
128 JVM_PRECOMPILED_HEADER := $(TOPDIR)/src/hotspot/share/precompiled/precompiled.hpp
129 endif
130
131 ifeq ($(call isTargetCpu, x86), true)
132 JVM_EXCLUDE_PATTERNS += x86_64
133 else ifeq ($(call isTargetCpu, x86_64), true)
134 JVM_EXCLUDE_PATTERNS += x86_32
135 endif
136
137 # Inline assembly for solaris
138 ifeq ($(call isTargetOs, solaris), true)
139 ifeq ($(call isTargetCpu, x86_64), true)
140 JVM_CFLAGS += $(TOPDIR)/src/hotspot/os_cpu/solaris_x86/solaris_x86_64.il
141 else ifeq ($(call isTargetCpu, sparcv9), true)
142 JVM_CFLAGS += $(TOPDIR)/src/hotspot/os_cpu/solaris_sparc/solaris_sparc.il
143 endif
144 # Exclude warnings in devstudio 12.6
145 ifeq ($(CC_VERSION_NUMBER), 5.15)
146 DISABLED_WARNINGS_solstudio += SEC_ARR_OUTSIDE_BOUND_READ \
147 SEC_ARR_OUTSIDE_BOUND_WRITE
148 endif
149 endif
150
151 ifeq ($(call And, $(call isTargetOs, solaris) $(call isTargetCpu, sparcv9)), true)
152 ifeq ($(COMPILE_WITH_DEBUG_SYMBOLS), false)
153 # NOTE: In the old build, we weirdly enough set -g/-g0 always, regardless
154 # of if debug symbols were needed. Without it, compilation fails on
155 # sparc! :-(
156 JVM_CFLAGS += -g0
157 endif
158 endif
159
160 ifeq ($(call isTargetOs, windows), true)
161 ifeq ($(call isTargetCpuBits, 64), true)
162 RC_DESC := 64-Bit$(SPACE)
163 endif
164 JVM_RCFLAGS += -D"HS_FILEDESC=$(HOTSPOT_VM_DISTRO) $(RC_DESC)$(JVM_VARIANT) VM"
165 endif
166
167 JVM_OPTIMIZATION ?= HIGHEST_JVM
168
169 # Need to set JVM_STRIPFLAGS to the default value from SPEC since the STRIPFLAGS
170 # parameter to SetupNativeCompilation allows an empty value to override the
171 # default.
172 JVM_STRIPFLAGS ?= $(STRIPFLAGS)
173
174 # This source set is reused so save in cache.
175 $(call FillFindCache, $(JVM_SRC_DIRS))
176
177 ################################################################################
178 # Now set up the actual compilation of the main hotspot native library
179
180 $(eval $(call SetupNativeCompilation, BUILD_LIBJVM, \
181 NAME := jvm, \
182 TOOLCHAIN := TOOLCHAIN_LINK_CXX, \
183 OUTPUT_DIR := $(JVM_LIB_OUTPUTDIR), \
184 SRC := $(JVM_SRC_DIRS), \
185 EXCLUDES := $(JVM_EXCLUDES), \
186 EXCLUDE_FILES := $(JVM_EXCLUDE_FILES), \
187 EXCLUDE_PATTERNS := $(JVM_EXCLUDE_PATTERNS), \
188 EXTRA_OBJECT_FILES := $(DTRACE_EXTRA_OBJECT_FILES), \
189 CFLAGS := $(JVM_CFLAGS), \
190 abstract_vm_version.cpp_CXXFLAGS := $(CFLAGS_VM_VERSION), \
191 arguments.cpp_CXXFLAGS := $(CFLAGS_VM_VERSION), \
192 DISABLED_WARNINGS_gcc := $(DISABLED_WARNINGS_gcc), \
193 DISABLED_WARNINGS_clang := $(DISABLED_WARNINGS_clang), \
194 DISABLED_WARNINGS_solstudio := $(DISABLED_WARNINGS_solstudio), \
195 DISABLED_WARNINGS_xlc := $(DISABLED_WARNINGS_xlc), \
196 DISABLED_WARNINGS_microsoft := $(DISABLED_WARNINGS_microsoft), \
197 ASFLAGS := $(JVM_ASFLAGS), \
198 LDFLAGS := $(JVM_LDFLAGS), \
199 LIBS := $(JVM_LIBS), \
200 OPTIMIZATION := $(JVM_OPTIMIZATION), \
201 OBJECT_DIR := $(JVM_OUTPUTDIR)/objs, \
202 MAPFILE := $(JVM_MAPFILE), \
203 USE_MAPFILE_FOR_SYMBOLS := true, \
204 STRIPFLAGS := $(JVM_STRIPFLAGS), \
205 EMBED_MANIFEST := true, \
206 RC_FLAGS := $(JVM_RCFLAGS), \
207 VERSIONINFO_RESOURCE := $(TOPDIR)/src/hotspot/os/windows/version.rc, \
208 PRECOMPILED_HEADER := $(JVM_PRECOMPILED_HEADER), \
209 PRECOMPILED_HEADER_EXCLUDE := $(JVM_PRECOMPILED_HEADER_EXCLUDE), \
210 ))
211
212 # Always recompile abstract_vm_version.cpp if libjvm needs to be relinked. This ensures
213 # that the internal vm version is updated as it relies on __DATE__ and __TIME__
214 # macros.
258 #
259 # -C demangle
260 # -d disassemble
261 # -r print relocation entries, interspersed with the disassembly
262 # -S print source code, intermixed with disassembly
263 # -l include filenames and line numbers
264 #
265 # Search the output for the operator(s) of interest, to see where they are
266 # referenced.
267 #
268 # When a reference to the global 'operator delete' is reported, it might be
269 # due to a "deleting destructor". In this case, objdump may show the
270 # reference to be associated with but not actually in a destructor. A
271 # deleting destructor is automatically generated for a class whose destructor
272 # is virtual. A deleting destructor requires an accessible 'operator delete'
273 # for the associated class. If the class doesn't provide a more specific
274 # declaration (either directly or by inheriting from a class that provides
275 # one) then the global definition will be used, triggering this check.
276
277 ifneq ($(GENERATE_COMPILE_COMMANDS_ONLY), true)
278 ifneq ($(filter $(TOOLCHAIN_TYPE), gcc clang solstudio), )
279
280 DEMANGLED_REGEXP := [^:]operator (new|delete)
281
282 # Running c++filt to find offending symbols in all files is too expensive,
283 # especially on Solaris, so use mangled names when looking for symbols.
284 # Save the demangling for when something is actually found.
285 ifeq ($(TOOLCHAIN_TYPE), solstudio)
286 MANGLED_SYMS := \
287 __1c2n6FL_pv_ \
288 __1c2N6FL_pv_ \
289 __1c2k6Fpv_v_ \
290 __1c2K6Fpv_v_ \
291 #
292 UNDEF_PATTERN := UNDEF
293 else
294 MANGLED_SYMS := \
295 _ZdaPv \
296 _ZdlPv \
297 _Znam \
298 _Znwm \
299 #
300 UNDEF_PATTERN := ' U '
301 endif
302
303 define SetupOperatorNewDeleteCheck
304 $1.op_check: $1
305 if [ -n "`$(NM) $$< | $(GREP) $(addprefix -e , $(MANGLED_SYMS)) \
306 | $(GREP) $(UNDEF_PATTERN)`" ]; then \
307 $(ECHO) "$$<: Error: Use of global operators new and delete is not allowed in Hotspot:"; \
308 $(NM) $$< | $(CXXFILT) | $(EGREP) '$(DEMANGLED_REGEXP)' | $(GREP) $(UNDEF_PATTERN); \
309 $(ECHO) "See: $(TOPDIR)/make/hotspot/lib/CompileJvm.gmk"; \
310 exit 1; \
311 fi
312 $(TOUCH) $$@
313
314 TARGETS += $1.op_check
315 endef
316
317 $(foreach o, $(BUILD_LIBJVM_ALL_OBJS), $(eval $(call SetupOperatorNewDeleteCheck,$o)))
318 endif
319 endif
|
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, specific file overrides, and general flags.
28 include lib/JvmFeatures.gmk
29 include lib/JvmOverrideFiles.gmk
30 include lib/JvmFlags.gmk
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 JVM_LDFLAGS += \
42 $(SHARED_LIBRARY_FLAGS) \
43 $(JVM_LDFLAGS_FEATURES) \
44 $(EXTRA_LDFLAGS) \
45 #
46
47 JVM_ASFLAGS += $(EXTRA_ASFLAGS)
48
49 JVM_LIBS += \
50 $(JVM_LIBS_FEATURES) \
51 #
52
53 # These files and directories are always excluded
54 JVM_EXCLUDE_FILES += args.cc
55 JVM_EXCLUDES += adlc
56
57 # Needed by abstract_vm_version.cpp
58 ifeq ($(call isTargetCpu, x86_64), true)
59 OPENJDK_TARGET_CPU_VM_VERSION := amd64
60 else
61 OPENJDK_TARGET_CPU_VM_VERSION := $(OPENJDK_TARGET_CPU)
62 endif
63
64 CFLAGS_VM_VERSION := \
65 $(VERSION_CFLAGS) \
66 -DHOTSPOT_VERSION_STRING='"$(VERSION_STRING)"' \
67 -DDEBUG_LEVEL='"$(DEBUG_LEVEL)"' \
68 -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \
69 -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \
70 -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
71 #
72
73 ifneq ($(HOTSPOT_BUILD_TIME), )
74 CFLAGS_VM_VERSION += -DHOTSPOT_BUILD_TIME='"$(HOTSPOT_BUILD_TIME)"'
75 endif
76
77 ################################################################################
78 # Disabled warnings
79
80 DISABLED_WARNINGS_gcc := parentheses comment unknown-pragmas address \
81 delete-non-virtual-dtor char-subscripts array-bounds int-in-bool-context \
82 ignored-qualifiers missing-field-initializers implicit-fallthrough \
83 empty-body strict-overflow sequence-point maybe-uninitialized \
84 misleading-indentation cast-function-type
85
86 ifeq ($(call check-jvm-feature, zero), true)
87 DISABLED_WARNINGS_gcc += return-type switch clobbered
88 endif
89
90 DISABLED_WARNINGS_clang := tautological-compare \
91 undefined-var-template sometimes-uninitialized unknown-pragmas \
92 delete-non-virtual-dtor missing-braces char-subscripts \
93 ignored-qualifiers missing-field-initializers mismatched-tags
94
95 DISABLED_WARNINGS_xlc := tautological-compare shift-negative-value
96
97 DISABLED_WARNINGS_microsoft :=
98
99
100
101 ################################################################################
102 # Platform specific setup
103
104 # ARM source selection
105
106 ifeq ($(call And, $(call isTargetOs, linux) $(call isTargetCpu, arm)), true)
107 JVM_EXCLUDE_PATTERNS += arm_64
108
109 else ifeq ($(call And, $(call isTargetOs, linux) $(call isTargetCpu, aarch64)), true)
110 # For 64-bit arm builds, we use the 64 bit hotspot/src/cpu/arm
111 # hotspot sources if HOTSPOT_TARGET_CPU_ARCH is set to arm.
112 # Exclude the aarch64 and 32 bit arm files for this build.
113 ifeq ($(HOTSPOT_TARGET_CPU_ARCH), arm)
114 JVM_EXCLUDE_PATTERNS += arm_32 aarch64
115 endif
116 endif
117
118 ifeq ($(call isTargetOs, linux macosx windows), true)
119 JVM_PRECOMPILED_HEADER := $(TOPDIR)/src/hotspot/share/precompiled/precompiled.hpp
120 endif
121
122 ifeq ($(call isTargetCpu, x86), true)
123 JVM_EXCLUDE_PATTERNS += x86_64
124 else ifeq ($(call isTargetCpu, x86_64), true)
125 JVM_EXCLUDE_PATTERNS += x86_32
126 endif
127
128 ifeq ($(call isTargetOs, windows), true)
129 ifeq ($(call isTargetCpuBits, 64), true)
130 RC_DESC := 64-Bit$(SPACE)
131 endif
132 JVM_RCFLAGS += -D"HS_FILEDESC=$(HOTSPOT_VM_DISTRO) $(RC_DESC)$(JVM_VARIANT) VM"
133 endif
134
135 JVM_OPTIMIZATION ?= HIGHEST_JVM
136
137 # Need to set JVM_STRIPFLAGS to the default value from SPEC since the STRIPFLAGS
138 # parameter to SetupNativeCompilation allows an empty value to override the
139 # default.
140 JVM_STRIPFLAGS ?= $(STRIPFLAGS)
141
142 # This source set is reused so save in cache.
143 $(call FillFindCache, $(JVM_SRC_DIRS))
144
145 ################################################################################
146 # Now set up the actual compilation of the main hotspot native library
147
148 $(eval $(call SetupNativeCompilation, BUILD_LIBJVM, \
149 NAME := jvm, \
150 TOOLCHAIN := TOOLCHAIN_LINK_CXX, \
151 OUTPUT_DIR := $(JVM_LIB_OUTPUTDIR), \
152 SRC := $(JVM_SRC_DIRS), \
153 EXCLUDES := $(JVM_EXCLUDES), \
154 EXCLUDE_FILES := $(JVM_EXCLUDE_FILES), \
155 EXCLUDE_PATTERNS := $(JVM_EXCLUDE_PATTERNS), \
156 EXTRA_OBJECT_FILES := $(DTRACE_EXTRA_OBJECT_FILES), \
157 CFLAGS := $(JVM_CFLAGS), \
158 abstract_vm_version.cpp_CXXFLAGS := $(CFLAGS_VM_VERSION), \
159 arguments.cpp_CXXFLAGS := $(CFLAGS_VM_VERSION), \
160 DISABLED_WARNINGS_gcc := $(DISABLED_WARNINGS_gcc), \
161 DISABLED_WARNINGS_clang := $(DISABLED_WARNINGS_clang), \
162 DISABLED_WARNINGS_xlc := $(DISABLED_WARNINGS_xlc), \
163 DISABLED_WARNINGS_microsoft := $(DISABLED_WARNINGS_microsoft), \
164 ASFLAGS := $(JVM_ASFLAGS), \
165 LDFLAGS := $(JVM_LDFLAGS), \
166 LIBS := $(JVM_LIBS), \
167 OPTIMIZATION := $(JVM_OPTIMIZATION), \
168 OBJECT_DIR := $(JVM_OUTPUTDIR)/objs, \
169 MAPFILE := $(JVM_MAPFILE), \
170 USE_MAPFILE_FOR_SYMBOLS := true, \
171 STRIPFLAGS := $(JVM_STRIPFLAGS), \
172 EMBED_MANIFEST := true, \
173 RC_FLAGS := $(JVM_RCFLAGS), \
174 VERSIONINFO_RESOURCE := $(TOPDIR)/src/hotspot/os/windows/version.rc, \
175 PRECOMPILED_HEADER := $(JVM_PRECOMPILED_HEADER), \
176 PRECOMPILED_HEADER_EXCLUDE := $(JVM_PRECOMPILED_HEADER_EXCLUDE), \
177 ))
178
179 # Always recompile abstract_vm_version.cpp if libjvm needs to be relinked. This ensures
180 # that the internal vm version is updated as it relies on __DATE__ and __TIME__
181 # macros.
225 #
226 # -C demangle
227 # -d disassemble
228 # -r print relocation entries, interspersed with the disassembly
229 # -S print source code, intermixed with disassembly
230 # -l include filenames and line numbers
231 #
232 # Search the output for the operator(s) of interest, to see where they are
233 # referenced.
234 #
235 # When a reference to the global 'operator delete' is reported, it might be
236 # due to a "deleting destructor". In this case, objdump may show the
237 # reference to be associated with but not actually in a destructor. A
238 # deleting destructor is automatically generated for a class whose destructor
239 # is virtual. A deleting destructor requires an accessible 'operator delete'
240 # for the associated class. If the class doesn't provide a more specific
241 # declaration (either directly or by inheriting from a class that provides
242 # one) then the global definition will be used, triggering this check.
243
244 ifneq ($(GENERATE_COMPILE_COMMANDS_ONLY), true)
245 ifneq ($(filter $(TOOLCHAIN_TYPE), gcc clang), )
246
247 DEMANGLED_REGEXP := [^:]operator (new|delete)
248
249 # Running c++filt to find offending symbols in all files is too expensive,
250 # so use mangled names when looking for symbols.
251 # Save the demangling for when something is actually found.
252 MANGLED_SYMS := \
253 _ZdaPv \
254 _ZdlPv \
255 _Znam \
256 _Znwm \
257 #
258 UNDEF_PATTERN := ' U '
259
260 define SetupOperatorNewDeleteCheck
261 $1.op_check: $1
262 if [ -n "`$(NM) $$< | $(GREP) $(addprefix -e , $(MANGLED_SYMS)) \
263 | $(GREP) $(UNDEF_PATTERN)`" ]; then \
264 $(ECHO) "$$<: Error: Use of global operators new and delete is not allowed in Hotspot:"; \
265 $(NM) $$< | $(CXXFILT) | $(EGREP) '$(DEMANGLED_REGEXP)' | $(GREP) $(UNDEF_PATTERN); \
266 $(ECHO) "See: $(TOPDIR)/make/hotspot/lib/CompileJvm.gmk"; \
267 exit 1; \
268 fi
269 $(TOUCH) $$@
270
271 TARGETS += $1.op_check
272 endef
273
274 $(foreach o, $(BUILD_LIBJVM_ALL_OBJS), $(eval $(call SetupOperatorNewDeleteCheck,$o)))
275 endif
276 endif
|