make/solaris/makefiles/dtrace.make

Thu, 13 Nov 2008 14:50:04 -0800

author
kvn
date
Thu, 13 Nov 2008 14:50:04 -0800
changeset 868
c1345e85f901
parent 631
d1605aabd0a1
child 878
b5e603f2e024
permissions
-rw-r--r--

6767659: Conversion from i486 to x86 missed some entries in makefiles
Summary: Fixed missed entries.
Reviewed-by: never

     1 #
     2 # Copyright 2005-2008 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    20 # CA 95054 USA or visit www.sun.com if you need additional information or
    21 # have any questions.
    22 #  
    23 #
    25 # Rules to build jvm_db/dtrace, used by vm.make
    27 # we build libjvm_dtrace/libjvm_db/dtrace for COMPILER1 and COMPILER2
    28 # but not for CORE configuration
    30 ifneq ("${TYPE}", "CORE")
    31 ifneq ("${TYPE}", "KERNEL")
    33 ifdef USE_GCC
    35 dtraceCheck:
    36 	$(QUIETLY) echo "**NOTICE** Dtrace support disabled for gcc builds"
    38 else
    41 JVM_DB = libjvm_db
    42 LIBJVM_DB = libjvm$(G_SUFFIX)_db.so
    44 JVM_DTRACE = jvm_dtrace
    45 LIBJVM_DTRACE = libjvm$(G_SUFFIX)_dtrace.so
    47 JVMOFFS = JvmOffsets
    48 JVMOFFS.o = $(JVMOFFS).o
    49 GENOFFS = generate$(JVMOFFS)
    51 DTRACE_SRCDIR = $(GAMMADIR)/src/os/$(Platform_os_family)/dtrace
    52 DTRACE = dtrace
    53 DTRACE.o = $(DTRACE).o
    55 # to remove '-g' option which causes link problems
    56 # also '-z nodefs' is used as workaround
    57 GENOFFS_CFLAGS = $(shell echo $(CFLAGS) | sed -e 's/ -g / /g' -e 's/ -g0 / /g';)
    59 ifdef LP64
    60 DTRACE_OPTS = -64 -D_LP64
    61 endif
    63 # making libjvm_db
    65 INCLS = $(GENERATED)/incls
    67 # Use mapfile with libjvm_db.so
    68 LIBJVM_DB_MAPFILE = $(MAKEFILES_DIR)/mapfile-vers-jvm_db
    69 LFLAGS_JVM_DB += $(MAPFLAG:FILENAME=$(LIBJVM_DB_MAPFILE))
    71 # Use mapfile with libjvm_dtrace.so
    72 LIBJVM_DTRACE_MAPFILE = $(MAKEFILES_DIR)/mapfile-vers-jvm_dtrace
    73 LFLAGS_JVM_DTRACE += $(MAPFLAG:FILENAME=$(LIBJVM_DTRACE_MAPFILE))
    75 ifdef USE_GCC
    76 LFLAGS_JVM_DB += -D_REENTRANT $(PICFLAG)
    77 LFLAGS_JVM_DTRACE += -D_REENTRANT $(PICFLAG)
    78 else
    79 LFLAGS_JVM_DB += -mt $(PICFLAG) -xnolib
    80 LFLAGS_JVM_DTRACE += -mt $(PICFLAG) -xnolib
    81 endif
    83 ISA = $(subst i386,i486,$(shell isainfo -n))
    85 # Making 64/libjvm_db.so: 64-bit version of libjvm_db.so which handles 32-bit libjvm.so
    86 ifneq ("${ISA}","${BUILDARCH}")
    88 XLIBJVM_DB = 64/$(LIBJVM_DB)
    89 XLIBJVM_DTRACE = 64/$(LIBJVM_DTRACE)
    91 $(XLIBJVM_DB): $(DTRACE_SRCDIR)/$(JVM_DB).c $(JVMOFFS).h $(LIBJVM_DB_MAPFILE)
    92 	@echo Making $@
    93 	$(QUIETLY) mkdir -p 64/ ; \
    94 	$(CC) $(SYMFLAG) $(ARCHFLAG/$(ISA)) -D$(TYPE) -I. -I$(GENERATED) \
    95 		$(SHARED_FLAG) $(LFLAGS_JVM_DB) -o $@ $(DTRACE_SRCDIR)/$(JVM_DB).c -lc
    96 $(XLIBJVM_DTRACE): $(DTRACE_SRCDIR)/$(JVM_DTRACE).c $(DTRACE_SRCDIR)/$(JVM_DTRACE).h $(LIBJVM_DTRACE_MAPFILE)
    97 	@echo Making $@
    98 	$(QUIETLY) mkdir -p 64/ ; \
    99 	$(CC) $(SYMFLAG) $(ARCHFLAG/$(ISA)) -D$(TYPE) -I. \
   100 		$(SHARED_FLAG) $(LFLAGS_JVM_DTRACE) -o $@ $(DTRACE_SRCDIR)/$(JVM_DTRACE).c -lc -lthread -ldoor
   101 endif # ifneq ("${ISA}","${BUILDARCH}")
   103 ifdef USE_GCC
   104 LFLAGS_GENOFFS += -D_REENTRANT
   105 else
   106 LFLAGS_GENOFFS += -mt -xnolib -norunpath
   107 endif
   109 lib$(GENOFFS).so: $(DTRACE_SRCDIR)/$(GENOFFS).cpp $(DTRACE_SRCDIR)/$(GENOFFS).h \
   110                   $(INCLS)/_vmStructs.cpp.incl $(LIBJVM.o)
   111 	$(QUIETLY) $(CCC) $(CPPFLAGS) $(GENOFFS_CFLAGS) $(SHARED_FLAG) $(PICFLAG) \
   112 		 $(LFLAGS_GENOFFS) -o $@ $(DTRACE_SRCDIR)/$(GENOFFS).cpp -lc
   114 $(GENOFFS): $(DTRACE_SRCDIR)/$(GENOFFS)Main.c lib$(GENOFFS).so
   115 	$(QUIETLY) $(LINK.CC) -z nodefs -o $@ $(DTRACE_SRCDIR)/$(GENOFFS)Main.c \
   116 		./lib$(GENOFFS).so
   118 # $@.tmp is created first. It's to avoid empty $(JVMOFFS).h produced in error case.
   119 $(JVMOFFS).h: $(GENOFFS)
   120 	$(QUIETLY) LD_LIBRARY_PATH=. ./$(GENOFFS) -header > $@.tmp ; \
   121 	if [ `diff $@.tmp $@ > /dev/null 2>&1; echo $$?` -ne 0 ] ; \
   122 	then rm -f $@; mv $@.tmp $@; echo Updated $@ ; \
   123 	else rm -f $@.tmp; \
   124 	fi
   126 $(JVMOFFS)Index.h: $(GENOFFS)
   127 	$(QUIETLY) LD_LIBRARY_PATH=. ./$(GENOFFS) -index > $@.tmp ; \
   128 	if [ `diff $@.tmp $@ > /dev/null 2>&1; echo $$?` -ne 0 ] ; \
   129 	then rm -f $@; mv $@.tmp $@; echo Updated $@ ; \
   130 	else rm -f $@.tmp; \
   131 	fi
   133 $(JVMOFFS).cpp: $(GENOFFS) $(JVMOFFS).h $(JVMOFFS)Index.h
   134 	$(QUIETLY) LD_LIBRARY_PATH=. ./$(GENOFFS) -table > $@.tmp ; \
   135 	if [ `diff $@.tmp $@ > /dev/null 2>&1; echo $$?` -ne 0 ] ; \
   136 	then rm -f $@; mv $@.tmp $@; echo Updated $@ ; \
   137 	else rm -f $@.tmp; \
   138 	fi
   140 $(JVMOFFS.o): $(JVMOFFS).h $(JVMOFFS).cpp 
   141 	$(QUIETLY) $(CCC) -c -I. -o $@ $(ARCHFLAG) -D$(TYPE) $(JVMOFFS).cpp
   143 $(LIBJVM_DB): $(DTRACE_SRCDIR)/$(JVM_DB).c $(JVMOFFS.o) $(XLIBJVM_DB) $(LIBJVM_DB_MAPFILE)
   144 	@echo Making $@
   145 	$(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) -D$(TYPE) -I. -I$(GENERATED) \
   146 		$(SHARED_FLAG) $(LFLAGS_JVM_DB) -o $@ $(DTRACE_SRCDIR)/$(JVM_DB).c -lc
   148 $(LIBJVM_DTRACE): $(DTRACE_SRCDIR)/$(JVM_DTRACE).c $(XLIBJVM_DTRACE) $(DTRACE_SRCDIR)/$(JVM_DTRACE).h $(LIBJVM_DTRACE_MAPFILE)
   149 	@echo Making $@
   150 	$(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) -D$(TYPE) -I.  \
   151 		$(SHARED_FLAG) $(LFLAGS_JVM_DTRACE) -o $@ $(DTRACE_SRCDIR)/$(JVM_DTRACE).c -lc -lthread -ldoor
   153 $(DTRACE).d: $(DTRACE_SRCDIR)/hotspot.d $(DTRACE_SRCDIR)/hotspot_jni.d \
   154              $(DTRACE_SRCDIR)/hs_private.d $(DTRACE_SRCDIR)/jhelper.d
   155 	$(QUIETLY) cat $^ > $@
   157 # Dtrace is available, so we build $(DTRACE.o)  
   158 $(DTRACE.o): $(DTRACE).d $(JVMOFFS).h $(JVMOFFS)Index.h $(DTraced_Files)
   159 	@echo Compiling $(DTRACE).d
   161 	$(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -G -o $@ -s $(DTRACE).d \
   162      $(DTraced_Files) ||\
   163   STATUS=$$?;\
   164 	if [ x"$$STATUS" = x"1" -a \
   165        x`uname -r` = x"5.10" -a \
   166        x`uname -p` = x"sparc" ]; then\
   167     echo "*****************************************************************";\
   168     echo "* If you are building server compiler, and the error message is ";\
   169     echo "* \"incorrect ELF machine type...\", you have run into solaris bug ";\
   170     echo "* 6213962, \"dtrace -G doesn't work on sparcv8+ object files\".";\
   171     echo "* Either patch/upgrade your system (>= S10u1_15), or set the ";\
   172     echo "* environment variable HOTSPOT_DISABLE_DTRACE_PROBES to disable ";\
   173     echo "* dtrace probes for this build.";\
   174     echo "*****************************************************************";\
   175   fi;\
   176   exit $$STATUS
   177   # Since some DTraced_Files are in LIBJVM.o and they are touched by this
   178   # command, and libgenerateJvmOffsets.so depends on LIBJVM.o, 'make' will
   179   # think it needs to rebuild libgenerateJvmOffsets.so and thus JvmOffsets*
   180   # files, but it doesn't, so we touch the necessary files to prevent later
   181   # recompilation. Note: we only touch the necessary files if they already
   182   # exist in order to close a race where an empty file can be created
   183   # before the real build rule is executed.
   184   # But, we can't touch the *.h files:  This rule depends
   185   # on them, and that would cause an infinite cycle of rebuilding.
   186   # Neither the *.h or *.ccp files need to be touched, since they have
   187   # rules which do not update them when the generator file has not
   188   # changed their contents.
   189 	$(QUIETLY) if [ -f lib$(GENOFFS).so ]; then touch lib$(GENOFFS).so; fi
   190 	$(QUIETLY) if [ -f $(GENOFFS) ]; then touch $(GENOFFS); fi
   191 	$(QUIETLY) if [ -f $(JVMOFFS.o) ]; then touch $(JVMOFFS.o); fi
   193 .PHONY: dtraceCheck
   195 SYSTEM_DTRACE_H = /usr/include/dtrace.h
   196 SYSTEM_DTRACE_PROG = /usr/sbin/dtrace
   197 PATCH_DTRACE_PROG = /opt/SUNWdtrd/sbin/dtrace
   198 systemDtraceFound := $(wildcard ${SYSTEM_DTRACE_PROG})
   199 patchDtraceFound := $(wildcard ${PATCH_DTRACE_PROG})
   200 systemDtraceHdrFound := $(wildcard $(SYSTEM_DTRACE_H))
   202 ifneq ("$(systemDtraceHdrFound)", "") 
   203 CFLAGS += -DHAVE_DTRACE_H
   204 endif
   206 ifneq ("$(patchDtraceFound)", "")
   207 DTRACE_PROG=$(PATCH_DTRACE_PROG)
   208 DTRACE_INCL=-I/opt/SUNWdtrd/include
   209 else
   210 ifneq ("$(systemDtraceFound)", "")
   211 DTRACE_PROG=$(SYSTEM_DTRACE_PROG)
   212 else
   214 endif # ifneq ("$(systemDtraceFound)", "")
   215 endif # ifneq ("$(patchDtraceFound)", "")
   217 ifneq ("${DTRACE_PROG}", "")
   218 ifeq ("${HOTSPOT_DISABLE_DTRACE_PROBES}", "")
   220 DTRACE_OBJS = $(DTRACE.o) $(JVMOFFS.o)
   221 CFLAGS += $(DTRACE_INCL) -DDTRACE_ENABLED
   222 MAPFILE_DTRACE_OPT = $(MAPFILE_DTRACE)
   224 dtraceCheck:
   226 else # manually disabled
   228 dtraceCheck:
   229 	$(QUIETLY) echo "**NOTICE** Dtrace support disabled via environment variable"
   231 endif # ifeq ("${HOTSPOT_DISABLE_DTRACE_PROBES}", "")
   233 else # No dtrace program found
   235 dtraceCheck:
   236 	$(QUIETLY) echo "**NOTICE** Dtrace support disabled: not supported by system"
   238 endif # ifneq ("${dtraceFound}", "")
   240 endif # ifdef USE_GCC
   242 else # KERNEL build
   244 dtraceCheck:
   245 	$(QUIETLY) echo "**NOTICE** Dtrace support disabled for KERNEL builds"
   247 endif # ifneq ("${TYPE}", "KERNEL")
   249 else # CORE build
   251 dtraceCheck:
   252 	$(QUIETLY) echo "**NOTICE** Dtrace support disabled for CORE builds"
   254 endif # ifneq ("${TYPE}", "CORE")

mercurial