1 # 2 # Copyright (c) 2013, 2018, 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, 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_LIBS += \ 51 $(JVM_LIBS_FEATURES) \ 52 # 53 54 # These files and directories are always excluded 55 JVM_EXCLUDE_FILES += args.cc 56 JVM_EXCLUDES += adlc 57 58 # Needed by vm_version.cpp 59 ifeq ($(OPENJDK_TARGET_CPU), x86_64) 60 OPENJDK_TARGET_CPU_VM_VERSION := amd64 61 else ifeq ($(OPENJDK_TARGET_CPU), sparcv9) 62 OPENJDK_TARGET_CPU_VM_VERSION := sparc 63 else ifeq ($(HOTSPOT_TARGET_CPU_ARCH), arm) 64 ifeq ($(OPENJDK_TARGET_CPU), aarch64) 65 # This sets the Oracle Aarch64 port to use arm64 66 # while the original Aarch64 port uses aarch64 67 OPENJDK_TARGET_CPU_VM_VERSION := arm64 68 endif 69 else 70 OPENJDK_TARGET_CPU_VM_VERSION := $(OPENJDK_TARGET_CPU) 71 endif 72 73 CFLAGS_VM_VERSION := \ 74 $(VERSION_CFLAGS) \ 75 -DHOTSPOT_VERSION_STRING='"$(VERSION_STRING)"' \ 76 -DDEBUG_LEVEL='"$(DEBUG_LEVEL)"' \ 77 -DHOTSPOT_BUILD_USER='"$(USERNAME)"' \ 78 -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"' \ 79 -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \ 80 # 81 82 ################################################################################ 83 # Disabled warnings 84 85 DISABLED_WARNINGS_gcc := extra 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 90 91 ifeq ($(call check-jvm-feature, zero), true) 92 DISABLED_WARNINGS_gcc += return-type switch 93 endif 94 95 DISABLED_WARNINGS_clang := tautological-compare deprecated-declarations \ 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 := 1540-0216 1540-0198 1540-1090 1540-1639 1540-1088 \ 105 1500-010 106 107 DISABLED_WARNINGS_microsoft := 108 109 110 111 ################################################################################ 112 # Platform specific setup 113 114 # ARM source selection 115 116 ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), linux-arm) 117 JVM_EXCLUDE_PATTERNS += arm_64 118 119 else ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), linux-aarch64) 120 # For 64-bit arm builds, we use the 64 bit hotspot/src/cpu/arm 121 # hotspot sources if HOTSPOT_TARGET_CPU_ARCH is set to arm. 122 # Exclude the aarch64 and 32 bit arm files for this build. 123 ifeq ($(HOTSPOT_TARGET_CPU_ARCH), arm) 124 JVM_EXCLUDE_PATTERNS += arm_32 aarch64 125 endif 126 endif 127 128 ifneq ($(filter $(OPENJDK_TARGET_OS), linux macosx windows), ) 129 JVM_PRECOMPILED_HEADER := $(TOPDIR)/src/hotspot/share/precompiled/precompiled.hpp 130 endif 131 132 ifeq ($(OPENJDK_TARGET_CPU), x86) 133 JVM_EXCLUDE_PATTERNS += x86_64 134 else ifeq ($(OPENJDK_TARGET_CPU), x86_64) 135 JVM_EXCLUDE_PATTERNS += x86_32 136 endif 137 138 # Inline assembly for solaris 139 ifeq ($(OPENJDK_TARGET_OS), solaris) 140 ifeq ($(OPENJDK_TARGET_CPU), x86_64) 141 JVM_CFLAGS += $(TOPDIR)/src/hotspot/os_cpu/solaris_x86/solaris_x86_64.il 142 else ifeq ($(OPENJDK_TARGET_CPU), sparcv9) 143 JVM_CFLAGS += $(TOPDIR)/src/hotspot/os_cpu/solaris_sparc/solaris_sparc.il 144 endif 145 # Exclude warnings in devstudio 12.6 146 ifeq ($(CC_VERSION_NUMBER), 5.15) 147 DISABLED_WARNINGS_solstudio += SEC_ARR_OUTSIDE_BOUND_READ \ 148 SEC_ARR_OUTSIDE_BOUND_WRITE 149 endif 150 endif 151 152 ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), solaris-sparcv9) 153 ifeq ($(COMPILE_WITH_DEBUG_SYMBOLS), false) 154 # NOTE: In the old build, we weirdly enough set -g/-g0 always, regardless 155 # of if debug symbols were needed. Without it, compilation fails on 156 # sparc! :-( 157 JVM_CFLAGS += -g0 158 endif 159 endif 160 161 ifeq ($(OPENJDK_TARGET_OS), windows) 162 ifeq ($(OPENJDK_TARGET_CPU_BITS), 64) 163 RC_DESC := 64-Bit$(SPACE) 164 endif 165 JVM_RCFLAGS += -D"HS_FILEDESC=$(HOTSPOT_VM_DISTRO) $(RC_DESC)$(JVM_VARIANT) VM" 166 endif 167 168 JVM_OPTIMIZATION ?= HIGHEST_JVM 169 170 # Need to set JVM_STRIPFLAGS to the default value from SPEC since the STRIPFLAGS 171 # parameter to SetupNativeCompilation allows an empty value to override the 172 # default. 173 JVM_STRIPFLAGS ?= $(STRIPFLAGS) 174 175 ################################################################################ 176 # Now set up the actual compilation of the main hotspot native library 177 178 $(eval $(call SetupNativeCompilation, BUILD_LIBJVM, \ 179 NAME := jvm, \ 180 TOOLCHAIN := TOOLCHAIN_LINK_CXX, \ 181 OUTPUT_DIR := $(JVM_LIB_OUTPUTDIR), \ 182 SRC := $(JVM_SRC_DIRS), \ 183 EXCLUDES := $(JVM_EXCLUDES), \ 184 EXCLUDE_FILES := $(JVM_EXCLUDE_FILES), \ 185 EXCLUDE_PATTERNS := $(JVM_EXCLUDE_PATTERNS), \ 186 EXTRA_OBJECT_FILES := $(DTRACE_EXTRA_OBJECT_FILES), \ 187 CFLAGS := $(JVM_CFLAGS), \ 188 vm_version.cpp_CXXFLAGS := $(CFLAGS_VM_VERSION), \ 189 arguments.cpp_CXXFLAGS := $(CFLAGS_VM_VERSION), \ 190 DISABLED_WARNINGS_gcc := $(DISABLED_WARNINGS_gcc), \ 191 DISABLED_WARNINGS_clang := $(DISABLED_WARNINGS_clang), \ 192 DISABLED_WARNINGS_solstudio := $(DISABLED_WARNINGS_solstudio), \ 193 DISABLED_WARNINGS_xlc := $(DISABLED_WARNINGS_xlc), \ 194 DISABLED_WARNINGS_microsoft := $(DISABLED_WARNINGS_microsoft), \ 195 ASFLAGS := $(JVM_ASFLAGS), \ 196 LDFLAGS := $(JVM_LDFLAGS), \ 197 LIBS := $(JVM_LIBS), \ 198 OPTIMIZATION := $(JVM_OPTIMIZATION), \ 199 OBJECT_DIR := $(JVM_OUTPUTDIR)/objs, \ 200 MAPFILE := $(JVM_MAPFILE), \ 201 USE_MAPFILE_FOR_SYMBOLS := true, \ 202 STRIPFLAGS := $(JVM_STRIPFLAGS), \ 203 EMBED_MANIFEST := true, \ 204 RC_FLAGS := $(JVM_RCFLAGS), \ 205 VERSIONINFO_RESOURCE := $(TOPDIR)/src/hotspot/os/windows/version.rc, \ 206 PRECOMPILED_HEADER := $(JVM_PRECOMPILED_HEADER), \ 207 PRECOMPILED_HEADER_EXCLUDE := $(JVM_PRECOMPILED_HEADER_EXCLUDE), \ 208 )) 209 210 # Always recompile vm_version.cpp if libjvm needs to be relinked. This ensures 211 # that the internal vm version is updated as it relies on __DATE__ and __TIME__ 212 # macros. 213 VM_VERSION_OBJ := $(JVM_OUTPUTDIR)/objs/vm_version$(OBJ_SUFFIX) 214 $(VM_VERSION_OBJ): $(filter-out $(VM_VERSION_OBJ) $(JVM_MAPFILE), \ 215 $(BUILD_LIBJVM_TARGET_DEPS)) 216 217 ifeq ($(OPENJDK_TARGET_OS), windows) 218 # It doesn't matter which jvm.lib file gets exported, but we need 219 # to pick just one. 220 ifeq ($(JVM_VARIANT), $(JVM_VARIANT_MAIN)) 221 $(eval $(call SetupCopyFiles, COPY_JVM_LIB, \ 222 DEST := $(LIB_OUTPUTDIR), \ 223 FILES :=$(BUILD_LIBJVM_IMPORT_LIBRARY), \ 224 )) 225 TARGETS += $(COPY_JVM_LIB) 226 endif 227 endif 228 229 # AIX warning explanation: 230 # 1500-010 : (W) WARNING in ...: Infinite loop. Program may not stop. 231 # There are several infinite loops in the vm, so better suppress. 232 # 1540-0198 : (W) The omitted keyword "private" is assumed for base class "...". 233 # 1540-0216 : (W) An expression of type .. cannot be converted to type .. 234 # In hotspot this fires for functionpointer to pointer conversions 235 # 1540-1088 : (W) The exception specification is being ignored. 236 # In hotspot this is caused by throw() in declaration of new() in nmethod.hpp. 237 # 1540-1090 : (I) The destructor of "..." might not be called. 238 # 1540-1639 : (I) The behavior of long type bit fields has changed ... 239 240 # Include mapfile generation. It relies on BUILD_LIBJVM_ALL_OBJS which is only 241 # defined after the above call to BUILD_LIBJVM. Mapfile will be generated 242 # after all object files are built, but before the jvm library is linked. 243 include lib/JvmMapfile.gmk 244 245 TARGETS += $(BUILD_LIBJVM) 246 247 ################################################################################ 248 # Hotspot disallows the use of global operators 'new' and 'delete'. This build 249 # time check helps enforce this requirement. If you trigger this check and the 250 # reference is not obvious from the source, GNU objdump can be used to help find 251 # the reference if compiled with GCC: 252 # 253 # objdump -lrdSC <path/to/file.o> 254 # 255 # -C demangle 256 # -d disassemble 257 # -r print relocation entries, interspersed with the disassembly 258 # -S print source code, intermixed with disassembly 259 # -l include filenames and line numbers 260 # 261 # Search the output for the operator(s) of interest, to see where they are 262 # referenced. 263 264 ifneq ($(filter $(TOOLCHAIN_TYPE), gcc clang solstudio), ) 265 266 DEMANGLED_REGEXP := [^:]operator (new|delete) 267 268 # Running c++filt to find offending symbols in all files is too expensive, 269 # especially on Solaris, so use mangled names when looking for symbols. 270 # Save the demangling for when something is actually found. 271 ifeq ($(TOOLCHAIN_TYPE), solstudio) 272 MANGLED_SYMS := \ 273 __1c2n6FL_pv_ \ 274 __1c2N6FL_pv_ \ 275 __1c2k6Fpv_v_ \ 276 __1c2K6Fpv_v_ \ 277 # 278 UNDEF_PATTERN := UNDEF 279 else 280 MANGLED_SYMS := \ 281 _ZdaPv \ 282 _ZdlPv \ 283 _Znam \ 284 _Znwm \ 285 # 286 UNDEF_PATTERN := ' U ' 287 endif 288 289 define SetupOperatorNewDeleteCheck 290 $1.op_check: $1 291 if [ -n "`$(NM) $$< | $(GREP) $(addprefix -e , $(MANGLED_SYMS)) \ 292 | $(GREP) $(UNDEF_PATTERN)`" ]; then \ 293 $(ECHO) "$$<: Error: Use of global operators new and delete is not allowed in Hotspot:"; \ 294 $(NM) $$< | $(CXXFILT) | $(EGREP) '$(DEMANGLED_REGEXP)' | $(GREP) $(UNDEF_PATTERN); \ 295 $(ECHO) "See: $(TOPDIR)/make/hotspot/lib/CompileJvm.gmk"; \ 296 exit 1; \ 297 fi 298 $(TOUCH) $$@ 299 300 TARGETS += $1.op_check 301 endef 302 303 $(foreach o, $(BUILD_LIBJVM_ALL_OBJS), $(eval $(call SetupOperatorNewDeleteCheck,$o))) 304 endif