< prev index next >

make/hotspot/lib/JvmDtraceObjects.gmk

Print this page




   6 # under the terms of the GNU General Public License version 2 only, as
   7 # published by the Free Software Foundation.  Oracle designates this
   8 # particular file as subject to the "Classpath" exception as provided
   9 # by Oracle in the LICENSE file that accompanied this code.
  10 #
  11 # This code is distributed in the hope that it will be useful, but WITHOUT
  12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14 # version 2 for more details (a copy is included in the LICENSE file that
  15 # accompanied this code).
  16 #
  17 # You should have received a copy of the GNU General Public License version
  18 # 2 along with this work; if not, write to the Free Software Foundation,
  19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20 #
  21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22 # or visit www.oracle.com if you need additional information or have any
  23 # questions.
  24 #
  25 
  26 ################################################################################
  27 # Support for dtrace integration with libjvm, and stand-alone dtrace library
  28 # compilation.
  29 
  30 ifeq ($(call check-jvm-feature, dtrace), true)
  31   ##############################################################################
  32 
  33   ifeq ($(OPENJDK_TARGET_OS), solaris)

  34     ############################################################################
  35     # Integrate with libjvm. Here we generate three object files which are
  36     # linked with libjvm.so. This step is complicated from a dependency
  37     # perspective, since it needs the rest of the compiled object files from the
  38     # libjvm compilation, but the output is object files that are to be included
  39     # when linking libjvm.so. So this generation must happen as a part of the
  40     # libjvm compilation.
  41 
  42     # First we need to generate the dtraceGenOffsets tool. When run, this will
  43     # produce more header files and a C++ file.
  44 
  45     # Note that generateJvmOffsets.cpp must be compiled as if it were a file
  46     # in the libjvm.so, using JVM_CFLAGS as setup in CompileJvm.gmk. Otherwise
  47     # this would preferrably have been done as a part of GensrcDtrace.gmk.
  48     $(eval $(call SetupNativeCompilation, BUILD_DTRACE_GEN_OFFSETS, \
  49         NAME := dtraceGenOffsets, \
  50         TYPE := EXECUTABLE, \
  51         SRC := $(TOPDIR)/make/hotspot/src/native/dtrace, \
  52         TOOLCHAIN := $(TOOLCHAIN_BUILD), \
  53         LDFLAGS := -m64, \
  54         CFLAGS := -m64 $(JVM_CFLAGS), \
  55         OBJECT_DIR := $(JVM_VARIANT_OUTPUTDIR)/tools/dtrace-gen-offsets/objs, \
  56         OUTPUT_DIR := $(JVM_VARIANT_OUTPUTDIR)/tools/dtrace-gen-offsets, \
  57     ))
  58 
  59     DTRACE_GEN_OFFSETS_TOOL := $(BUILD_DTRACE_GEN_OFFSETS_TARGET)
  60 
  61     # Argument 1: Output filename
  62     # Argument 2: dtrace-gen-offset tool command line option
  63     define SetupDtraceOffsetsGeneration
  64       $1: $$(BUILD_DTRACE_GEN_OFFSETS)
  65         $$(call LogInfo, Generating dtrace $2 file $$(@F))
  66         $$(call MakeDir, $$(@D))
  67         $$(call ExecuteWithLog, $$@, ( $$(DTRACE_GEN_OFFSETS_TOOL) -$$(strip $2) > $$@ ) )
  68 
  69       TARGETS += $1
  70     endef
  71 
  72     JVM_OFFSETS_H := $(DTRACE_SUPPORT_DIR)/JvmOffsets.h
  73     JVM_OFFSETS_CPP := $(DTRACE_SUPPORT_DIR)/JvmOffsets.cpp
  74     JVM_OFFSETS_INDEX_H := $(DTRACE_SUPPORT_DIR)/JvmOffsetsIndex.h
  75 
  76     # Run the dtrace-gen-offset tool to generate these three files.
  77     # The generated JvmOffsets.cpp is compiled with the rest of libjvm.
  78     $(eval $(call SetupDtraceOffsetsGeneration, $(JVM_OFFSETS_H), header))
  79     $(eval $(call SetupDtraceOffsetsGeneration, $(JVM_OFFSETS_INDEX_H), index))
  80     $(eval $(call SetupDtraceOffsetsGeneration, $(JVM_OFFSETS_CPP), table))
  81 
  82     ############################################################################
  83     # Generate DTRACE_OBJ which is linked with libjvm.so.

  84 
  85     # Concatenate all *.d files into a single file
  86     DTRACE_SOURCE_FILES := $(addprefix $(TOPDIR)/src/hotspot/os/posix/dtrace/, \
  87         hotspot_jni.d \
  88         hotspot.d \
  89         hs_private.d \
  90     )
  91 
  92     $(JVM_OUTPUTDIR)/objs/dtrace.d: $(DTRACE_SOURCE_FILES)
  93         $(call LogInfo, Generating $(@F))
  94         $(call MakeDir, $(@D))
  95         $(CAT) $^ > $@
  96 
  97     DTRACE_INSTRUMENTED_OBJS := $(addprefix $(JVM_OUTPUTDIR)/objs/, \
  98         ciEnv.o \
  99         classLoadingService.o \
 100         compileBroker.o \
 101         hashtable.o \
 102         instanceKlass.o \
 103         java.o \


 121           vmPSOperations.o \
 122       )
 123     endif
 124 
 125     DTRACE_FLAGS := -64 -G
 126     DTRACE_CPP_FLAGS := -D_LP64
 127 
 128     # Make sure we run our selected compiler for preprocessing instead of letting
 129     # the dtrace tool pick it on it's own.
 130     $(DTRACE_OBJ): $(JVM_OUTPUTDIR)/objs/dtrace.d $(DTRACE_INSTRUMENTED_OBJS)
 131         $(call LogInfo, Generating $(@F) from $(<F) and object files)
 132         $(call MakeDir, $(DTRACE_SUPPORT_DIR))
 133         $(call ExecuteWithLog, $(DTRACE_SUPPORT_DIR)/$(@F).d, \
 134             ($(CPP) $(DTRACE_CPP_FLAGS) $< > $(DTRACE_SUPPORT_DIR)/$(@F).d))
 135         $(call ExecuteWithLog, $@, $(DTRACE) $(DTRACE_FLAGS) -xlazyload -o $@ \
 136             -s $(DTRACE_SUPPORT_DIR)/$(@F).d $(sort $(DTRACE_INSTRUMENTED_OBJS)))
 137 
 138     ############################################################################
 139     # Generate DTRACE_JHELPER_OBJ which is linked with libjvm.so.
 140 






 141     # Unfortunately dtrace generates incorrect types for some symbols in
 142     # dtrace_jhelper.o, resulting in "warning: symbol X has differing types"
 143     # See JDK-6890703 for details.
 144     # We work around this by fixing the types for these symbols using elfedit,
 145     # after dtrace has generated the .o file.
 146     JHELPER_DTRACE_SRC := $(TOPDIR)/src/hotspot/os/solaris/dtrace/jhelper.d
 147 
 148     GetElfeditCommands = \
 149       $(foreach symbol, \
 150           $(shell $(GREP) ^extern $(JHELPER_DTRACE_SRC) | $(AWK) '{ gsub(";","") ; print $$3 }'), \
 151           -e 'sym:st_type $(symbol) 1')
 152 
 153     # Make sure we run our selected compiler for preprocessing instead of letting
 154     # the dtrace tool pick it on it's own.
 155     $(DTRACE_JHELPER_OBJ): $(JHELPER_DTRACE_SRC) $(JVM_OFFSETS_INDEX_H)
 156         $(call LogInfo, Running dtrace for $(<F))
 157         $(call MakeDir, $(DTRACE_SUPPORT_DIR))
 158         $(call ExecuteWithLog, $(DTRACE_SUPPORT_DIR)/$(@F).d, \
 159             ($(CPP) $(DTRACE_CPP_FLAGS) -I$(DTRACE_SUPPORT_DIR) $^ \
 160             > $(DTRACE_SUPPORT_DIR)/$(@F).d))
 161         $(call ExecuteWithLog, $@, $(DTRACE) $(DTRACE_FLAGS) -o $@ \
 162             -s $(DTRACE_SUPPORT_DIR)/$(@F).d)
 163         ifeq ($(OPENJDK_TARGET_CPU_ARCH), sparc)
 164           $(call ExecuteWithLog, $@.elfedit, $(ELFEDIT) $(call GetElfeditCommands) $@)
 165         endif
 166 
 167     ############################################################################
 168     # Build the stand-alone dtrace libraries
 169 
 170     LIBJVM_DTRACE_OUTPUTDIR := $(JVM_VARIANT_OUTPUTDIR)/libjvm_dtrace
 171 
 172     $(eval $(call SetupNativeCompilation, BUILD_LIBJVM_DTRACE, \
 173         NAME := jvm_dtrace, \
 174         OUTPUT_DIR := $(JVM_LIB_OUTPUTDIR), \
 175         SRC := $(TOPDIR)/src/java.base/solaris/native/libjvm_dtrace, \
 176         CFLAGS := -m64 -G -mt -KPIC, \
 177         LDFLAGS := -m64 -mt -xnolib $(SHARED_LIBRARY_FLAGS), \
 178         LIBS := $(LIBDL) -lthread -ldoor, \
 179         MAPFILE := $(TOPDIR)/make/mapfiles/libjvm_dtrace/mapfile-vers, \
 180         OBJECT_DIR := $(LIBJVM_DTRACE_OUTPUTDIR)/objs, \
 181     ))
 182 
 183     LIBJVM_DB_OUTPUTDIR := $(JVM_VARIANT_OUTPUTDIR)/libjvm_db
 184 
 185     # Note that libjvm_db.c has tests for COMPILER2, but this was never set by
 186     # the old build.
 187     $(eval $(call SetupNativeCompilation, BUILD_LIBJVM_DB, \
 188         NAME := jvm_db, \
 189         OUTPUT_DIR := $(JVM_LIB_OUTPUTDIR), \
 190         SRC := $(TOPDIR)/src/java.base/solaris/native/libjvm_db, \
 191         CFLAGS := -I$(JVM_VARIANT_OUTPUTDIR)/gensrc -I$(DTRACE_SUPPORT_DIR) \
 192             -m64 -G -mt -KPIC, \
 193         LDFLAGS := -m64 -mt -xnolib $(SHARED_LIBRARY_FLAGS), \
 194         MAPFILE := $(TOPDIR)/make/mapfiles/libjvm_db/mapfile-vers, \
 195         OBJECT_DIR := $(LIBJVM_DB_OUTPUTDIR)/objs, \
 196     ))
 197 
 198     # We need the generated JvmOffsets.h before we can compile the libjvm_db source code.
 199     $(BUILD_LIBJVM_DB_ALL_OBJS): $(JVM_OFFSETS_H)
 200 
 201     TARGETS += $(BUILD_LIBJVM_DTRACE) $(BUILD_LIBJVM_DB)
 202   endif
 203 endif


   6 # under the terms of the GNU General Public License version 2 only, as
   7 # published by the Free Software Foundation.  Oracle designates this
   8 # particular file as subject to the "Classpath" exception as provided
   9 # by Oracle in the LICENSE file that accompanied this code.
  10 #
  11 # This code is distributed in the hope that it will be useful, but WITHOUT
  12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14 # version 2 for more details (a copy is included in the LICENSE file that
  15 # accompanied this code).
  16 #
  17 # You should have received a copy of the GNU General Public License version
  18 # 2 along with this work; if not, write to the Free Software Foundation,
  19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20 #
  21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22 # or visit www.oracle.com if you need additional information or have any
  23 # questions.
  24 #
  25 




  26 ifeq ($(call check-jvm-feature, dtrace), true)


  27   ifeq ($(OPENJDK_TARGET_OS), solaris)
  28 
  29     ############################################################################
  30     # Integrate with libjvm. Here we generate two object files which are
  31     # linked with libjvm.so. This step is complicated from a dependency
  32     # perspective. We add these two files to the linking of libjvm using
  33     # EXTRA_OBJECT_FILES, but they need to be created outside the call to
  34     # SetupNativeCompilation. Also, one of the files is dependent on compiled
  35     # object files from the libjvm compilation, so this generation must happen
  36     # as a part of the libjvm compilation.
  37 
  38     # These files are are generated by CompileDtracePostJvm.gmk but consumed by
  39     # CompileJvm.gmk
  40     DTRACE_OBJ := $(JVM_OUTPUTDIR)/objs/dtrace.o
  41     DTRACE_JHELPER_OBJ := $(JVM_OUTPUTDIR)/objs/dtrace_jhelper.o
  42 
  43     DTRACE_EXTRA_OBJECT_FILES := $(DTRACE_OBJ) $(DTRACE_JHELPER_OBJ)
































  44 
  45     ############################################################################
  46     # Generate DTRACE_OBJ which is linked with libjvm.so. It depends on a set of
  47     # object files from the compilation.
  48 
  49     # Concatenate all *.d files into a single file
  50     DTRACE_SOURCE_FILES := $(addprefix $(TOPDIR)/src/hotspot/os/posix/dtrace/, \
  51         hotspot_jni.d \
  52         hotspot.d \
  53         hs_private.d \
  54     )
  55 
  56     $(JVM_OUTPUTDIR)/objs/dtrace.d: $(DTRACE_SOURCE_FILES)
  57         $(call LogInfo, Generating $(@F))
  58         $(call MakeDir, $(@D))
  59         $(CAT) $^ > $@
  60 
  61     DTRACE_INSTRUMENTED_OBJS := $(addprefix $(JVM_OUTPUTDIR)/objs/, \
  62         ciEnv.o \
  63         classLoadingService.o \
  64         compileBroker.o \
  65         hashtable.o \
  66         instanceKlass.o \
  67         java.o \


  85           vmPSOperations.o \
  86       )
  87     endif
  88 
  89     DTRACE_FLAGS := -64 -G
  90     DTRACE_CPP_FLAGS := -D_LP64
  91 
  92     # Make sure we run our selected compiler for preprocessing instead of letting
  93     # the dtrace tool pick it on it's own.
  94     $(DTRACE_OBJ): $(JVM_OUTPUTDIR)/objs/dtrace.d $(DTRACE_INSTRUMENTED_OBJS)
  95         $(call LogInfo, Generating $(@F) from $(<F) and object files)
  96         $(call MakeDir, $(DTRACE_SUPPORT_DIR))
  97         $(call ExecuteWithLog, $(DTRACE_SUPPORT_DIR)/$(@F).d, \
  98             ($(CPP) $(DTRACE_CPP_FLAGS) $< > $(DTRACE_SUPPORT_DIR)/$(@F).d))
  99         $(call ExecuteWithLog, $@, $(DTRACE) $(DTRACE_FLAGS) -xlazyload -o $@ \
 100             -s $(DTRACE_SUPPORT_DIR)/$(@F).d $(sort $(DTRACE_INSTRUMENTED_OBJS)))
 101 
 102     ############################################################################
 103     # Generate DTRACE_JHELPER_OBJ which is linked with libjvm.so.
 104 
 105     JHELPER_DTRACE_SRC := $(TOPDIR)/src/hotspot/os/solaris/dtrace/jhelper.d
 106 
 107     # jhelper.d includes JvmOffsetsIndex.h which was created by the gensrc step.
 108     DTRACE_GENSRC_DIR := $(JVM_VARIANT_OUTPUTDIR)/gensrc/dtracefiles
 109     JVM_OFFSETS_INDEX_H := $(DTRACE_GENSRC_DIR)/JvmOffsetsIndex.h
 110 
 111     # Unfortunately dtrace generates incorrect types for some symbols in
 112     # dtrace_jhelper.o, resulting in "warning: symbol X has differing types"
 113     # See JDK-6890703 for details.
 114     # We work around this by fixing the types for these symbols using elfedit,
 115     # after dtrace has generated the .o file.


 116     GetElfeditCommands = \
 117       $(foreach symbol, \
 118           $(shell $(GREP) ^extern $(JHELPER_DTRACE_SRC) | $(AWK) '{ gsub(";","") ; print $$3 }'), \
 119           -e 'sym:st_type $(symbol) 1')
 120 
 121     # Make sure we run our selected compiler for preprocessing instead of letting
 122     # the dtrace tool pick it on it's own.
 123     $(DTRACE_JHELPER_OBJ): $(JHELPER_DTRACE_SRC) $(JVM_OFFSETS_INDEX_H)
 124         $(call LogInfo, Running dtrace for $(<F))
 125         $(call MakeDir, $(DTRACE_SUPPORT_DIR))
 126         $(call ExecuteWithLog, $(DTRACE_SUPPORT_DIR)/$(@F).d, \
 127             ($(CPP) $(DTRACE_CPP_FLAGS) -I$(DTRACE_GENSRC_DIR) $^ \
 128             > $(DTRACE_SUPPORT_DIR)/$(@F).d))
 129         $(call ExecuteWithLog, $@, $(DTRACE) $(DTRACE_FLAGS) -o $@ \
 130             -s $(DTRACE_SUPPORT_DIR)/$(@F).d)
 131         ifeq ($(OPENJDK_TARGET_CPU_ARCH), sparc)
 132           $(call ExecuteWithLog, $@.elfedit, $(ELFEDIT) $(call GetElfeditCommands) $@)
 133         endif
 134 



































 135   endif
 136 endif
< prev index next >