make/bsd/makefiles/dtrace.make

Mon, 06 Feb 2012 09:14:22 +0100

author
erikj
date
Mon, 06 Feb 2012 09:14:22 +0100
changeset 3518
719f7007c8e8
parent 3202
436b4a3231bf
child 4153
b9a9ed0f8eeb
child 4156
9024b6b53ec2
permissions
-rw-r--r--

7141242: build-infra merge: Rename CPP->CXX and LINK->LD
Summary: Cleaned up make variables for compilers and linker to consistently use CXX for C++ compiler, CC for C compiler and LD for linker.
Reviewed-by: dholmes, ohrstrom

     1 #
     2 # Copyright (c) 2005, 2010, 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
    42 LIBJVM_DB = libjvm$(G_SUFFIX)_db.dylib
    44 JVM_DTRACE = jvm_dtrace
    45 #LIBJVM_DTRACE = libjvm_dtrace.dylib
    46 LIBJVM_DTRACE = libjvm$(G_SUFFIX)_dtrace.dylib
    48 JVMOFFS = JvmOffsets
    49 JVMOFFS.o = $(JVMOFFS).o
    50 GENOFFS = generate$(JVMOFFS)
    52 DTRACE_SRCDIR = $(GAMMADIR)/src/os/$(Platform_os_family)/dtrace
    53 DTRACE = dtrace
    54 DTRACE.o = $(DTRACE).o
    56 # to remove '-g' option which causes link problems
    57 # also '-z nodefs' is used as workaround
    58 GENOFFS_CFLAGS = $(shell echo $(CFLAGS) | sed -e 's/ -g / /g' -e 's/ -g0 / /g';)
    60 ifdef LP64
    61 DTRACE_OPTS = -D_LP64
    62 endif
    64 # making libjvm_db
    66 # Use mapfile with libjvm_db.so
    67 LIBJVM_DB_MAPFILE = # no mapfile for usdt2 # $(MAKEFILES_DIR)/mapfile-vers-jvm_db
    68 #LFLAGS_JVM_DB += $(MAPFLAG:FILENAME=$(LIBJVM_DB_MAPFILE))
    70 # Use mapfile with libjvm_dtrace.so
    71 LIBJVM_DTRACE_MAPFILE = # no mapfile for usdt2 # $(MAKEFILES_DIR)/mapfile-vers-jvm_dtrace
    72 #LFLAGS_JVM_DTRACE += $(MAPFLAG:FILENAME=$(LIBJVM_DTRACE_MAPFILE))
    74 LFLAGS_JVM_DB += $(PICFLAG) # -D_REENTRANT
    75 LFLAGS_JVM_DTRACE += $(PICFLAG) # -D_REENTRANT
    77 ISA = $(subst i386,i486,$(BUILDARCH))
    79 # Making 64/libjvm_db.so: 64-bit version of libjvm_db.so which handles 32-bit libjvm.so
    80 ifneq ("${ISA}","${BUILDARCH}")
    82 XLIBJVM_DB = 64/$(LIBJVM_DB)
    83 XLIBJVM_DB_G = 64/$(LIBJVM_DB_G)
    84 XLIBJVM_DTRACE = 64/$(LIBJVM_DTRACE)
    85 XLIBJVM_DTRACE_G = 64/$(LIBJVM_DTRACE_G)
    86 XARCH = $(subst sparcv9,v9,$(shell echo $(ISA)))
    88 $(XLIBJVM_DB): $(DTRACE_SRCDIR)/$(JVM_DB).c $(JVMOFFS).h $(LIBJVM_DB_MAPFILE)
    89 	@echo Making $@
    90 	$(QUIETLY) mkdir -p 64/ ; \
    91 	$(CC) $(SYMFLAG) -xarch=$(XARCH) -D$(TYPE) -I. -I$(GENERATED) \
    92 		$(SHARED_FLAG) $(LFLAGS_JVM_DB) -o $@ $(DTRACE_SRCDIR)/$(JVM_DB).c #-lc
    93 #	[ -f $(XLIBJVM_DB_G) ] || { ln -s $(LIBJVM_DB) $(XLIBJVM_DB_G); }
    95 $(XLIBJVM_DTRACE): $(DTRACE_SRCDIR)/$(JVM_DTRACE).c $(DTRACE_SRCDIR)/$(JVM_DTRACE).h $(LIBJVM_DTRACE_MAPFILE)
    96 	@echo Making $@
    97 	$(QUIETLY) mkdir -p 64/ ; \
    98 	$(CC) $(SYMFLAG) -xarch=$(XARCH) -D$(TYPE) -I. \
    99 		$(SHARED_FLAG) $(LFLAGS_JVM_DTRACE) -o $@ $(DTRACE_SRCDIR)/$(JVM_DTRACE).c #-lc -lthread -ldoor
   100 #	[ -f $(XLIBJVM_DTRACE_G) ] || { ln -s $(LIBJVM_DTRACE) $(XLIBJVM_DTRACE_G); }
   102 endif # ifneq ("${ISA}","${BUILDARCH}")
   104 LFLAGS_GENOFFS += -L.
   106 lib$(GENOFFS).dylib: $(DTRACE_SRCDIR)/$(GENOFFS).cpp $(DTRACE_SRCDIR)/$(GENOFFS).h \
   107                   $(LIBJVM.o)
   108 	$(QUIETLY) $(CXX) $(CXXFLAGS) $(GENOFFS_CFLAGS) $(SHARED_FLAG) $(PICFLAG) \
   109 		 $(LFLAGS_GENOFFS) -o $@ $(DTRACE_SRCDIR)/$(GENOFFS).cpp -ljvm
   111 $(GENOFFS): $(DTRACE_SRCDIR)/$(GENOFFS)Main.c lib$(GENOFFS).dylib
   112 	$(QUIETLY) $(LINK.CXX) -o $@ $(DTRACE_SRCDIR)/$(GENOFFS)Main.c \
   113 		./lib$(GENOFFS).dylib
   115 # $@.tmp is created first to avoid an empty $(JVMOFFS).h if an error occurs.
   116 $(JVMOFFS).h: $(GENOFFS)
   117 	$(QUIETLY) DYLD_LIBRARY_PATH=. ./$(GENOFFS) -header > $@.tmp; touch $@; \
   118 	if [ `diff $@.tmp $@ > /dev/null 2>&1; echo $$?` -ne 0 ] ; \
   119 	then rm -f $@; mv $@.tmp $@; \
   120 	else rm -f $@.tmp; \
   121 	fi
   123 $(JVMOFFS)Index.h: $(GENOFFS)
   124 	$(QUIETLY) DYLD_LIBRARY_PATH=. ./$(GENOFFS) -index > $@.tmp; touch $@; \
   125 	if [ `diff $@.tmp $@ > /dev/null 2>&1; echo $$?` -ne 0 ] ; \
   126 	then rm -f $@; mv $@.tmp $@; \
   127 	else rm -f $@.tmp; \
   128 	fi
   130 $(JVMOFFS).cpp: $(GENOFFS) $(JVMOFFS).h $(JVMOFFS)Index.h
   131 	$(QUIETLY) DYLD_LIBRARY_PATH=. ./$(GENOFFS) -table > $@.tmp; touch $@; \
   132 	if [ `diff $@.tmp $@ > /dev/null 2>&1; echo $$?` -ne 0 ] ; \
   133 	then rm -f $@; mv $@.tmp $@; \
   134 	else rm -f $@.tmp; \
   135 	fi
   137 $(JVMOFFS.o): $(JVMOFFS).h $(JVMOFFS).cpp 
   138 	$(QUIETLY) $(CXX) -c -I. -o $@ $(ARCHFLAG) -D$(TYPE) $(JVMOFFS).cpp
   140 $(LIBJVM_DB): $(DTRACE_SRCDIR)/$(JVM_DB).c $(JVMOFFS.o) $(XLIBJVM_DB) $(LIBJVM_DB_MAPFILE)
   141 	@echo Making $@
   142 	$(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) -D$(TYPE) -I. -I$(GENERATED) \
   143 		$(SHARED_FLAG) $(LFLAGS_JVM_DB) -o $@ $(DTRACE_SRCDIR)/$(JVM_DB).c -Wall # -lc
   144 #	[ -f $(LIBJVM_DB_G) ] || { ln -s $@ $(LIBJVM_DB_G); }
   146 $(LIBJVM_DTRACE): $(DTRACE_SRCDIR)/$(JVM_DTRACE).c $(XLIBJVM_DTRACE) $(DTRACE_SRCDIR)/$(JVM_DTRACE).h $(LIBJVM_DTRACE_MAPFILE)
   147 	@echo Making $@
   148 	$(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) -D$(TYPE) -I.  \
   149 		$(SHARED_FLAG) $(LFLAGS_JVM_DTRACE) -o $@ $(DTRACE_SRCDIR)/$(JVM_DTRACE).c #-lc -lthread -ldoor
   150 #	[ -f $(LIBJVM_DTRACE_G) ] || { ln -s $@ $(LIBJVM_DTRACE_G); }
   152 #$(DTRACE).d: $(DTRACE_SRCDIR)/hotspot.d $(DTRACE_SRCDIR)/hotspot_jni.d \
   153 #             $(DTRACE_SRCDIR)/hs_private.d $(DTRACE_SRCDIR)/jhelper.d
   154 #	$(QUIETLY) cat $^ > $@
   156 $(DtraceOutDir):
   157 	mkdir $(DtraceOutDir)
   159 $(DtraceOutDir)/hotspot.h: $(DTRACE_SRCDIR)/hotspot.d | $(DtraceOutDir)
   160 	$(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -h -o $@ -s $(DTRACE_SRCDIR)/hotspot.d
   162 $(DtraceOutDir)/hotspot_jni.h: $(DTRACE_SRCDIR)/hotspot_jni.d | $(DtraceOutDir)
   163 	$(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -h -o $@ -s $(DTRACE_SRCDIR)/hotspot_jni.d
   165 $(DtraceOutDir)/hs_private.h: $(DTRACE_SRCDIR)/hs_private.d | $(DtraceOutDir)
   166 	$(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -h -o $@ -s $(DTRACE_SRCDIR)/hs_private.d
   168 $(DtraceOutDir)/jhelper.h: $(DTRACE_SRCDIR)/jhelper.d $(JVMOFFS).o | $(DtraceOutDir)
   169 	$(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -h -o $@ -s $(DTRACE_SRCDIR)/jhelper.d
   171 # jhelper currently disabled
   172 dtrace_gen_headers: $(DtraceOutDir)/hotspot.h $(DtraceOutDir)/hotspot_jni.h $(DtraceOutDir)/hs_private.h 
   174 DTraced_Files = ciEnv.o \
   175                 classLoadingService.o \
   176                 compileBroker.o \
   177                 hashtable.o \
   178                 instanceKlass.o \
   179                 java.o \
   180                 jni.o \
   181                 jvm.o \
   182                 memoryManager.o \
   183                 nmethod.o \
   184                 objectMonitor.o \
   185                 runtimeService.o \
   186                 sharedRuntime.o \
   187                 synchronizer.o \
   188                 thread.o \
   189                 unsafe.o \
   190                 vmThread.o \
   191                 vmCMSOperations.o \
   192                 vmPSOperations.o \
   193                 vmGCOperations.o \
   195 # Dtrace is available, so we build $(DTRACE.o)  
   196 #$(DTRACE.o): $(DTRACE).d $(JVMOFFS).h $(JVMOFFS)Index.h $(DTraced_Files)
   197 #	@echo Compiling $(DTRACE).d
   199 #	$(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -G -xlazyload -o $@ -s $(DTRACE).d \
   200 #     $(DTraced_Files) ||\
   201 #  STATUS=$$?;\
   202 #	if [ x"$$STATUS" = x"1" -a \
   203 #       x`uname -r` = x"5.10" -a \
   204 #       x`uname -p` = x"sparc" ]; then\
   205 #    echo "*****************************************************************";\
   206 #    echo "* If you are building server compiler, and the error message is ";\
   207 #    echo "* \"incorrect ELF machine type...\", you have run into solaris bug ";\
   208 #    echo "* 6213962, \"dtrace -G doesn't work on sparcv8+ object files\".";\
   209 #    echo "* Either patch/upgrade your system (>= S10u1_15), or set the ";\
   210 #    echo "* environment variable HOTSPOT_DISABLE_DTRACE_PROBES to disable ";\
   211 #    echo "* dtrace probes for this build.";\
   212 #    echo "*****************************************************************";\
   213 #  fi;\
   214 #  exit $$STATUS
   215   # Since some DTraced_Files are in LIBJVM.o and they are touched by this
   216   # command, and libgenerateJvmOffsets.so depends on LIBJVM.o, 'make' will
   217   # think it needs to rebuild libgenerateJvmOffsets.so and thus JvmOffsets*
   218   # files, but it doesn't, so we touch the necessary files to prevent later
   219   # recompilation. Note: we only touch the necessary files if they already
   220   # exist in order to close a race where an empty file can be created
   221   # before the real build rule is executed.
   222   # But, we can't touch the *.h files:  This rule depends
   223   # on them, and that would cause an infinite cycle of rebuilding.
   224   # Neither the *.h or *.ccp files need to be touched, since they have
   225   # rules which do not update them when the generator file has not
   226   # changed their contents.
   227 #	$(QUIETLY) if [ -f lib$(GENOFFS).so ]; then touch lib$(GENOFFS).so; fi
   228 #	$(QUIETLY) if [ -f $(GENOFFS) ]; then touch $(GENOFFS); fi
   229 #	$(QUIETLY) if [ -f $(JVMOFFS.o) ]; then touch $(JVMOFFS.o); fi
   231 .PHONY: dtraceCheck
   233 #SYSTEM_DTRACE_H = /usr/include/dtrace.h
   234 SYSTEM_DTRACE_PROG = /usr/sbin/dtrace
   235 #PATCH_DTRACE_PROG = /opt/SUNWdtrd/sbin/dtrace
   236 systemDtraceFound := $(wildcard ${SYSTEM_DTRACE_PROG})
   237 #patchDtraceFound := $(wildcard ${PATCH_DTRACE_PROG})
   238 #systemDtraceHdrFound := $(wildcard $(SYSTEM_DTRACE_H))
   240 #ifneq ("$(systemDtraceHdrFound)", "") 
   241 #CFLAGS += -DHAVE_DTRACE_H
   242 #endif
   244 #ifneq ("$(patchDtraceFound)", "")
   245 #DTRACE_PROG=$(PATCH_DTRACE_PROG)
   246 #DTRACE_INCL=-I/opt/SUNWdtrd/include
   247 #else
   248 ifneq ("$(systemDtraceFound)", "")
   249 DTRACE_PROG=$(SYSTEM_DTRACE_PROG)
   250 else
   252 endif # ifneq ("$(systemDtraceFound)", "")
   253 #endif # ifneq ("$(patchDtraceFound)", "")
   255 ifneq ("${DTRACE_PROG}", "")
   256 ifeq ("${HOTSPOT_DISABLE_DTRACE_PROBES}", "")
   258 DTRACE_OBJS = $(DTRACE.o) #$(JVMOFFS.o)
   259 CFLAGS += -DDTRACE_ENABLED #$(DTRACE_INCL)
   260 #clangCFLAGS += -DDTRACE_ENABLED -fno-optimize-sibling-calls
   261 #MAPFILE_DTRACE_OPT = $(MAPFILE_DTRACE)
   264 dtraceCheck:
   266 dtrace_stuff: dtrace_gen_headers
   267 	$(QUIETLY) echo "dtrace headers generated"
   270 else # manually disabled
   272 dtraceCheck:
   273 	$(QUIETLY) echo "**NOTICE** Dtrace support disabled via environment variable"
   275 dtrace_stuff:
   277 endif # ifeq ("${HOTSPOT_DISABLE_DTRACE_PROBES}", "")
   279 else # No dtrace program found
   281 dtraceCheck:
   282 	$(QUIETLY) echo "**NOTICE** Dtrace support disabled: not supported by system"
   284 dtrace_stuff:
   286 endif # ifneq ("${dtraceFound}", "")
   288 endif # ifeq ($(OS_VENDOR), Darwin)
   291 else # KERNEL build
   293 dtraceCheck:
   294 	$(QUIETLY) echo "**NOTICE** Dtrace support disabled for KERNEL builds"
   296 endif # ifneq ("${TYPE}", "KERNEL")
   298 else # CORE build
   300 dtraceCheck:
   301 	$(QUIETLY) echo "**NOTICE** Dtrace support disabled for CORE builds"
   303 endif # ifneq ("${TYPE}", "CORE")

mercurial