comparison make/solaris/makefiles/dtrace.make @ 91:a294fd0c4b38

6583644: Move all managed/SCCS files out of 'build' into 'make' directory Summary: Moved makefiles out of build and build/closed into make/ Reviewed-by: kvn, ohair
author kamg
date Wed, 09 Apr 2008 14:22:48 -0400
parents build/solaris/makefiles/dtrace.make@a61af66fc99e
children 018d5b58dd4f
comparison
equal deleted inserted replaced
90:cf4e16e9ca60 91:a294fd0c4b38
1 #
2 # Copyright 2005-2007 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 #
24
25 # Rules to build jvm_db/dtrace, used by vm.make
26
27 # we build libjvm_dtrace/libjvm_db/dtrace for COMPILER1 and COMPILER2
28 # but not for CORE configuration
29
30 ifneq ("${TYPE}", "CORE")
31 ifneq ("${TYPE}", "KERNEL")
32
33 ifdef USE_GCC
34
35 dtraceCheck:
36 $(QUIETLY) echo "**NOTICE** Dtrace support disabled for gcc builds"
37
38 else
39
40
41 JVM_DB = libjvm_db
42 LIBJVM_DB = libjvm$(G_SUFFIX)_db.so
43
44 JVM_DTRACE = jvm_dtrace
45 LIBJVM_DTRACE = libjvm$(G_SUFFIX)_dtrace.so
46
47 JVMOFFS = JvmOffsets
48 JVMOFFS.o = $(JVMOFFS).o
49 GENOFFS = generate$(JVMOFFS)
50
51 DTRACE_SRCDIR = $(GAMMADIR)/src/os/$(Platform_os_family)/dtrace
52 DTRACE = dtrace
53 DTRACE.o = $(DTRACE).o
54
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';)
58
59 ifdef LP64
60 DTRACE_OPTS = -64 -D_LP64
61 endif
62
63 # making libjvm_db
64
65 INCLS = $(GENERATED)/incls
66
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))
70
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))
74
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
82
83 ISA = $(subst i386,i486,$(shell isainfo -n))
84
85 # Making 64/libjvm_db.so: 64-bit version of libjvm_db.so which handles 32-bit libjvm.so
86 ifneq ("${ISA}","${BUILDARCH}")
87
88 XLIBJVM_DB = 64/$(LIBJVM_DB)
89 XLIBJVM_DTRACE = 64/$(LIBJVM_DTRACE)
90 XARCH = $(subst sparcv9,v9,$(shell echo $(ISA)))
91
92 $(XLIBJVM_DB): $(DTRACE_SRCDIR)/$(JVM_DB).c $(JVMOFFS).h $(LIBJVM_DB_MAPFILE)
93 @echo Making $@
94 $(QUIETLY) mkdir -p 64/ ; \
95 $(CC) $(SYMFLAG) -xarch=$(XARCH) -D$(TYPE) -I. -I$(GENERATED) \
96 $(SHARED_FLAG) $(LFLAGS_JVM_DB) -o $@ $(DTRACE_SRCDIR)/$(JVM_DB).c -lc
97 $(XLIBJVM_DTRACE): $(DTRACE_SRCDIR)/$(JVM_DTRACE).c $(DTRACE_SRCDIR)/$(JVM_DTRACE).h $(LIBJVM_DTRACE_MAPFILE)
98 @echo Making $@
99 $(QUIETLY) mkdir -p 64/ ; \
100 $(CC) $(SYMFLAG) -xarch=$(XARCH) -D$(TYPE) -I. \
101 $(SHARED_FLAG) $(LFLAGS_JVM_DTRACE) -o $@ $(DTRACE_SRCDIR)/$(JVM_DTRACE).c -lc -lthread -ldoor
102 endif # ifneq ("${ISA}","${BUILDARCH}")
103
104 ifdef USE_GCC
105 LFLAGS_GENOFFS += -D_REENTRANT
106 else
107 LFLAGS_GENOFFS += -mt -xnolib -norunpath
108 endif
109
110 lib$(GENOFFS).so: $(DTRACE_SRCDIR)/$(GENOFFS).cpp $(DTRACE_SRCDIR)/$(GENOFFS).h \
111 $(INCLS)/_vmStructs.cpp.incl $(LIBJVM.o)
112 $(QUIETLY) $(CCC) $(CPPFLAGS) $(GENOFFS_CFLAGS) $(SHARED_FLAG) $(PICFLAG) \
113 $(LFLAGS_GENOFFS) -o $@ $(DTRACE_SRCDIR)/$(GENOFFS).cpp -lc
114
115 $(GENOFFS): $(DTRACE_SRCDIR)/$(GENOFFS)Main.c lib$(GENOFFS).so
116 $(QUIETLY) $(LINK.CC) -z nodefs -o $@ $(DTRACE_SRCDIR)/$(GENOFFS)Main.c \
117 ./lib$(GENOFFS).so
118
119 # $@.tmp is created first. It's to avoid empty $(JVMOFFS).h produced in error case.
120 $(JVMOFFS).h: $(GENOFFS)
121 $(QUIETLY) LD_LIBRARY_PATH=. ./$(GENOFFS) -header > $@.tmp ; \
122 if [ `diff $@.tmp $@ > /dev/null 2>&1; echo $$?` -ne 0 ] ; \
123 then rm -f $@; mv $@.tmp $@; echo Updated $@ ; \
124 else rm -f $@.tmp; \
125 fi
126
127 $(JVMOFFS)Index.h: $(GENOFFS)
128 $(QUIETLY) LD_LIBRARY_PATH=. ./$(GENOFFS) -index > $@.tmp ; \
129 if [ `diff $@.tmp $@ > /dev/null 2>&1; echo $$?` -ne 0 ] ; \
130 then rm -f $@; mv $@.tmp $@; echo Updated $@ ; \
131 else rm -f $@.tmp; \
132 fi
133
134 $(JVMOFFS).cpp: $(GENOFFS) $(JVMOFFS).h $(JVMOFFS)Index.h
135 $(QUIETLY) LD_LIBRARY_PATH=. ./$(GENOFFS) -table > $@.tmp ; \
136 if [ `diff $@.tmp $@ > /dev/null 2>&1; echo $$?` -ne 0 ] ; \
137 then rm -f $@; mv $@.tmp $@; echo Updated $@ ; \
138 else rm -f $@.tmp; \
139 fi
140
141 $(JVMOFFS.o): $(JVMOFFS).h $(JVMOFFS).cpp
142 $(QUIETLY) $(CCC) -c -I. -o $@ $(ARCHFLAG) -D$(TYPE) $(JVMOFFS).cpp
143
144 $(LIBJVM_DB): $(DTRACE_SRCDIR)/$(JVM_DB).c $(JVMOFFS.o) $(XLIBJVM_DB) $(LIBJVM_DB_MAPFILE)
145 @echo Making $@
146 $(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) -D$(TYPE) -I. -I$(GENERATED) \
147 $(SHARED_FLAG) $(LFLAGS_JVM_DB) -o $@ $(DTRACE_SRCDIR)/$(JVM_DB).c -lc
148
149 $(LIBJVM_DTRACE): $(DTRACE_SRCDIR)/$(JVM_DTRACE).c $(XLIBJVM_DTRACE) $(DTRACE_SRCDIR)/$(JVM_DTRACE).h $(LIBJVM_DTRACE_MAPFILE)
150 @echo Making $@
151 $(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) -D$(TYPE) -I. \
152 $(SHARED_FLAG) $(LFLAGS_JVM_DTRACE) -o $@ $(DTRACE_SRCDIR)/$(JVM_DTRACE).c -lc -lthread -ldoor
153
154 $(DTRACE).d: $(DTRACE_SRCDIR)/hotspot.d $(DTRACE_SRCDIR)/hotspot_jni.d \
155 $(DTRACE_SRCDIR)/hs_private.d $(DTRACE_SRCDIR)/jhelper.d
156 $(QUIETLY) cat $^ > $@
157
158 # Dtrace is available, so we build $(DTRACE.o)
159 $(DTRACE.o): $(DTRACE).d $(JVMOFFS).h $(JVMOFFS)Index.h $(DTraced_Files)
160 @echo Compiling $(DTRACE).d
161
162 $(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -G -o $@ -s $(DTRACE).d \
163 $(DTraced_Files) ||\
164 STATUS=$$?;\
165 if [ x"$$STATUS" = x"1" -a \
166 x`uname -r` = x"5.10" -a \
167 x`uname -p` = x"sparc" ]; then\
168 echo "*****************************************************************";\
169 echo "* If you are building server compiler, and the error message is ";\
170 echo "* \"incorrect ELF machine type...\", you have run into solaris bug ";\
171 echo "* 6213962, \"dtrace -G doesn't work on sparcv8+ object files\".";\
172 echo "* Either patch/upgrade your system (>= S10u1_15), or set the ";\
173 echo "* environment variable HOTSPOT_DISABLE_DTRACE_PROBES to disable ";\
174 echo "* dtrace probes for this build.";\
175 echo "*****************************************************************";\
176 fi;\
177 exit $$STATUS
178 # Since some DTraced_Files are in LIBJVM.o and they are touched by this
179 # command, and libgenerateJvmOffsets.so depends on LIBJVM.o, 'make' will
180 # think it needs to rebuild libgenerateJvmOffsets.so and thus JvmOffsets*
181 # files, but it doesn't, so we touch the necessary files to prevent later
182 # recompilation. Note: we only touch the necessary files if they already
183 # exist in order to close a race where an empty file can be created
184 # before the real build rule is executed.
185 # But, we can't touch the *.h files: This rule depends
186 # on them, and that would cause an infinite cycle of rebuilding.
187 # Neither the *.h or *.ccp files need to be touched, since they have
188 # rules which do not update them when the generator file has not
189 # changed their contents.
190 $(QUIETLY) if [ -f lib$(GENOFFS).so ]; then touch lib$(GENOFFS).so; fi
191 $(QUIETLY) if [ -f $(GENOFFS) ]; then touch $(GENOFFS); fi
192 $(QUIETLY) if [ -f $(JVMOFFS.o) ]; then touch $(JVMOFFS.o); fi
193
194 .PHONY: dtraceCheck
195
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
201 ifneq ("$(patchDtraceFound)", "")
202 DTRACE_PROG=$(PATCH_DTRACE_PROG)
203 DTRACE_INCL=-I/opt/SUNWdtrd/include
204 else
205 ifneq ("$(systemDtraceFound)", "")
206 DTRACE_PROG=$(SYSTEM_DTRACE_PROG)
207 else
208
209 endif # ifneq ("$(systemDtraceFound)", "")
210 endif # ifneq ("$(patchDtraceFound)", "")
211
212 ifneq ("${DTRACE_PROG}", "")
213 ifeq ("${HOTSPOT_DISABLE_DTRACE_PROBES}", "")
214
215 DTRACE_OBJS = $(DTRACE.o) $(JVMOFFS.o)
216 CFLAGS += $(DTRACE_INCL) -DDTRACE_ENABLED
217 MAPFILE_DTRACE_OPT = $(MAPFILE_DTRACE)
218
219 dtraceCheck:
220
221 else # manually disabled
222
223 dtraceCheck:
224 $(QUIETLY) echo "**NOTICE** Dtrace support disabled via environment variable"
225
226 endif # ifeq ("${HOTSPOT_DISABLE_DTRACE_PROBES}", "")
227
228 else # No dtrace program found
229
230 dtraceCheck:
231 $(QUIETLY) echo "**NOTICE** Dtrace support disabled: not supported by system"
232
233 endif # ifneq ("${dtraceFound}", "")
234
235 endif # ifdef USE_GCC
236
237 else # KERNEL build
238
239 dtraceCheck:
240 $(QUIETLY) echo "**NOTICE** Dtrace support disabled for KERNEL builds"
241
242 endif # ifneq ("${TYPE}", "KERNEL")
243
244 else # CORE build
245
246 dtraceCheck:
247 $(QUIETLY) echo "**NOTICE** Dtrace support disabled for CORE builds"
248
249 endif # ifneq ("${TYPE}", "CORE")