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