make/linux/makefiles/vm.make

Tue, 08 Aug 2017 15:57:29 +0800

author
aoqi
date
Tue, 08 Aug 2017 15:57:29 +0800
changeset 6876
710a3c8b516e
parent 5442
01aa164323fa
parent 1
2d8a650513c2
child 7535
7ae4e26cb1e0
permissions
-rw-r--r--

merge

     1 #
     2 # Copyright (c) 1999, 2013, 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.
     8 #
     9 # This code is distributed in the hope that it will be useful, but WITHOUT
    10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12 # version 2 for more details (a copy is included in the LICENSE file that
    13 # accompanied this code).
    14 #
    15 # You should have received a copy of the GNU General Public License version
    16 # 2 along with this work; if not, write to the Free Software Foundation,
    17 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18 #
    19 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20 # or visit www.oracle.com if you need additional information or have any
    21 # questions.
    22 #
    23 #
    25 #
    26 # This file has been modified by Loongson Technology in 2015. These
    27 # modifications are Copyright (c) 2015 Loongson Technology, and are made
    28 # available on the same license terms set forth above.
    29 #
    31 # Rules to build JVM and related libraries, included from vm.make in the build
    32 # directory.
    34 # Common build rules.
    35 MAKEFILES_DIR=$(GAMMADIR)/make/$(Platform_os_family)/makefiles
    36 include $(MAKEFILES_DIR)/rules.make
    37 include $(GAMMADIR)/make/altsrc.make
    39 default: build
    41 #----------------------------------------------------------------------
    42 # Defs
    44 GENERATED     = ../generated
    45 DEP_DIR       = $(GENERATED)/dependencies
    47 # reads the generated files defining the set of .o's and the .o .h dependencies
    48 -include $(DEP_DIR)/*.d
    50 # read machine-specific adjustments (%%% should do this via buildtree.make?)
    51 ifeq ($(findstring true, $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true)
    52   include $(MAKEFILES_DIR)/zeroshark.make
    53 else
    54   include $(MAKEFILES_DIR)/$(BUILDARCH).make
    55   -include $(HS_ALT_MAKE)/$(Platform_os_family)/makefiles/$(BUILDARCH).make
    56 endif
    58 # set VPATH so make knows where to look for source files
    59 # Src_Dirs_V is everything in src/share/vm/*, plus the right os/*/vm and cpu/*/vm
    60 # The adfiles directory contains ad_<arch>.[ch]pp.
    61 # The jvmtifiles directory contains jvmti*.[ch]pp
    62 Src_Dirs_V += $(GENERATED)/adfiles $(GENERATED)/jvmtifiles $(GENERATED)/tracefiles
    63 VPATH += $(Src_Dirs_V:%=%:)
    65 # set INCLUDES for C preprocessor.
    66 Src_Dirs_I += $(GENERATED)
    67 # The order is important for the precompiled headers to work.
    68 INCLUDES += $(PRECOMPILED_HEADER_DIR:%=-I%) $(Src_Dirs_I:%=-I%)
    70 # SYMFLAG is used by {jsig,saproc}.make
    71 ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
    72   # always build with debug info when we can create .debuginfo files
    73   SYMFLAG = -g
    74 else
    75   ifeq (${VERSION}, debug)
    76     SYMFLAG = -g
    77   else
    78     SYMFLAG =
    79   endif
    80 endif
    82 # HOTSPOT_RELEASE_VERSION and HOTSPOT_BUILD_VERSION are defined
    83 # in $(GAMMADIR)/make/defs.make
    84 ifeq ($(HOTSPOT_BUILD_VERSION),)
    85   BUILD_VERSION = -DHOTSPOT_RELEASE_VERSION="\"$(HOTSPOT_RELEASE_VERSION)\""
    86 else
    87   BUILD_VERSION = -DHOTSPOT_RELEASE_VERSION="\"$(HOTSPOT_RELEASE_VERSION)-$(HOTSPOT_BUILD_VERSION)\""
    88 endif
    90 # The following variables are defined in the generated flags.make file.
    91 BUILD_VERSION = -DHOTSPOT_RELEASE_VERSION="\"$(HS_BUILD_VER)\""
    92 JRE_VERSION   = -DJRE_RELEASE_VERSION="\"$(JRE_RELEASE_VER)\""
    93 HS_LIB_ARCH   = -DHOTSPOT_LIB_ARCH=\"$(LIBARCH)\"
    94 BUILD_TARGET  = -DHOTSPOT_BUILD_TARGET="\"$(TARGET)\""
    95 BUILD_USER    = -DHOTSPOT_BUILD_USER="\"$(HOTSPOT_BUILD_USER)\""
    96 VM_DISTRO     = -DHOTSPOT_VM_DISTRO="\"$(HOTSPOT_VM_DISTRO)\""
    98 CXXFLAGS =           \
    99   ${SYSDEFS}         \
   100   ${INCLUDES}        \
   101   ${BUILD_VERSION}   \
   102   ${BUILD_TARGET}    \
   103   ${BUILD_USER}      \
   104   ${HS_LIB_ARCH}     \
   105   ${VM_DISTRO}
   107 ifeq ($(MIPS_ABI),n32)
   108   CXXFLAGS +=   -DN32 
   109 else
   110   ifeq ($(MIPS_ABI),n64)
   111     CXXFLAGS +=   -DN64
   112   endif
   113 endif
   114 # This is VERY important! The version define must only be supplied to vm_version.o
   115 # If not, ccache will not re-use the cache at all, since the version string might contain
   116 # a time and date.
   117 CXXFLAGS/vm_version.o += ${JRE_VERSION}
   119 CXXFLAGS/BYFILE = $(CXXFLAGS/$@)
   121 # File specific flags
   122 CXXFLAGS += $(CXXFLAGS/BYFILE)
   124 # Large File Support
   125 ifneq ($(LP64), 1)
   126 CXXFLAGS/ostream.o += -D_FILE_OFFSET_BITS=64
   127 endif # ifneq ($(LP64), 1)
   129 # CFLAGS_WARN holds compiler options to suppress/enable warnings.
   130 CFLAGS += $(CFLAGS_WARN/BYFILE)
   132 # Do not use C++ exception handling
   133 CFLAGS += $(CFLAGS/NOEX)
   135 # Extra flags from gnumake's invocation or environment
   136 CFLAGS += $(EXTRA_CFLAGS)
   137 LFLAGS += $(EXTRA_CFLAGS)
   139 # Don't set excutable bit on stack segment
   140 # the same could be done by separate execstack command
   141 LFLAGS += -Xlinker -z -Xlinker noexecstack
   143 LIBS += -lm -ldl -lpthread
   145 # By default, link the *.o into the library, not the executable.
   146 LINK_INTO$(LINK_INTO) = LIBJVM
   148 JDK_LIBDIR = $(JAVA_HOME)/jre/lib/$(LIBARCH)
   150 #----------------------------------------------------------------------
   151 # jvm_db & dtrace
   152 include $(MAKEFILES_DIR)/dtrace.make
   154 #----------------------------------------------------------------------
   155 # JVM
   157 JVM      = jvm
   158 LIBJVM   = lib$(JVM).so
   160 LIBJVM_DEBUGINFO   = lib$(JVM).debuginfo
   161 LIBJVM_DIZ         = lib$(JVM).diz
   163 SPECIAL_PATHS:=adlc c1 gc_implementation opto shark libadt
   165 SOURCE_PATHS=\
   166   $(shell find $(HS_COMMON_SRC)/share/vm/* -type d \! \
   167       \( -name DUMMY $(foreach dir,$(SPECIAL_PATHS),-o -name $(dir)) \))
   168 SOURCE_PATHS+=$(HS_COMMON_SRC)/os/$(Platform_os_family)/vm
   169 SOURCE_PATHS+=$(HS_COMMON_SRC)/os/posix/vm
   170 SOURCE_PATHS+=$(HS_COMMON_SRC)/cpu/$(Platform_arch)/vm
   171 SOURCE_PATHS+=$(HS_COMMON_SRC)/os_cpu/$(Platform_os_arch)/vm
   173 CORE_PATHS=$(foreach path,$(SOURCE_PATHS),$(call altsrc,$(path)) $(path))
   174 CORE_PATHS+=$(GENERATED)/jvmtifiles $(GENERATED)/tracefiles
   176 ifneq ($(INCLUDE_TRACE), false)
   177 CORE_PATHS+=$(shell if [ -d $(HS_ALT_SRC)/share/vm/jfr ]; then \
   178   find $(HS_ALT_SRC)/share/vm/jfr -type d; \
   179   fi)
   180 endif
   182 COMPILER1_PATHS := $(call altsrc,$(HS_COMMON_SRC)/share/vm/c1)
   183 COMPILER1_PATHS += $(HS_COMMON_SRC)/share/vm/c1
   185 COMPILER2_PATHS := $(call altsrc,$(HS_COMMON_SRC)/share/vm/opto)
   186 COMPILER2_PATHS += $(call altsrc,$(HS_COMMON_SRC)/share/vm/libadt)
   187 COMPILER2_PATHS += $(HS_COMMON_SRC)/share/vm/opto
   188 COMPILER2_PATHS += $(HS_COMMON_SRC)/share/vm/libadt
   189 COMPILER2_PATHS += $(GENERATED)/adfiles
   191 SHARK_PATHS := $(GAMMADIR)/src/share/vm/shark
   193 # Include dirs per type.
   194 Src_Dirs/CORE      := $(CORE_PATHS)
   195 Src_Dirs/COMPILER1 := $(CORE_PATHS) $(COMPILER1_PATHS)
   196 Src_Dirs/COMPILER2 := $(CORE_PATHS) $(COMPILER2_PATHS)
   197 Src_Dirs/TIERED    := $(CORE_PATHS) $(COMPILER1_PATHS) $(COMPILER2_PATHS)
   198 Src_Dirs/ZERO      := $(CORE_PATHS)
   199 Src_Dirs/SHARK     := $(CORE_PATHS) $(SHARK_PATHS)
   200 Src_Dirs := $(Src_Dirs/$(TYPE))
   202 COMPILER2_SPECIFIC_FILES := opto libadt bcEscapeAnalyzer.cpp c2_\* runtime_\*
   203 COMPILER1_SPECIFIC_FILES := c1_\*
   204 SHARK_SPECIFIC_FILES     := shark
   205 ZERO_SPECIFIC_FILES      := zero
   207 # Always exclude these.
   208 Src_Files_EXCLUDE += jsig.c jvmtiEnvRecommended.cpp jvmtiEnvStub.cpp
   210 # Exclude per type.
   211 Src_Files_EXCLUDE/CORE      := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp
   212 Src_Files_EXCLUDE/COMPILER1 := $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp
   213 Src_Files_EXCLUDE/COMPILER2 := $(COMPILER1_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES)
   214 Src_Files_EXCLUDE/TIERED    := $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES)
   215 Src_Files_EXCLUDE/ZERO      := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp
   216 Src_Files_EXCLUDE/SHARK     := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES)
   218 Src_Files_EXCLUDE +=  $(Src_Files_EXCLUDE/$(TYPE))
   220 # Special handling of arch model.
   221 ifeq ($(Platform_arch_model), x86_32)
   222 Src_Files_EXCLUDE += \*x86_64\*
   223 endif
   224 ifeq ($(Platform_arch_model), x86_64)
   225 Src_Files_EXCLUDE += \*x86_32\*
   226 endif
   227 ifeq ($(Platform_arch_model), mips_32)
   228 Src_Files_EXCLUDE += \*mips_64\*
   229 endif
   230 ifeq ($(Platform_arch_model), mips_64)
   231 Src_Files_EXCLUDE += \*mips_32\*
   232 endif
   234 # Alternate vm.make
   235 # This has to be included here to allow changes to the source
   236 # directories and excluded files before they are expanded
   237 # by the definition of Src_Files.
   238 -include $(HS_ALT_MAKE)/$(Platform_os_family)/makefiles/vm.make
   240 # Locate all source files in the given directory, excluding files in Src_Files_EXCLUDE.
   241 define findsrc
   242 	$(notdir $(shell find $(1)/. ! -name . -prune \
   243 		-a \( -name \*.c -o -name \*.cpp -o -name \*.s \) \
   244 		-a ! \( -name DUMMY $(addprefix -o -name ,$(Src_Files_EXCLUDE)) \)))
   245 endef
   247 Src_Files := $(foreach e,$(Src_Dirs),$(call findsrc,$(e)))
   249 Obj_Files = $(sort $(addsuffix .o,$(basename $(Src_Files))))
   251 JVM_OBJ_FILES = $(Obj_Files)
   253 vm_version.o: $(filter-out vm_version.o,$(JVM_OBJ_FILES))
   255 mapfile : $(MAPFILE) vm.def
   256 	rm -f $@
   257 	awk '{ if ($$0 ~ "INSERT VTABLE SYMBOLS HERE")	\
   258                  { system ("cat vm.def"); }		\
   259                else					\
   260                  { print $$0 }				\
   261              }' > $@ < $(MAPFILE)
   263 mapfile_reorder : mapfile $(REORDERFILE)
   264 	rm -f $@
   265 	cat $^ > $@
   267 vm.def: $(Res_Files) $(Obj_Files)
   268 	sh $(GAMMADIR)/make/linux/makefiles/build_vm_def.sh *.o > $@
   270 ifeq ($(JVM_VARIANT_ZEROSHARK), true)
   271   STATIC_CXX = false
   272 else
   273   ifeq ($(ZERO_LIBARCH), ppc64)
   274     STATIC_CXX = false
   275   else
   276     STATIC_CXX = true
   277   endif
   278 endif
   280 ifeq ($(LINK_INTO),AOUT)
   281   LIBJVM.o                 =
   282   LIBJVM_MAPFILE           =
   283   LIBS_VM                  = $(LIBS)
   284 else
   285   LIBJVM.o                 = $(JVM_OBJ_FILES)
   286   LIBJVM_MAPFILE$(LDNOMAP) = mapfile_reorder
   287   LFLAGS_VM$(LDNOMAP)      += $(MAPFLAG:FILENAME=$(LIBJVM_MAPFILE))
   288   LFLAGS_VM                += $(SONAMEFLAG:SONAME=$(LIBJVM))
   290   # JVM is statically linked with libgcc[_s] and libstdc++; this is needed to
   291   # get around library dependency and compatibility issues. Must use gcc not
   292   # g++ to link.
   293   ifeq ($(STATIC_CXX), true)
   294     LFLAGS_VM              += $(STATIC_LIBGCC)
   295     LIBS_VM                += $(STATIC_STDCXX)
   296   else
   297     LIBS_VM                += -lstdc++
   298   endif
   300   LIBS_VM                  += $(LIBS)
   301 endif
   302 ifeq ($(JVM_VARIANT_ZERO), true)
   303   LIBS_VM += $(LIBFFI_LIBS)
   304 endif
   305 ifeq ($(JVM_VARIANT_ZEROSHARK), true)
   306   LIBS_VM   += $(LIBFFI_LIBS) $(LLVM_LIBS)
   307   LFLAGS_VM += $(LLVM_LDFLAGS)
   308 endif
   310 LINK_VM = $(LINK_LIB.CC)
   312 # rule for building precompiled header
   313 $(PRECOMPILED_HEADER):
   314 	$(QUIETLY) echo Generating precompiled header $@
   315 	$(QUIETLY) mkdir -p $(PRECOMPILED_HEADER_DIR)
   316 	$(QUIETLY) $(COMPILE.CXX) $(DEPFLAGS) -x c++-header $(PRECOMPILED_HEADER_SRC) -o $@ $(COMPILE_DONE)
   318 # making the library:
   320 ifneq ($(JVM_BASE_ADDR),)
   321 # By default shared library is linked at base address == 0. Modify the
   322 # linker script if JVM prefers a different base location. It can also be
   323 # implemented with 'prelink -r'. But 'prelink' is not (yet) available on
   324 # our build platform (AS-2.1).
   325 LD_SCRIPT = libjvm.so.lds
   326 $(LD_SCRIPT): $(LIBJVM_MAPFILE)
   327 	$(QUIETLY) {                                                \
   328 	  rm -rf $@;                                                \
   329 	  $(LINK_VM) -Wl,--verbose $(LFLAGS_VM) 2>&1             |  \
   330 	    sed -e '/^======/,/^======/!d'                          \
   331 		-e '/^======/d'                                     \
   332 		-e 's/0\( + SIZEOF_HEADERS\)/$(JVM_BASE_ADDR)\1/'   \
   333 		> $@;                                               \
   334 	}
   335 LD_SCRIPT_FLAG = -Wl,-T,$(LD_SCRIPT)
   336 endif
   338 # With more recent Redhat releases (or the cutting edge version Fedora), if
   339 # SELinux is configured to be enabled, the runtime linker will fail to apply
   340 # the text relocation to libjvm.so considering that it is built as a non-PIC
   341 # DSO. To workaround that, we run chcon to libjvm.so after it is built. See
   342 # details in bug 6538311.
   343 $(LIBJVM): $(LIBJVM.o) $(LIBJVM_MAPFILE) $(LD_SCRIPT)
   344 	$(QUIETLY) {                                                    \
   345 	    echo Linking vm...;                                         \
   346 	    $(LINK_LIB.CXX/PRE_HOOK)                                     \
   347 	    $(LINK_VM) $(LD_SCRIPT_FLAG)                                \
   348 		       $(LFLAGS_VM) -o $@ $(sort $(LIBJVM.o)) $(LIBS_VM);       \
   349 	    $(LINK_LIB.CXX/POST_HOOK)                                    \
   350 	    rm -f $@.1; ln -s $@ $@.1;                                  \
   351             if [ \"$(CROSS_COMPILE_ARCH)\" = \"\" ] ; then                    \
   352 	      if [ -x /usr/sbin/selinuxenabled ] ; then                 \
   353 	        /usr/sbin/selinuxenabled;                               \
   354                 if [ $$? = 0 ] ; then					\
   355 		  /usr/bin/chcon -t textrel_shlib_t $@;                 \
   356 		  if [ $$? != 0 ]; then                                 \
   357 		    echo "ERROR: Cannot chcon $@";			\
   358 		  fi							\
   359 	        fi							\
   360 	      fi                                                        \
   361             fi 								\
   362 	}
   364 ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
   365 	$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJVM_DEBUGINFO)
   366 	$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DEBUGINFO) $@
   367   ifeq ($(STRIP_POLICY),all_strip)
   368 	$(QUIETLY) $(STRIP) $@
   369   else
   370     ifeq ($(STRIP_POLICY),min_strip)
   371 	$(QUIETLY) $(STRIP) -g $@
   372     # implied else here is no stripping at all
   373     endif
   374   endif
   375   ifeq ($(ZIP_DEBUGINFO_FILES),1)
   376 	$(ZIPEXE) -q -y $(LIBJVM_DIZ) $(LIBJVM_DEBUGINFO)
   377 	$(RM) $(LIBJVM_DEBUGINFO)
   378   endif
   379 endif
   381 DEST_SUBDIR        = $(JDK_LIBDIR)/$(VM_SUBDIR)
   382 DEST_JVM           = $(DEST_SUBDIR)/$(LIBJVM)
   383 DEST_JVM_DEBUGINFO = $(DEST_SUBDIR)/$(LIBJVM_DEBUGINFO)
   384 DEST_JVM_DIZ       = $(DEST_SUBDIR)/$(LIBJVM_DIZ)
   386 install_jvm: $(LIBJVM)
   387 	@echo "Copying $(LIBJVM) to $(DEST_JVM)"
   388 	$(QUIETLY) test -f $(LIBJVM_DEBUGINFO) && \
   389 	    cp -f $(LIBJVM_DEBUGINFO) $(DEST_JVM_DEBUGINFO)
   390 	$(QUIETLY) test -f $(LIBJVM_DIZ) && \
   391 	    cp -f $(LIBJVM_DIZ) $(DEST_JVM_DIZ)
   392 	$(QUIETLY) cp -f $(LIBJVM) $(DEST_JVM) && echo "Done"
   394 #----------------------------------------------------------------------
   395 # Other files
   397 # Signal interposition library
   398 include $(MAKEFILES_DIR)/jsig.make
   400 # Serviceability agent
   401 include $(MAKEFILES_DIR)/saproc.make
   403 #----------------------------------------------------------------------
   405 build: $(LIBJVM) $(LAUNCHER) $(LIBJSIG) $(LIBJVM_DB) $(BUILDLIBSAPROC) dtraceCheck
   407 install: install_jvm install_jsig install_saproc
   409 .PHONY: default build install install_jvm $(HS_ALT_MAKE)/$(Platform_os_family)/makefiles/$(BUILDARCH).make $(HS_ALT_MAKE)/$(Platform_os_family)/makefiles/vm.make

mercurial