1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/make/linux/makefiles/vm.make Wed Apr 27 01:25:04 2016 +0800 1.3 @@ -0,0 +1,390 @@ 1.4 +# 1.5 +# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 1.6 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 +# 1.8 +# This code is free software; you can redistribute it and/or modify it 1.9 +# under the terms of the GNU General Public License version 2 only, as 1.10 +# published by the Free Software Foundation. 1.11 +# 1.12 +# This code is distributed in the hope that it will be useful, but WITHOUT 1.13 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 +# version 2 for more details (a copy is included in the LICENSE file that 1.16 +# accompanied this code). 1.17 +# 1.18 +# You should have received a copy of the GNU General Public License version 1.19 +# 2 along with this work; if not, write to the Free Software Foundation, 1.20 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 +# 1.22 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 +# or visit www.oracle.com if you need additional information or have any 1.24 +# questions. 1.25 +# 1.26 +# 1.27 + 1.28 +# Rules to build JVM and related libraries, included from vm.make in the build 1.29 +# directory. 1.30 + 1.31 +# Common build rules. 1.32 +MAKEFILES_DIR=$(GAMMADIR)/make/$(Platform_os_family)/makefiles 1.33 +include $(MAKEFILES_DIR)/rules.make 1.34 +include $(GAMMADIR)/make/altsrc.make 1.35 + 1.36 +default: build 1.37 + 1.38 +#---------------------------------------------------------------------- 1.39 +# Defs 1.40 + 1.41 +GENERATED = ../generated 1.42 +DEP_DIR = $(GENERATED)/dependencies 1.43 + 1.44 +# reads the generated files defining the set of .o's and the .o .h dependencies 1.45 +-include $(DEP_DIR)/*.d 1.46 + 1.47 +# read machine-specific adjustments (%%% should do this via buildtree.make?) 1.48 +ifeq ($(findstring true, $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true) 1.49 + include $(MAKEFILES_DIR)/zeroshark.make 1.50 +else 1.51 + include $(MAKEFILES_DIR)/$(BUILDARCH).make 1.52 + -include $(HS_ALT_MAKE)/$(Platform_os_family)/makefiles/$(BUILDARCH).make 1.53 +endif 1.54 + 1.55 +# set VPATH so make knows where to look for source files 1.56 +# Src_Dirs_V is everything in src/share/vm/*, plus the right os/*/vm and cpu/*/vm 1.57 +# The adfiles directory contains ad_<arch>.[ch]pp. 1.58 +# The jvmtifiles directory contains jvmti*.[ch]pp 1.59 +Src_Dirs_V += $(GENERATED)/adfiles $(GENERATED)/jvmtifiles $(GENERATED)/tracefiles 1.60 +VPATH += $(Src_Dirs_V:%=%:) 1.61 + 1.62 +# set INCLUDES for C preprocessor. 1.63 +Src_Dirs_I += $(GENERATED) 1.64 +# The order is important for the precompiled headers to work. 1.65 +INCLUDES += $(PRECOMPILED_HEADER_DIR:%=-I%) $(Src_Dirs_I:%=-I%) 1.66 + 1.67 +# SYMFLAG is used by {jsig,saproc}.make 1.68 +ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) 1.69 + # always build with debug info when we can create .debuginfo files 1.70 + SYMFLAG = -g 1.71 +else 1.72 + ifeq (${VERSION}, debug) 1.73 + SYMFLAG = -g 1.74 + else 1.75 + SYMFLAG = 1.76 + endif 1.77 +endif 1.78 + 1.79 +# HOTSPOT_RELEASE_VERSION and HOTSPOT_BUILD_VERSION are defined 1.80 +# in $(GAMMADIR)/make/defs.make 1.81 +ifeq ($(HOTSPOT_BUILD_VERSION),) 1.82 + BUILD_VERSION = -DHOTSPOT_RELEASE_VERSION="\"$(HOTSPOT_RELEASE_VERSION)\"" 1.83 +else 1.84 + BUILD_VERSION = -DHOTSPOT_RELEASE_VERSION="\"$(HOTSPOT_RELEASE_VERSION)-$(HOTSPOT_BUILD_VERSION)\"" 1.85 +endif 1.86 + 1.87 +# The following variables are defined in the generated flags.make file. 1.88 +BUILD_VERSION = -DHOTSPOT_RELEASE_VERSION="\"$(HS_BUILD_VER)\"" 1.89 +JRE_VERSION = -DJRE_RELEASE_VERSION="\"$(JRE_RELEASE_VER)\"" 1.90 +HS_LIB_ARCH = -DHOTSPOT_LIB_ARCH=\"$(LIBARCH)\" 1.91 +BUILD_TARGET = -DHOTSPOT_BUILD_TARGET="\"$(TARGET)\"" 1.92 +BUILD_USER = -DHOTSPOT_BUILD_USER="\"$(HOTSPOT_BUILD_USER)\"" 1.93 +VM_DISTRO = -DHOTSPOT_VM_DISTRO="\"$(HOTSPOT_VM_DISTRO)\"" 1.94 + 1.95 +CXXFLAGS = \ 1.96 + ${SYSDEFS} \ 1.97 + ${INCLUDES} \ 1.98 + ${BUILD_VERSION} \ 1.99 + ${BUILD_TARGET} \ 1.100 + ${BUILD_USER} \ 1.101 + ${HS_LIB_ARCH} \ 1.102 + ${VM_DISTRO} 1.103 + 1.104 +# This is VERY important! The version define must only be supplied to vm_version.o 1.105 +# If not, ccache will not re-use the cache at all, since the version string might contain 1.106 +# a time and date. 1.107 +CXXFLAGS/vm_version.o += ${JRE_VERSION} 1.108 + 1.109 +CXXFLAGS/BYFILE = $(CXXFLAGS/$@) 1.110 + 1.111 +# File specific flags 1.112 +CXXFLAGS += $(CXXFLAGS/BYFILE) 1.113 + 1.114 +# Large File Support 1.115 +ifneq ($(LP64), 1) 1.116 +CXXFLAGS/ostream.o += -D_FILE_OFFSET_BITS=64 1.117 +endif # ifneq ($(LP64), 1) 1.118 + 1.119 +# CFLAGS_WARN holds compiler options to suppress/enable warnings. 1.120 +CFLAGS += $(CFLAGS_WARN/BYFILE) 1.121 + 1.122 +# Do not use C++ exception handling 1.123 +CFLAGS += $(CFLAGS/NOEX) 1.124 + 1.125 +# Extra flags from gnumake's invocation or environment 1.126 +CFLAGS += $(EXTRA_CFLAGS) 1.127 +LFLAGS += $(EXTRA_CFLAGS) 1.128 + 1.129 +# Don't set excutable bit on stack segment 1.130 +# the same could be done by separate execstack command 1.131 +LFLAGS += -Xlinker -z -Xlinker noexecstack 1.132 + 1.133 +LIBS += -lm -ldl -lpthread 1.134 + 1.135 +# By default, link the *.o into the library, not the executable. 1.136 +LINK_INTO$(LINK_INTO) = LIBJVM 1.137 + 1.138 +JDK_LIBDIR = $(JAVA_HOME)/jre/lib/$(LIBARCH) 1.139 + 1.140 +#---------------------------------------------------------------------- 1.141 +# jvm_db & dtrace 1.142 +include $(MAKEFILES_DIR)/dtrace.make 1.143 + 1.144 +#---------------------------------------------------------------------- 1.145 +# JVM 1.146 + 1.147 +JVM = jvm 1.148 +LIBJVM = lib$(JVM).so 1.149 + 1.150 +LIBJVM_DEBUGINFO = lib$(JVM).debuginfo 1.151 +LIBJVM_DIZ = lib$(JVM).diz 1.152 + 1.153 +SPECIAL_PATHS:=adlc c1 gc_implementation opto shark libadt 1.154 + 1.155 +SOURCE_PATHS=\ 1.156 + $(shell find $(HS_COMMON_SRC)/share/vm/* -type d \! \ 1.157 + \( -name DUMMY $(foreach dir,$(SPECIAL_PATHS),-o -name $(dir)) \)) 1.158 +SOURCE_PATHS+=$(HS_COMMON_SRC)/os/$(Platform_os_family)/vm 1.159 +SOURCE_PATHS+=$(HS_COMMON_SRC)/os/posix/vm 1.160 +SOURCE_PATHS+=$(HS_COMMON_SRC)/cpu/$(Platform_arch)/vm 1.161 +SOURCE_PATHS+=$(HS_COMMON_SRC)/os_cpu/$(Platform_os_arch)/vm 1.162 + 1.163 +CORE_PATHS=$(foreach path,$(SOURCE_PATHS),$(call altsrc,$(path)) $(path)) 1.164 +CORE_PATHS+=$(GENERATED)/jvmtifiles $(GENERATED)/tracefiles 1.165 + 1.166 +ifneq ($(INCLUDE_TRACE), false) 1.167 +CORE_PATHS+=$(shell if [ -d $(HS_ALT_SRC)/share/vm/jfr ]; then \ 1.168 + find $(HS_ALT_SRC)/share/vm/jfr -type d; \ 1.169 + fi) 1.170 +endif 1.171 + 1.172 +COMPILER1_PATHS := $(call altsrc,$(HS_COMMON_SRC)/share/vm/c1) 1.173 +COMPILER1_PATHS += $(HS_COMMON_SRC)/share/vm/c1 1.174 + 1.175 +COMPILER2_PATHS := $(call altsrc,$(HS_COMMON_SRC)/share/vm/opto) 1.176 +COMPILER2_PATHS += $(call altsrc,$(HS_COMMON_SRC)/share/vm/libadt) 1.177 +COMPILER2_PATHS += $(HS_COMMON_SRC)/share/vm/opto 1.178 +COMPILER2_PATHS += $(HS_COMMON_SRC)/share/vm/libadt 1.179 +COMPILER2_PATHS += $(GENERATED)/adfiles 1.180 + 1.181 +SHARK_PATHS := $(GAMMADIR)/src/share/vm/shark 1.182 + 1.183 +# Include dirs per type. 1.184 +Src_Dirs/CORE := $(CORE_PATHS) 1.185 +Src_Dirs/COMPILER1 := $(CORE_PATHS) $(COMPILER1_PATHS) 1.186 +Src_Dirs/COMPILER2 := $(CORE_PATHS) $(COMPILER2_PATHS) 1.187 +Src_Dirs/TIERED := $(CORE_PATHS) $(COMPILER1_PATHS) $(COMPILER2_PATHS) 1.188 +Src_Dirs/ZERO := $(CORE_PATHS) 1.189 +Src_Dirs/SHARK := $(CORE_PATHS) $(SHARK_PATHS) 1.190 +Src_Dirs := $(Src_Dirs/$(TYPE)) 1.191 + 1.192 +COMPILER2_SPECIFIC_FILES := opto libadt bcEscapeAnalyzer.cpp c2_\* runtime_\* 1.193 +COMPILER1_SPECIFIC_FILES := c1_\* 1.194 +SHARK_SPECIFIC_FILES := shark 1.195 +ZERO_SPECIFIC_FILES := zero 1.196 + 1.197 +# Always exclude these. 1.198 +Src_Files_EXCLUDE += jsig.c jvmtiEnvRecommended.cpp jvmtiEnvStub.cpp 1.199 + 1.200 +# Exclude per type. 1.201 +Src_Files_EXCLUDE/CORE := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp 1.202 +Src_Files_EXCLUDE/COMPILER1 := $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp 1.203 +Src_Files_EXCLUDE/COMPILER2 := $(COMPILER1_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) 1.204 +Src_Files_EXCLUDE/TIERED := $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) 1.205 +Src_Files_EXCLUDE/ZERO := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp 1.206 +Src_Files_EXCLUDE/SHARK := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) 1.207 + 1.208 +Src_Files_EXCLUDE += $(Src_Files_EXCLUDE/$(TYPE)) 1.209 + 1.210 +# Special handling of arch model. 1.211 +ifeq ($(Platform_arch_model), x86_32) 1.212 +Src_Files_EXCLUDE += \*x86_64\* 1.213 +endif 1.214 +ifeq ($(Platform_arch_model), x86_64) 1.215 +Src_Files_EXCLUDE += \*x86_32\* 1.216 +endif 1.217 + 1.218 +# Alternate vm.make 1.219 +# This has to be included here to allow changes to the source 1.220 +# directories and excluded files before they are expanded 1.221 +# by the definition of Src_Files. 1.222 +-include $(HS_ALT_MAKE)/$(Platform_os_family)/makefiles/vm.make 1.223 + 1.224 +# Locate all source files in the given directory, excluding files in Src_Files_EXCLUDE. 1.225 +define findsrc 1.226 + $(notdir $(shell find $(1)/. ! -name . -prune \ 1.227 + -a \( -name \*.c -o -name \*.cpp -o -name \*.s \) \ 1.228 + -a ! \( -name DUMMY $(addprefix -o -name ,$(Src_Files_EXCLUDE)) \))) 1.229 +endef 1.230 + 1.231 +Src_Files := $(foreach e,$(Src_Dirs),$(call findsrc,$(e))) 1.232 + 1.233 +Obj_Files = $(sort $(addsuffix .o,$(basename $(Src_Files)))) 1.234 + 1.235 +JVM_OBJ_FILES = $(Obj_Files) 1.236 + 1.237 +vm_version.o: $(filter-out vm_version.o,$(JVM_OBJ_FILES)) 1.238 + 1.239 +mapfile : $(MAPFILE) vm.def 1.240 + rm -f $@ 1.241 + awk '{ if ($$0 ~ "INSERT VTABLE SYMBOLS HERE") \ 1.242 + { system ("cat vm.def"); } \ 1.243 + else \ 1.244 + { print $$0 } \ 1.245 + }' > $@ < $(MAPFILE) 1.246 + 1.247 +mapfile_reorder : mapfile $(REORDERFILE) 1.248 + rm -f $@ 1.249 + cat $^ > $@ 1.250 + 1.251 +vm.def: $(Res_Files) $(Obj_Files) 1.252 + sh $(GAMMADIR)/make/linux/makefiles/build_vm_def.sh *.o > $@ 1.253 + 1.254 +ifeq ($(JVM_VARIANT_ZEROSHARK), true) 1.255 + STATIC_CXX = false 1.256 +else 1.257 + ifeq ($(ZERO_LIBARCH), ppc64) 1.258 + STATIC_CXX = false 1.259 + else 1.260 + STATIC_CXX = true 1.261 + endif 1.262 +endif 1.263 + 1.264 +ifeq ($(LINK_INTO),AOUT) 1.265 + LIBJVM.o = 1.266 + LIBJVM_MAPFILE = 1.267 + LIBS_VM = $(LIBS) 1.268 +else 1.269 + LIBJVM.o = $(JVM_OBJ_FILES) 1.270 + LIBJVM_MAPFILE$(LDNOMAP) = mapfile_reorder 1.271 + LFLAGS_VM$(LDNOMAP) += $(MAPFLAG:FILENAME=$(LIBJVM_MAPFILE)) 1.272 + LFLAGS_VM += $(SONAMEFLAG:SONAME=$(LIBJVM)) 1.273 + 1.274 + # JVM is statically linked with libgcc[_s] and libstdc++; this is needed to 1.275 + # get around library dependency and compatibility issues. Must use gcc not 1.276 + # g++ to link. 1.277 + ifeq ($(STATIC_CXX), true) 1.278 + LFLAGS_VM += $(STATIC_LIBGCC) 1.279 + LIBS_VM += $(STATIC_STDCXX) 1.280 + else 1.281 + LIBS_VM += -lstdc++ 1.282 + endif 1.283 + 1.284 + LIBS_VM += $(LIBS) 1.285 +endif 1.286 +ifeq ($(JVM_VARIANT_ZERO), true) 1.287 + LIBS_VM += $(LIBFFI_LIBS) 1.288 +endif 1.289 +ifeq ($(JVM_VARIANT_ZEROSHARK), true) 1.290 + LIBS_VM += $(LIBFFI_LIBS) $(LLVM_LIBS) 1.291 + LFLAGS_VM += $(LLVM_LDFLAGS) 1.292 +endif 1.293 + 1.294 +LINK_VM = $(LINK_LIB.CC) 1.295 + 1.296 +# rule for building precompiled header 1.297 +$(PRECOMPILED_HEADER): 1.298 + $(QUIETLY) echo Generating precompiled header $@ 1.299 + $(QUIETLY) mkdir -p $(PRECOMPILED_HEADER_DIR) 1.300 + $(QUIETLY) $(COMPILE.CXX) $(DEPFLAGS) -x c++-header $(PRECOMPILED_HEADER_SRC) -o $@ $(COMPILE_DONE) 1.301 + 1.302 +# making the library: 1.303 + 1.304 +ifneq ($(JVM_BASE_ADDR),) 1.305 +# By default shared library is linked at base address == 0. Modify the 1.306 +# linker script if JVM prefers a different base location. It can also be 1.307 +# implemented with 'prelink -r'. But 'prelink' is not (yet) available on 1.308 +# our build platform (AS-2.1). 1.309 +LD_SCRIPT = libjvm.so.lds 1.310 +$(LD_SCRIPT): $(LIBJVM_MAPFILE) 1.311 + $(QUIETLY) { \ 1.312 + rm -rf $@; \ 1.313 + $(LINK_VM) -Wl,--verbose $(LFLAGS_VM) 2>&1 | \ 1.314 + sed -e '/^======/,/^======/!d' \ 1.315 + -e '/^======/d' \ 1.316 + -e 's/0\( + SIZEOF_HEADERS\)/$(JVM_BASE_ADDR)\1/' \ 1.317 + > $@; \ 1.318 + } 1.319 +LD_SCRIPT_FLAG = -Wl,-T,$(LD_SCRIPT) 1.320 +endif 1.321 + 1.322 +# With more recent Redhat releases (or the cutting edge version Fedora), if 1.323 +# SELinux is configured to be enabled, the runtime linker will fail to apply 1.324 +# the text relocation to libjvm.so considering that it is built as a non-PIC 1.325 +# DSO. To workaround that, we run chcon to libjvm.so after it is built. See 1.326 +# details in bug 6538311. 1.327 +$(LIBJVM): $(LIBJVM.o) $(LIBJVM_MAPFILE) $(LD_SCRIPT) 1.328 + $(QUIETLY) { \ 1.329 + echo Linking vm...; \ 1.330 + $(LINK_LIB.CXX/PRE_HOOK) \ 1.331 + $(LINK_VM) $(LD_SCRIPT_FLAG) \ 1.332 + $(LFLAGS_VM) -o $@ $(sort $(LIBJVM.o)) $(LIBS_VM); \ 1.333 + $(LINK_LIB.CXX/POST_HOOK) \ 1.334 + rm -f $@.1; ln -s $@ $@.1; \ 1.335 + if [ \"$(CROSS_COMPILE_ARCH)\" = \"\" ] ; then \ 1.336 + if [ -x /usr/sbin/selinuxenabled ] ; then \ 1.337 + /usr/sbin/selinuxenabled; \ 1.338 + if [ $$? = 0 ] ; then \ 1.339 + /usr/bin/chcon -t textrel_shlib_t $@; \ 1.340 + if [ $$? != 0 ]; then \ 1.341 + echo "ERROR: Cannot chcon $@"; \ 1.342 + fi \ 1.343 + fi \ 1.344 + fi \ 1.345 + fi \ 1.346 + } 1.347 + 1.348 +ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) 1.349 + $(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJVM_DEBUGINFO) 1.350 + $(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DEBUGINFO) $@ 1.351 + ifeq ($(STRIP_POLICY),all_strip) 1.352 + $(QUIETLY) $(STRIP) $@ 1.353 + else 1.354 + ifeq ($(STRIP_POLICY),min_strip) 1.355 + $(QUIETLY) $(STRIP) -g $@ 1.356 + # implied else here is no stripping at all 1.357 + endif 1.358 + endif 1.359 + ifeq ($(ZIP_DEBUGINFO_FILES),1) 1.360 + $(ZIPEXE) -q -y $(LIBJVM_DIZ) $(LIBJVM_DEBUGINFO) 1.361 + $(RM) $(LIBJVM_DEBUGINFO) 1.362 + endif 1.363 +endif 1.364 + 1.365 +DEST_SUBDIR = $(JDK_LIBDIR)/$(VM_SUBDIR) 1.366 +DEST_JVM = $(DEST_SUBDIR)/$(LIBJVM) 1.367 +DEST_JVM_DEBUGINFO = $(DEST_SUBDIR)/$(LIBJVM_DEBUGINFO) 1.368 +DEST_JVM_DIZ = $(DEST_SUBDIR)/$(LIBJVM_DIZ) 1.369 + 1.370 +install_jvm: $(LIBJVM) 1.371 + @echo "Copying $(LIBJVM) to $(DEST_JVM)" 1.372 + $(QUIETLY) test -f $(LIBJVM_DEBUGINFO) && \ 1.373 + cp -f $(LIBJVM_DEBUGINFO) $(DEST_JVM_DEBUGINFO) 1.374 + $(QUIETLY) test -f $(LIBJVM_DIZ) && \ 1.375 + cp -f $(LIBJVM_DIZ) $(DEST_JVM_DIZ) 1.376 + $(QUIETLY) cp -f $(LIBJVM) $(DEST_JVM) && echo "Done" 1.377 + 1.378 +#---------------------------------------------------------------------- 1.379 +# Other files 1.380 + 1.381 +# Signal interposition library 1.382 +include $(MAKEFILES_DIR)/jsig.make 1.383 + 1.384 +# Serviceability agent 1.385 +include $(MAKEFILES_DIR)/saproc.make 1.386 + 1.387 +#---------------------------------------------------------------------- 1.388 + 1.389 +build: $(LIBJVM) $(LAUNCHER) $(LIBJSIG) $(LIBJVM_DB) $(BUILDLIBSAPROC) dtraceCheck 1.390 + 1.391 +install: install_jvm install_jsig install_saproc 1.392 + 1.393 +.PHONY: default build install install_jvm $(HS_ALT_MAKE)/$(Platform_os_family)/makefiles/$(BUILDARCH).make $(HS_ALT_MAKE)/$(Platform_os_family)/makefiles/vm.make