make/bsd/makefiles/dtrace.make

Thu, 20 Dec 2012 10:22:19 +0100

author
stefank
date
Thu, 20 Dec 2012 10:22:19 +0100
changeset 4393
35431a769282
parent 4344
892acf0431ef
child 4492
8b46b0196eb0
permissions
-rw-r--r--

8004823: Add VM support for type annotation reflection
Reviewed-by: dholmes, coleenp
Contributed-by: joel.franck@oracle.com

     1 #
     2 # Copyright (c) 2005, 2012, 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 # 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 or KERNEL configurations.
    30 ifneq ("${TYPE}", "CORE")
    31 ifneq ("${TYPE}", "KERNEL")
    33 ifeq ($(OS_VENDOR), Darwin)
    34 # we build dtrace for macosx using USDT2 probes
    36 DtraceOutDir = $(GENERATED)/dtracefiles
    38 # Bsd does not build libjvm_db, does not compile on macosx
    39 # disabled in build: rule in vm.make
    40 JVM_DB = libjvm_db
    41 LIBJVM_DB = libjvm_db.dylib
    43 JVM_DTRACE = jvm_dtrace
    44 LIBJVM_DTRACE = libjvm_dtrace.dylib
    46 JVMOFFS = JvmOffsets
    47 JVMOFFS.o = $(JVMOFFS).o
    48 GENOFFS = generate$(JVMOFFS)
    50 DTRACE_SRCDIR = $(GAMMADIR)/src/os/$(Platform_os_family)/dtrace
    51 DTRACE = dtrace
    52 DTRACE.o = $(DTRACE).o
    54 # to remove '-g' option which causes link problems
    55 # also '-z nodefs' is used as workaround
    56 GENOFFS_CFLAGS = $(shell echo $(CFLAGS) | sed -e 's/ -g / /g' -e 's/ -g0 / /g';)
    58 ifdef LP64
    59 DTRACE_OPTS = -D_LP64
    60 endif
    62 # making libjvm_db
    64 # Use mapfile with libjvm_db.so
    65 LIBJVM_DB_MAPFILE = # no mapfile for usdt2 # $(MAKEFILES_DIR)/mapfile-vers-jvm_db
    66 #LFLAGS_JVM_DB += $(MAPFLAG:FILENAME=$(LIBJVM_DB_MAPFILE))
    68 # Use mapfile with libjvm_dtrace.so
    69 LIBJVM_DTRACE_MAPFILE = # no mapfile for usdt2 # $(MAKEFILES_DIR)/mapfile-vers-jvm_dtrace
    70 #LFLAGS_JVM_DTRACE += $(MAPFLAG:FILENAME=$(LIBJVM_DTRACE_MAPFILE))
    72 LFLAGS_JVM_DB += $(PICFLAG) # -D_REENTRANT
    73 LFLAGS_JVM_DTRACE += $(PICFLAG) # -D_REENTRANT
    75 ISA = $(subst i386,i486,$(BUILDARCH))
    77 # Making 64/libjvm_db.so: 64-bit version of libjvm_db.so which handles 32-bit libjvm.so
    78 ifneq ("${ISA}","${BUILDARCH}")
    80 XLIBJVM_DB = 64/$(LIBJVM_DB)
    81 XLIBJVM_DTRACE = 64/$(LIBJVM_DTRACE)
    82 XARCH = $(subst sparcv9,v9,$(shell echo $(ISA)))
    84 $(XLIBJVM_DB): $(DTRACE_SRCDIR)/$(JVM_DB).c $(JVMOFFS).h $(LIBJVM_DB_MAPFILE)
    85 	@echo Making $@
    86 	$(QUIETLY) mkdir -p 64/ ; \
    87 	$(CC) $(SYMFLAG) -xarch=$(XARCH) -D$(TYPE) -I. -I$(GENERATED) \
    88 		$(SHARED_FLAG) $(LFLAGS_JVM_DB) -o $@ $(DTRACE_SRCDIR)/$(JVM_DB).c #-lc
    90 $(XLIBJVM_DTRACE): $(DTRACE_SRCDIR)/$(JVM_DTRACE).c $(DTRACE_SRCDIR)/$(JVM_DTRACE).h $(LIBJVM_DTRACE_MAPFILE)
    91 	@echo Making $@
    92 	$(QUIETLY) mkdir -p 64/ ; \
    93 	$(CC) $(SYMFLAG) -xarch=$(XARCH) -D$(TYPE) -I. \
    94 		$(SHARED_FLAG) $(LFLAGS_JVM_DTRACE) -o $@ $(DTRACE_SRCDIR)/$(JVM_DTRACE).c #-lc -lthread -ldoor
    96 endif # ifneq ("${ISA}","${BUILDARCH}")
    98 LFLAGS_GENOFFS += -L.
   100 lib$(GENOFFS).dylib: $(DTRACE_SRCDIR)/$(GENOFFS).cpp $(DTRACE_SRCDIR)/$(GENOFFS).h \
   101                   $(LIBJVM.o)
   102 	$(QUIETLY) $(CXX) $(CXXFLAGS) $(GENOFFS_CFLAGS) $(SHARED_FLAG) $(PICFLAG) \
   103 		 $(LFLAGS_GENOFFS) -o $@ $(DTRACE_SRCDIR)/$(GENOFFS).cpp -ljvm
   105 $(GENOFFS): $(DTRACE_SRCDIR)/$(GENOFFS)Main.c lib$(GENOFFS).dylib
   106 	$(QUIETLY) $(LINK.CXX) -o $@ $(DTRACE_SRCDIR)/$(GENOFFS)Main.c \
   107 		./lib$(GENOFFS).dylib
   109 # $@.tmp is created first to avoid an empty $(JVMOFFS).h if an error occurs.
   110 $(JVMOFFS).h: $(GENOFFS)
   111 	$(QUIETLY) DYLD_LIBRARY_PATH=.:$(DYLD_LIBRARY_PATH) ./$(GENOFFS) -header > $@.tmp; touch $@; \
   112 	if [ `diff $@.tmp $@ > /dev/null 2>&1; echo $$?` -ne 0 ] ; \
   113 	then rm -f $@; mv $@.tmp $@; \
   114 	else rm -f $@.tmp; \
   115 	fi
   117 $(JVMOFFS)Index.h: $(GENOFFS)
   118 	$(QUIETLY) DYLD_LIBRARY_PATH=.:$(DYLD_LIBRARY_PATH) ./$(GENOFFS) -index > $@.tmp; touch $@; \
   119 	if [ `diff $@.tmp $@ > /dev/null 2>&1; echo $$?` -ne 0 ] ; \
   120 	then rm -f $@; mv $@.tmp $@; \
   121 	else rm -f $@.tmp; \
   122 	fi
   124 $(JVMOFFS).cpp: $(GENOFFS) $(JVMOFFS).h $(JVMOFFS)Index.h
   125 	$(QUIETLY) DYLD_LIBRARY_PATH=.:$(DYLD_LIBRARY_PATH) ./$(GENOFFS) -table > $@.tmp; touch $@; \
   126 	if [ `diff $@.tmp $@ > /dev/null 2>&1; echo $$?` -ne 0 ] ; \
   127 	then rm -f $@; mv $@.tmp $@; \
   128 	else rm -f $@.tmp; \
   129 	fi
   131 $(JVMOFFS.o): $(JVMOFFS).h $(JVMOFFS).cpp 
   132 	$(QUIETLY) $(CXX) -c -I. -o $@ $(ARCHFLAG) -D$(TYPE) $(JVMOFFS).cpp
   134 $(LIBJVM_DB): $(DTRACE_SRCDIR)/$(JVM_DB).c $(JVMOFFS.o) $(XLIBJVM_DB) $(LIBJVM_DB_MAPFILE)
   135 	@echo Making $@
   136 	$(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) -D$(TYPE) -I. -I$(GENERATED) \
   137 		$(SHARED_FLAG) $(LFLAGS_JVM_DB) -o $@ $(DTRACE_SRCDIR)/$(JVM_DB).c -Wall # -lc
   139 $(LIBJVM_DTRACE): $(DTRACE_SRCDIR)/$(JVM_DTRACE).c $(XLIBJVM_DTRACE) $(DTRACE_SRCDIR)/$(JVM_DTRACE).h $(LIBJVM_DTRACE_MAPFILE)
   140 	@echo Making $@
   141 	$(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) -D$(TYPE) -I.  \
   142 		$(SHARED_FLAG) $(LFLAGS_JVM_DTRACE) -o $@ $(DTRACE_SRCDIR)/$(JVM_DTRACE).c #-lc -lthread -ldoor
   144 #$(DTRACE).d: $(DTRACE_SRCDIR)/hotspot.d $(DTRACE_SRCDIR)/hotspot_jni.d \
   145 #             $(DTRACE_SRCDIR)/hs_private.d $(DTRACE_SRCDIR)/jhelper.d
   146 #	$(QUIETLY) cat $^ > $@
   148 $(DtraceOutDir):
   149 	mkdir $(DtraceOutDir)
   151 $(DtraceOutDir)/hotspot.h: $(DTRACE_SRCDIR)/hotspot.d | $(DtraceOutDir)
   152 	$(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -h -o $@ -s $(DTRACE_SRCDIR)/hotspot.d
   154 $(DtraceOutDir)/hotspot_jni.h: $(DTRACE_SRCDIR)/hotspot_jni.d | $(DtraceOutDir)
   155 	$(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -h -o $@ -s $(DTRACE_SRCDIR)/hotspot_jni.d
   157 $(DtraceOutDir)/hs_private.h: $(DTRACE_SRCDIR)/hs_private.d | $(DtraceOutDir)
   158 	$(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -h -o $@ -s $(DTRACE_SRCDIR)/hs_private.d
   160 $(DtraceOutDir)/jhelper.h: $(DTRACE_SRCDIR)/jhelper.d $(JVMOFFS).o | $(DtraceOutDir)
   161 	$(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -h -o $@ -s $(DTRACE_SRCDIR)/jhelper.d
   163 # jhelper currently disabled
   164 dtrace_gen_headers: $(DtraceOutDir)/hotspot.h $(DtraceOutDir)/hotspot_jni.h $(DtraceOutDir)/hs_private.h 
   166 DTraced_Files = ciEnv.o \
   167                 classLoadingService.o \
   168                 compileBroker.o \
   169                 hashtable.o \
   170                 instanceKlass.o \
   171                 java.o \
   172                 jni.o \
   173                 jvm.o \
   174                 memoryManager.o \
   175                 nmethod.o \
   176                 objectMonitor.o \
   177                 runtimeService.o \
   178                 sharedRuntime.o \
   179                 synchronizer.o \
   180                 thread.o \
   181                 unsafe.o \
   182                 vmThread.o \
   183                 vmCMSOperations.o \
   184                 vmPSOperations.o \
   185                 vmGCOperations.o \
   187 # Dtrace is available, so we build $(DTRACE.o)  
   188 #$(DTRACE.o): $(DTRACE).d $(JVMOFFS).h $(JVMOFFS)Index.h $(DTraced_Files)
   189 #	@echo Compiling $(DTRACE).d
   191 #	$(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -G -xlazyload -o $@ -s $(DTRACE).d \
   192 #     $(DTraced_Files) ||\
   193 #  STATUS=$$?;\
   194 #	if [ x"$$STATUS" = x"1" -a \
   195 #       x`uname -r` = x"5.10" -a \
   196 #       x`uname -p` = x"sparc" ]; then\
   197 #    echo "*****************************************************************";\
   198 #    echo "* If you are building server compiler, and the error message is ";\
   199 #    echo "* \"incorrect ELF machine type...\", you have run into solaris bug ";\
   200 #    echo "* 6213962, \"dtrace -G doesn't work on sparcv8+ object files\".";\
   201 #    echo "* Either patch/upgrade your system (>= S10u1_15), or set the ";\
   202 #    echo "* environment variable HOTSPOT_DISABLE_DTRACE_PROBES to disable ";\
   203 #    echo "* dtrace probes for this build.";\
   204 #    echo "*****************************************************************";\
   205 #  fi;\
   206 #  exit $$STATUS
   207   # Since some DTraced_Files are in LIBJVM.o and they are touched by this
   208   # command, and libgenerateJvmOffsets.so depends on LIBJVM.o, 'make' will
   209   # think it needs to rebuild libgenerateJvmOffsets.so and thus JvmOffsets*
   210   # files, but it doesn't, so we touch the necessary files to prevent later
   211   # recompilation. Note: we only touch the necessary files if they already
   212   # exist in order to close a race where an empty file can be created
   213   # before the real build rule is executed.
   214   # But, we can't touch the *.h files:  This rule depends
   215   # on them, and that would cause an infinite cycle of rebuilding.
   216   # Neither the *.h or *.ccp files need to be touched, since they have
   217   # rules which do not update them when the generator file has not
   218   # changed their contents.
   219 #	$(QUIETLY) if [ -f lib$(GENOFFS).so ]; then touch lib$(GENOFFS).so; fi
   220 #	$(QUIETLY) if [ -f $(GENOFFS) ]; then touch $(GENOFFS); fi
   221 #	$(QUIETLY) if [ -f $(JVMOFFS.o) ]; then touch $(JVMOFFS.o); fi
   223 .PHONY: dtraceCheck
   225 #SYSTEM_DTRACE_H = /usr/include/dtrace.h
   226 SYSTEM_DTRACE_PROG = /usr/sbin/dtrace
   227 #PATCH_DTRACE_PROG = /opt/SUNWdtrd/sbin/dtrace
   228 systemDtraceFound := $(wildcard ${SYSTEM_DTRACE_PROG})
   229 #patchDtraceFound := $(wildcard ${PATCH_DTRACE_PROG})
   230 #systemDtraceHdrFound := $(wildcard $(SYSTEM_DTRACE_H))
   232 #ifneq ("$(systemDtraceHdrFound)", "") 
   233 #CFLAGS += -DHAVE_DTRACE_H
   234 #endif
   236 #ifneq ("$(patchDtraceFound)", "")
   237 #DTRACE_PROG=$(PATCH_DTRACE_PROG)
   238 #DTRACE_INCL=-I/opt/SUNWdtrd/include
   239 #else
   240 ifneq ("$(systemDtraceFound)", "")
   241 DTRACE_PROG=$(SYSTEM_DTRACE_PROG)
   242 else
   244 endif # ifneq ("$(systemDtraceFound)", "")
   245 #endif # ifneq ("$(patchDtraceFound)", "")
   247 ifneq ("${DTRACE_PROG}", "")
   248 ifeq ("${HOTSPOT_DISABLE_DTRACE_PROBES}", "")
   250 DTRACE_OBJS = $(DTRACE.o) #$(JVMOFFS.o)
   251 CFLAGS += -DDTRACE_ENABLED #$(DTRACE_INCL)
   252 #clangCFLAGS += -DDTRACE_ENABLED -fno-optimize-sibling-calls
   253 #MAPFILE_DTRACE_OPT = $(MAPFILE_DTRACE)
   256 dtraceCheck:
   258 dtrace_stuff: dtrace_gen_headers
   259 	$(QUIETLY) echo "dtrace headers generated"
   262 else # manually disabled
   264 dtraceCheck:
   265 	$(QUIETLY) echo "**NOTICE** Dtrace support disabled via environment variable"
   267 dtrace_stuff:
   269 endif # ifeq ("${HOTSPOT_DISABLE_DTRACE_PROBES}", "")
   271 else # No dtrace program found
   273 dtraceCheck:
   274 	$(QUIETLY) echo "**NOTICE** Dtrace support disabled: not supported by system"
   276 dtrace_stuff:
   278 endif # ifneq ("${dtraceFound}", "")
   280 endif # ifeq ($(OS_VENDOR), Darwin)
   283 else # KERNEL build
   285 dtraceCheck:
   286 	$(QUIETLY) echo "**NOTICE** Dtrace support disabled for KERNEL builds"
   288 endif # ifneq ("${TYPE}", "KERNEL")
   290 else # CORE build
   292 dtraceCheck:
   293 	$(QUIETLY) echo "**NOTICE** Dtrace support disabled for CORE builds"
   295 endif # ifneq ("${TYPE}", "CORE")

mercurial