make/linux/makefiles/vm.make

Wed, 11 Aug 2010 05:51:21 -0700

author
twisti
date
Wed, 11 Aug 2010 05:51:21 -0700
changeset 2047
d2ede61b7a12
parent 2036
126ea7725993
child 2314
f95d63e2154a
permissions
-rw-r--r--

6976186: integrate Shark HotSpot changes
Summary: Shark is a JIT compiler for Zero that uses the LLVM compiler infrastructure.
Reviewed-by: kvn, twisti
Contributed-by: Gary Benson <gbenson@redhat.com>

duke@435 1 #
twisti@2047 2 # Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
duke@435 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 #
duke@435 5 # This code is free software; you can redistribute it and/or modify it
duke@435 6 # under the terms of the GNU General Public License version 2 only, as
duke@435 7 # published by the Free Software Foundation.
duke@435 8 #
duke@435 9 # This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 # version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 # accompanied this code).
duke@435 14 #
duke@435 15 # You should have received a copy of the GNU General Public License version
duke@435 16 # 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 #
trims@1907 19 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 # or visit www.oracle.com if you need additional information or have any
trims@1907 21 # questions.
duke@435 22 #
duke@435 23 #
duke@435 24
duke@435 25 # Rules to build JVM and related libraries, included from vm.make in the build
duke@435 26 # directory.
duke@435 27
duke@435 28 # Common build rules.
kamg@526 29 MAKEFILES_DIR=$(GAMMADIR)/make/$(Platform_os_family)/makefiles
duke@435 30 include $(MAKEFILES_DIR)/rules.make
duke@435 31
duke@435 32 default: build
duke@435 33
duke@435 34 #----------------------------------------------------------------------
duke@435 35 # Defs
duke@435 36
duke@435 37 GENERATED = ../generated
duke@435 38
duke@435 39 # read a generated file defining the set of .o's and the .o .h dependencies
duke@435 40 include $(GENERATED)/Dependencies
duke@435 41
duke@435 42 # read machine-specific adjustments (%%% should do this via buildtree.make?)
never@1445 43 ifeq ($(ZERO_BUILD), true)
never@1445 44 include $(MAKEFILES_DIR)/zeroshark.make
never@1445 45 else
never@1445 46 include $(MAKEFILES_DIR)/$(BUILDARCH).make
never@1445 47 endif
duke@435 48
duke@435 49 # set VPATH so make knows where to look for source files
duke@435 50 # Src_Dirs is everything in src/share/vm/*, plus the right os/*/vm and cpu/*/vm
duke@435 51 # The incls directory contains generated header file lists for inclusion.
duke@435 52 # The adfiles directory contains ad_<arch>.[ch]pp.
duke@435 53 # The jvmtifiles directory contains jvmti*.[ch]pp
duke@435 54 Src_Dirs_V = $(GENERATED)/adfiles $(GENERATED)/jvmtifiles ${Src_Dirs} $(GENERATED)/incls
duke@435 55 VPATH += $(Src_Dirs_V:%=%:)
duke@435 56
duke@435 57 # set INCLUDES for C preprocessor
duke@435 58 Src_Dirs_I = $(PRECOMPILED_HEADER_DIR) $(GENERATED)/adfiles $(GENERATED)/jvmtifiles ${Src_Dirs} $(GENERATED)
duke@435 59 INCLUDES += $(Src_Dirs_I:%=-I%)
duke@435 60
duke@435 61 ifeq (${VERSION}, debug)
duke@435 62 SYMFLAG = -g
duke@435 63 else
duke@435 64 SYMFLAG =
duke@435 65 endif
duke@435 66
duke@435 67 # HOTSPOT_RELEASE_VERSION and HOTSPOT_BUILD_VERSION are defined
duke@435 68 # in $(GAMMADIR)/make/defs.make
duke@435 69 ifeq ($(HOTSPOT_BUILD_VERSION),)
duke@435 70 BUILD_VERSION = -DHOTSPOT_RELEASE_VERSION="\"$(HOTSPOT_RELEASE_VERSION)\""
duke@435 71 else
duke@435 72 BUILD_VERSION = -DHOTSPOT_RELEASE_VERSION="\"$(HOTSPOT_RELEASE_VERSION)-$(HOTSPOT_BUILD_VERSION)\""
duke@435 73 endif
duke@435 74
duke@435 75 # The following variables are defined in the generated flags.make file.
duke@435 76 BUILD_VERSION = -DHOTSPOT_RELEASE_VERSION="\"$(HS_BUILD_VER)\""
duke@435 77 JRE_VERSION = -DJRE_RELEASE_VERSION="\"$(JRE_RELEASE_VER)\""
jrose@535 78 HS_LIB_ARCH = -DHOTSPOT_LIB_ARCH=\"$(LIBARCH)\"
duke@435 79 BUILD_TARGET = -DHOTSPOT_BUILD_TARGET="\"$(TARGET)\""
duke@435 80 BUILD_USER = -DHOTSPOT_BUILD_USER="\"$(HOTSPOT_BUILD_USER)\""
duke@435 81 VM_DISTRO = -DHOTSPOT_VM_DISTRO="\"$(HOTSPOT_VM_DISTRO)\""
duke@435 82
duke@435 83 CPPFLAGS = \
duke@435 84 ${SYSDEFS} \
duke@435 85 ${INCLUDES} \
duke@435 86 ${BUILD_VERSION} \
duke@435 87 ${BUILD_TARGET} \
duke@435 88 ${BUILD_USER} \
jrose@535 89 ${HS_LIB_ARCH} \
duke@435 90 ${JRE_VERSION} \
duke@435 91 ${VM_DISTRO}
duke@435 92
duke@435 93 # CFLAGS_WARN holds compiler options to suppress/enable warnings.
duke@435 94 CFLAGS += $(CFLAGS_WARN/BYFILE)
duke@435 95
duke@435 96 # Do not use C++ exception handling
duke@435 97 CFLAGS += $(CFLAGS/NOEX)
duke@435 98
duke@435 99 # Extra flags from gnumake's invocation or environment
duke@435 100 CFLAGS += $(EXTRA_CFLAGS)
bobv@2036 101 LFLAGS += $(EXTRA_CFLAGS)
duke@435 102
duke@435 103 LIBS += -lm -ldl -lpthread
duke@435 104
duke@435 105 # By default, link the *.o into the library, not the executable.
duke@435 106 LINK_INTO$(LINK_INTO) = LIBJVM
duke@435 107
duke@435 108 JDK_LIBDIR = $(JAVA_HOME)/jre/lib/$(LIBARCH)
duke@435 109
duke@435 110 #----------------------------------------------------------------------
duke@435 111 # jvm_db & dtrace
duke@435 112 include $(MAKEFILES_DIR)/dtrace.make
duke@435 113
duke@435 114 #----------------------------------------------------------------------
duke@435 115 # JVM
duke@435 116
phh@1558 117 JVM = jvm
phh@1558 118 LIBJVM = lib$(JVM).so
phh@1558 119 LIBJVM_G = lib$(JVM)$(G_SUFFIX).so
duke@435 120
duke@435 121 JVM_OBJ_FILES = $(Obj_Files)
duke@435 122
duke@435 123 vm_version.o: $(filter-out vm_version.o,$(JVM_OBJ_FILES))
duke@435 124
never@1729 125 mapfile : $(MAPFILE) vm.def
duke@435 126 rm -f $@
never@1729 127 awk '{ if ($$0 ~ "INSERT VTABLE SYMBOLS HERE") \
never@1729 128 { system ("cat vm.def"); } \
never@1729 129 else \
never@1729 130 { print $$0 } \
never@1729 131 }' > $@ < $(MAPFILE)
duke@435 132
duke@435 133 mapfile_reorder : mapfile $(REORDERFILE)
duke@435 134 rm -f $@
duke@435 135 cat $^ > $@
duke@435 136
never@1729 137 vm.def: $(Res_Files) $(Obj_Files)
never@1729 138 sh $(GAMMADIR)/make/linux/makefiles/build_vm_def.sh *.o > $@
never@1729 139
twisti@2047 140 ifeq ($(SHARK_BUILD), true)
never@1445 141 STATIC_CXX = false
never@1445 142 else
twisti@2047 143 ifeq ($(ZERO_LIBARCH), ppc64)
twisti@2047 144 STATIC_CXX = false
twisti@2047 145 else
twisti@2047 146 STATIC_CXX = true
twisti@2047 147 endif
never@1445 148 endif
duke@435 149
duke@435 150 ifeq ($(LINK_INTO),AOUT)
duke@435 151 LIBJVM.o =
duke@435 152 LIBJVM_MAPFILE =
duke@435 153 LIBS_VM = $(LIBS)
duke@435 154 else
duke@435 155 LIBJVM.o = $(JVM_OBJ_FILES)
duke@435 156 LIBJVM_MAPFILE$(LDNOMAP) = mapfile_reorder
duke@435 157 LFLAGS_VM$(LDNOMAP) += $(MAPFLAG:FILENAME=$(LIBJVM_MAPFILE))
duke@435 158 LFLAGS_VM += $(SONAMEFLAG:SONAME=$(LIBJVM))
duke@435 159
duke@435 160 # JVM is statically linked with libgcc[_s] and libstdc++; this is needed to
duke@435 161 # get around library dependency and compatibility issues. Must use gcc not
duke@435 162 # g++ to link.
duke@435 163 ifeq ($(STATIC_CXX), true)
duke@435 164 LFLAGS_VM += $(STATIC_LIBGCC)
duke@435 165 LIBS_VM += $(STATIC_STDCXX)
duke@435 166 else
duke@435 167 LIBS_VM += -lstdc++
duke@435 168 endif
duke@435 169
duke@435 170 LIBS_VM += $(LIBS)
duke@435 171 endif
never@1445 172 ifeq ($(ZERO_BUILD), true)
never@1445 173 LIBS_VM += $(LIBFFI_LIBS)
never@1445 174 endif
twisti@2047 175 ifeq ($(SHARK_BUILD), true)
twisti@2047 176 LFLAGS_VM += $(LLVM_LDFLAGS)
twisti@2047 177 LIBS_VM += $(LLVM_LIBS)
twisti@2047 178 endif
duke@435 179
duke@435 180 LINK_VM = $(LINK_LIB.c)
duke@435 181
duke@435 182 # rule for building precompiled header
duke@435 183 $(PRECOMPILED_HEADER): $(Precompiled_Files)
duke@435 184 $(QUIETLY) echo Generating precompiled header $@
duke@435 185 $(QUIETLY) mkdir -p $(PRECOMPILED_HEADER_DIR)/incls
duke@435 186 $(QUIETLY) $(COMPILE.CC) -x c++-header -c $(GENERATED)/incls/_precompiled.incl -o $@ $(COMPILE_DONE)
duke@435 187
duke@435 188 # making the library:
duke@435 189
duke@435 190 ifneq ($(JVM_BASE_ADDR),)
duke@435 191 # By default shared library is linked at base address == 0. Modify the
duke@435 192 # linker script if JVM prefers a different base location. It can also be
duke@435 193 # implemented with 'prelink -r'. But 'prelink' is not (yet) available on
duke@435 194 # our build platform (AS-2.1).
duke@435 195 LD_SCRIPT = libjvm.so.lds
duke@435 196 $(LD_SCRIPT): $(LIBJVM_MAPFILE)
duke@435 197 $(QUIETLY) { \
duke@435 198 rm -rf $@; \
duke@435 199 $(LINK_VM) -Wl,--verbose $(LFLAGS_VM) 2>&1 | \
duke@435 200 sed -e '/^======/,/^======/!d' \
duke@435 201 -e '/^======/d' \
duke@435 202 -e 's/0\( + SIZEOF_HEADERS\)/$(JVM_BASE_ADDR)\1/' \
duke@435 203 > $@; \
duke@435 204 }
duke@435 205 LD_SCRIPT_FLAG = -Wl,-T,$(LD_SCRIPT)
duke@435 206 endif
duke@435 207
duke@435 208 # With more recent Redhat releases (or the cutting edge version Fedora), if
duke@435 209 # SELinux is configured to be enabled, the runtime linker will fail to apply
duke@435 210 # the text relocation to libjvm.so considering that it is built as a non-PIC
duke@435 211 # DSO. To workaround that, we run chcon to libjvm.so after it is built. See
duke@435 212 # details in bug 6538311.
duke@435 213 $(LIBJVM): $(LIBJVM.o) $(LIBJVM_MAPFILE) $(LD_SCRIPT)
duke@435 214 $(QUIETLY) { \
duke@435 215 echo Linking vm...; \
duke@435 216 $(LINK_LIB.CC/PRE_HOOK) \
duke@435 217 $(LINK_VM) $(LD_SCRIPT_FLAG) \
duke@435 218 $(LFLAGS_VM) -o $@ $(LIBJVM.o) $(LIBS_VM); \
duke@435 219 $(LINK_LIB.CC/POST_HOOK) \
duke@435 220 rm -f $@.1; ln -s $@ $@.1; \
phh@1558 221 [ -f $(LIBJVM_G) ] || { ln -s $@ $(LIBJVM_G); ln -s $@.1 $(LIBJVM_G).1; }; \
bobv@2036 222 if [ \"$(CROSS_COMPILE_ARCH)\" = \"\" ] ; then \
bobv@2036 223 if [ -x /usr/sbin/selinuxenabled ] ; then \
bobv@2036 224 /usr/sbin/selinuxenabled; \
bobv@2036 225 if [ $$? = 0 ] ; then \
bobv@2036 226 /usr/bin/chcon -t textrel_shlib_t $@; \
bobv@2036 227 if [ $$? != 0 ]; then \
bobv@2036 228 echo "ERROR: Cannot chcon $@"; \
bobv@2036 229 fi \
bobv@2036 230 fi \
bobv@2036 231 fi \
bobv@2036 232 fi \
duke@435 233 }
duke@435 234
duke@435 235 DEST_JVM = $(JDK_LIBDIR)/$(VM_SUBDIR)/$(LIBJVM)
duke@435 236
duke@435 237 install_jvm: $(LIBJVM)
duke@435 238 @echo "Copying $(LIBJVM) to $(DEST_JVM)"
duke@435 239 $(QUIETLY) cp -f $(LIBJVM) $(DEST_JVM) && echo "Done"
duke@435 240
duke@435 241 #----------------------------------------------------------------------
duke@435 242 # Other files
duke@435 243
duke@435 244 # Gamma launcher
duke@435 245 include $(MAKEFILES_DIR)/launcher.make
duke@435 246
duke@435 247 # Signal interposition library
duke@435 248 include $(MAKEFILES_DIR)/jsig.make
duke@435 249
duke@435 250 # Serviceability agent
duke@435 251 include $(MAKEFILES_DIR)/saproc.make
duke@435 252
duke@435 253 #----------------------------------------------------------------------
duke@435 254
duke@435 255 build: $(LIBJVM) $(LAUNCHER) $(LIBJSIG) $(LIBJVM_DB) checkAndBuildSA
duke@435 256
duke@435 257 install: install_jvm install_jsig install_saproc
duke@435 258
duke@435 259 .PHONY: default build install install_jvm

mercurial