never@3156: # zgu@4492: # Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. never@3156: # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. never@3156: # never@3156: # This code is free software; you can redistribute it and/or modify it never@3156: # under the terms of the GNU General Public License version 2 only, as never@3156: # published by the Free Software Foundation. never@3156: # never@3156: # This code is distributed in the hope that it will be useful, but WITHOUT never@3156: # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or never@3156: # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License never@3156: # version 2 for more details (a copy is included in the LICENSE file that never@3156: # accompanied this code). never@3156: # never@3156: # You should have received a copy of the GNU General Public License version never@3156: # 2 along with this work; if not, write to the Free Software Foundation, never@3156: # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. never@3156: # never@3156: # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA never@3156: # or visit www.oracle.com if you need additional information or have any never@3156: # questions. never@3156: # never@3156: # never@3156: dcubed@3202: # Rules to build jvm_db/dtrace, used by vm.make never@3156: dcubed@3202: # We build libjvm_dtrace/libjvm_db/dtrace for COMPILER1 and COMPILER2 zgu@4492: # but not for CORE configuration. dcubed@3202: dcubed@3202: ifneq ("${TYPE}", "CORE") dcubed@3202: dcubed@3202: ifeq ($(OS_VENDOR), Darwin) dcubed@3202: # we build dtrace for macosx using USDT2 probes dcubed@3202: dcubed@3202: DtraceOutDir = $(GENERATED)/dtracefiles dcubed@3202: dcubed@3202: # Bsd does not build libjvm_db, does not compile on macosx dcubed@3202: # disabled in build: rule in vm.make dcubed@3202: JVM_DB = libjvm_db dcubed@4344: LIBJVM_DB = libjvm_db.dylib dcubed@3202: dcubed@3202: JVM_DTRACE = jvm_dtrace dcubed@4344: LIBJVM_DTRACE = libjvm_dtrace.dylib dcubed@3202: dcubed@3202: JVMOFFS = JvmOffsets dcubed@3202: JVMOFFS.o = $(JVMOFFS).o dcubed@3202: GENOFFS = generate$(JVMOFFS) dcubed@3202: dcubed@3202: DTRACE_SRCDIR = $(GAMMADIR)/src/os/$(Platform_os_family)/dtrace dcubed@3202: DTRACE = dtrace dcubed@3202: DTRACE.o = $(DTRACE).o dcubed@3202: dcubed@3202: # to remove '-g' option which causes link problems dcubed@3202: # also '-z nodefs' is used as workaround dcubed@3202: GENOFFS_CFLAGS = $(shell echo $(CFLAGS) | sed -e 's/ -g / /g' -e 's/ -g0 / /g';) dcubed@3202: dcubed@3202: ifdef LP64 dcubed@3202: DTRACE_OPTS = -D_LP64 dcubed@3202: endif dcubed@3202: dcubed@3202: # making libjvm_db dcubed@3202: dcubed@3202: # Use mapfile with libjvm_db.so dcubed@3202: LIBJVM_DB_MAPFILE = # no mapfile for usdt2 # $(MAKEFILES_DIR)/mapfile-vers-jvm_db dcubed@3202: #LFLAGS_JVM_DB += $(MAPFLAG:FILENAME=$(LIBJVM_DB_MAPFILE)) dcubed@3202: dcubed@3202: # Use mapfile with libjvm_dtrace.so dcubed@3202: LIBJVM_DTRACE_MAPFILE = # no mapfile for usdt2 # $(MAKEFILES_DIR)/mapfile-vers-jvm_dtrace dcubed@3202: #LFLAGS_JVM_DTRACE += $(MAPFLAG:FILENAME=$(LIBJVM_DTRACE_MAPFILE)) dcubed@3202: dcubed@3202: LFLAGS_JVM_DB += $(PICFLAG) # -D_REENTRANT dcubed@3202: LFLAGS_JVM_DTRACE += $(PICFLAG) # -D_REENTRANT dcubed@3202: dcubed@3202: ISA = $(subst i386,i486,$(BUILDARCH)) dcubed@3202: dcubed@3202: # Making 64/libjvm_db.so: 64-bit version of libjvm_db.so which handles 32-bit libjvm.so dcubed@3202: ifneq ("${ISA}","${BUILDARCH}") dcubed@3202: dcubed@3202: XLIBJVM_DB = 64/$(LIBJVM_DB) dcubed@3202: XLIBJVM_DTRACE = 64/$(LIBJVM_DTRACE) dcubed@3202: XARCH = $(subst sparcv9,v9,$(shell echo $(ISA))) dcubed@3202: dcubed@3202: $(XLIBJVM_DB): $(DTRACE_SRCDIR)/$(JVM_DB).c $(JVMOFFS).h $(LIBJVM_DB_MAPFILE) dcubed@3202: @echo Making $@ dcubed@3202: $(QUIETLY) mkdir -p 64/ ; \ dcubed@3202: $(CC) $(SYMFLAG) -xarch=$(XARCH) -D$(TYPE) -I. -I$(GENERATED) \ dcubed@3202: $(SHARED_FLAG) $(LFLAGS_JVM_DB) -o $@ $(DTRACE_SRCDIR)/$(JVM_DB).c #-lc dcubed@3202: dcubed@3202: $(XLIBJVM_DTRACE): $(DTRACE_SRCDIR)/$(JVM_DTRACE).c $(DTRACE_SRCDIR)/$(JVM_DTRACE).h $(LIBJVM_DTRACE_MAPFILE) dcubed@3202: @echo Making $@ dcubed@3202: $(QUIETLY) mkdir -p 64/ ; \ dcubed@3202: $(CC) $(SYMFLAG) -xarch=$(XARCH) -D$(TYPE) -I. \ dcubed@3202: $(SHARED_FLAG) $(LFLAGS_JVM_DTRACE) -o $@ $(DTRACE_SRCDIR)/$(JVM_DTRACE).c #-lc -lthread -ldoor dcubed@3202: dcubed@3202: endif # ifneq ("${ISA}","${BUILDARCH}") dcubed@3202: dcubed@3202: LFLAGS_GENOFFS += -L. dcubed@3202: dcubed@3202: lib$(GENOFFS).dylib: $(DTRACE_SRCDIR)/$(GENOFFS).cpp $(DTRACE_SRCDIR)/$(GENOFFS).h \ dcubed@3202: $(LIBJVM.o) erikj@3518: $(QUIETLY) $(CXX) $(CXXFLAGS) $(GENOFFS_CFLAGS) $(SHARED_FLAG) $(PICFLAG) \ dcubed@3202: $(LFLAGS_GENOFFS) -o $@ $(DTRACE_SRCDIR)/$(GENOFFS).cpp -ljvm dcubed@3202: dcubed@3202: $(GENOFFS): $(DTRACE_SRCDIR)/$(GENOFFS)Main.c lib$(GENOFFS).dylib erikj@3518: $(QUIETLY) $(LINK.CXX) -o $@ $(DTRACE_SRCDIR)/$(GENOFFS)Main.c \ dcubed@3202: ./lib$(GENOFFS).dylib dcubed@3202: dcubed@3202: # $@.tmp is created first to avoid an empty $(JVMOFFS).h if an error occurs. dcubed@3202: $(JVMOFFS).h: $(GENOFFS) vlivanov@4156: $(QUIETLY) DYLD_LIBRARY_PATH=.:$(DYLD_LIBRARY_PATH) ./$(GENOFFS) -header > $@.tmp; touch $@; \ dcubed@3202: if [ `diff $@.tmp $@ > /dev/null 2>&1; echo $$?` -ne 0 ] ; \ dcubed@3202: then rm -f $@; mv $@.tmp $@; \ dcubed@3202: else rm -f $@.tmp; \ dcubed@3202: fi dcubed@3202: dcubed@3202: $(JVMOFFS)Index.h: $(GENOFFS) vlivanov@4156: $(QUIETLY) DYLD_LIBRARY_PATH=.:$(DYLD_LIBRARY_PATH) ./$(GENOFFS) -index > $@.tmp; touch $@; \ dcubed@3202: if [ `diff $@.tmp $@ > /dev/null 2>&1; echo $$?` -ne 0 ] ; \ dcubed@3202: then rm -f $@; mv $@.tmp $@; \ dcubed@3202: else rm -f $@.tmp; \ dcubed@3202: fi dcubed@3202: dcubed@3202: $(JVMOFFS).cpp: $(GENOFFS) $(JVMOFFS).h $(JVMOFFS)Index.h vlivanov@4156: $(QUIETLY) DYLD_LIBRARY_PATH=.:$(DYLD_LIBRARY_PATH) ./$(GENOFFS) -table > $@.tmp; touch $@; \ dcubed@3202: if [ `diff $@.tmp $@ > /dev/null 2>&1; echo $$?` -ne 0 ] ; \ dcubed@3202: then rm -f $@; mv $@.tmp $@; \ dcubed@3202: else rm -f $@.tmp; \ dcubed@3202: fi dcubed@3202: dcubed@3202: $(JVMOFFS.o): $(JVMOFFS).h $(JVMOFFS).cpp erikj@3518: $(QUIETLY) $(CXX) -c -I. -o $@ $(ARCHFLAG) -D$(TYPE) $(JVMOFFS).cpp dcubed@3202: dcubed@3202: $(LIBJVM_DB): $(DTRACE_SRCDIR)/$(JVM_DB).c $(JVMOFFS.o) $(XLIBJVM_DB) $(LIBJVM_DB_MAPFILE) dcubed@3202: @echo Making $@ dcubed@3202: $(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) -D$(TYPE) -I. -I$(GENERATED) \ dcubed@3202: $(SHARED_FLAG) $(LFLAGS_JVM_DB) -o $@ $(DTRACE_SRCDIR)/$(JVM_DB).c -Wall # -lc dcubed@3202: dcubed@3202: $(LIBJVM_DTRACE): $(DTRACE_SRCDIR)/$(JVM_DTRACE).c $(XLIBJVM_DTRACE) $(DTRACE_SRCDIR)/$(JVM_DTRACE).h $(LIBJVM_DTRACE_MAPFILE) dcubed@3202: @echo Making $@ dcubed@3202: $(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) -D$(TYPE) -I. \ dcubed@3202: $(SHARED_FLAG) $(LFLAGS_JVM_DTRACE) -o $@ $(DTRACE_SRCDIR)/$(JVM_DTRACE).c #-lc -lthread -ldoor dcubed@3202: dcubed@3202: #$(DTRACE).d: $(DTRACE_SRCDIR)/hotspot.d $(DTRACE_SRCDIR)/hotspot_jni.d \ dcubed@3202: # $(DTRACE_SRCDIR)/hs_private.d $(DTRACE_SRCDIR)/jhelper.d dcubed@3202: # $(QUIETLY) cat $^ > $@ dcubed@3202: dcubed@3202: $(DtraceOutDir): dcubed@3202: mkdir $(DtraceOutDir) dcubed@3202: dcubed@3202: $(DtraceOutDir)/hotspot.h: $(DTRACE_SRCDIR)/hotspot.d | $(DtraceOutDir) dcubed@3202: $(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -h -o $@ -s $(DTRACE_SRCDIR)/hotspot.d dcubed@3202: dcubed@3202: $(DtraceOutDir)/hotspot_jni.h: $(DTRACE_SRCDIR)/hotspot_jni.d | $(DtraceOutDir) dcubed@3202: $(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -h -o $@ -s $(DTRACE_SRCDIR)/hotspot_jni.d dcubed@3202: dcubed@3202: $(DtraceOutDir)/hs_private.h: $(DTRACE_SRCDIR)/hs_private.d | $(DtraceOutDir) dcubed@3202: $(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -h -o $@ -s $(DTRACE_SRCDIR)/hs_private.d dcubed@3202: dcubed@3202: $(DtraceOutDir)/jhelper.h: $(DTRACE_SRCDIR)/jhelper.d $(JVMOFFS).o | $(DtraceOutDir) dcubed@3202: $(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -h -o $@ -s $(DTRACE_SRCDIR)/jhelper.d dcubed@3202: dcubed@3202: # jhelper currently disabled dcubed@3202: dtrace_gen_headers: $(DtraceOutDir)/hotspot.h $(DtraceOutDir)/hotspot_jni.h $(DtraceOutDir)/hs_private.h dcubed@3202: dcubed@3202: DTraced_Files = ciEnv.o \ dcubed@3202: classLoadingService.o \ dcubed@3202: compileBroker.o \ dcubed@3202: hashtable.o \ dcubed@3202: instanceKlass.o \ dcubed@3202: java.o \ dcubed@3202: jni.o \ dcubed@3202: jvm.o \ dcubed@3202: memoryManager.o \ dcubed@3202: nmethod.o \ dcubed@3202: objectMonitor.o \ dcubed@3202: runtimeService.o \ dcubed@3202: sharedRuntime.o \ dcubed@3202: synchronizer.o \ dcubed@3202: thread.o \ dcubed@3202: unsafe.o \ dcubed@3202: vmThread.o \ dcubed@3202: vmCMSOperations.o \ dcubed@3202: vmPSOperations.o \ dcubed@3202: vmGCOperations.o \ dcubed@3202: dcubed@3202: # Dtrace is available, so we build $(DTRACE.o) dcubed@3202: #$(DTRACE.o): $(DTRACE).d $(JVMOFFS).h $(JVMOFFS)Index.h $(DTraced_Files) dcubed@3202: # @echo Compiling $(DTRACE).d dcubed@3202: dcubed@3202: # $(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -G -xlazyload -o $@ -s $(DTRACE).d \ dcubed@3202: # $(DTraced_Files) ||\ dcubed@3202: # STATUS=$$?;\ dcubed@3202: # if [ x"$$STATUS" = x"1" -a \ dcubed@3202: # x`uname -r` = x"5.10" -a \ dcubed@3202: # x`uname -p` = x"sparc" ]; then\ dcubed@3202: # echo "*****************************************************************";\ dcubed@3202: # echo "* If you are building server compiler, and the error message is ";\ dcubed@3202: # echo "* \"incorrect ELF machine type...\", you have run into solaris bug ";\ dcubed@3202: # echo "* 6213962, \"dtrace -G doesn't work on sparcv8+ object files\".";\ dcubed@3202: # echo "* Either patch/upgrade your system (>= S10u1_15), or set the ";\ dcubed@3202: # echo "* environment variable HOTSPOT_DISABLE_DTRACE_PROBES to disable ";\ dcubed@3202: # echo "* dtrace probes for this build.";\ dcubed@3202: # echo "*****************************************************************";\ dcubed@3202: # fi;\ dcubed@3202: # exit $$STATUS dcubed@3202: # Since some DTraced_Files are in LIBJVM.o and they are touched by this dcubed@3202: # command, and libgenerateJvmOffsets.so depends on LIBJVM.o, 'make' will dcubed@3202: # think it needs to rebuild libgenerateJvmOffsets.so and thus JvmOffsets* dcubed@3202: # files, but it doesn't, so we touch the necessary files to prevent later dcubed@3202: # recompilation. Note: we only touch the necessary files if they already dcubed@3202: # exist in order to close a race where an empty file can be created dcubed@3202: # before the real build rule is executed. dcubed@3202: # But, we can't touch the *.h files: This rule depends dcubed@3202: # on them, and that would cause an infinite cycle of rebuilding. dcubed@3202: # Neither the *.h or *.ccp files need to be touched, since they have dcubed@3202: # rules which do not update them when the generator file has not dcubed@3202: # changed their contents. dcubed@3202: # $(QUIETLY) if [ -f lib$(GENOFFS).so ]; then touch lib$(GENOFFS).so; fi dcubed@3202: # $(QUIETLY) if [ -f $(GENOFFS) ]; then touch $(GENOFFS); fi dcubed@3202: # $(QUIETLY) if [ -f $(JVMOFFS.o) ]; then touch $(JVMOFFS.o); fi dcubed@3202: dcubed@3202: .PHONY: dtraceCheck dcubed@3202: dcubed@3202: #SYSTEM_DTRACE_H = /usr/include/dtrace.h dcubed@3202: SYSTEM_DTRACE_PROG = /usr/sbin/dtrace dcubed@3202: #PATCH_DTRACE_PROG = /opt/SUNWdtrd/sbin/dtrace dcubed@3202: systemDtraceFound := $(wildcard ${SYSTEM_DTRACE_PROG}) dcubed@3202: #patchDtraceFound := $(wildcard ${PATCH_DTRACE_PROG}) dcubed@3202: #systemDtraceHdrFound := $(wildcard $(SYSTEM_DTRACE_H)) dcubed@3202: dcubed@3202: #ifneq ("$(systemDtraceHdrFound)", "") dcubed@3202: #CFLAGS += -DHAVE_DTRACE_H dcubed@3202: #endif dcubed@3202: dcubed@3202: #ifneq ("$(patchDtraceFound)", "") dcubed@3202: #DTRACE_PROG=$(PATCH_DTRACE_PROG) dcubed@3202: #DTRACE_INCL=-I/opt/SUNWdtrd/include dcubed@3202: #else dcubed@3202: ifneq ("$(systemDtraceFound)", "") dcubed@3202: DTRACE_PROG=$(SYSTEM_DTRACE_PROG) dcubed@3202: else dcubed@3202: dcubed@3202: endif # ifneq ("$(systemDtraceFound)", "") dcubed@3202: #endif # ifneq ("$(patchDtraceFound)", "") dcubed@3202: dcubed@3202: ifneq ("${DTRACE_PROG}", "") dcubed@3202: ifeq ("${HOTSPOT_DISABLE_DTRACE_PROBES}", "") dcubed@3202: dcubed@3202: DTRACE_OBJS = $(DTRACE.o) #$(JVMOFFS.o) dcubed@3202: CFLAGS += -DDTRACE_ENABLED #$(DTRACE_INCL) dcubed@3202: #clangCFLAGS += -DDTRACE_ENABLED -fno-optimize-sibling-calls dcubed@3202: #MAPFILE_DTRACE_OPT = $(MAPFILE_DTRACE) dcubed@3202: dcubed@3202: dcubed@3202: dtraceCheck: dcubed@3202: dcubed@3202: dtrace_stuff: dtrace_gen_headers dcubed@3202: $(QUIETLY) echo "dtrace headers generated" dcubed@3202: dcubed@3202: dcubed@3202: else # manually disabled dcubed@3202: dcubed@3202: dtraceCheck: dcubed@3202: $(QUIETLY) echo "**NOTICE** Dtrace support disabled via environment variable" dcubed@3202: dcubed@3202: dtrace_stuff: dcubed@3202: dcubed@3202: endif # ifeq ("${HOTSPOT_DISABLE_DTRACE_PROBES}", "") dcubed@3202: dcubed@3202: else # No dtrace program found dcubed@3202: dcubed@3202: dtraceCheck: dcubed@3202: $(QUIETLY) echo "**NOTICE** Dtrace support disabled: not supported by system" dcubed@3202: dcubed@3202: dtrace_stuff: dcubed@3202: dcubed@3202: endif # ifneq ("${dtraceFound}", "") dcubed@3202: dcubed@3202: endif # ifeq ($(OS_VENDOR), Darwin) dcubed@3202: dcubed@3202: dcubed@3202: else # CORE build dcubed@3202: dcubed@3202: dtraceCheck: dcubed@3202: $(QUIETLY) echo "**NOTICE** Dtrace support disabled for CORE builds" dcubed@3202: dcubed@3202: endif # ifneq ("${TYPE}", "CORE")