< prev index next >

make/hotspot/lib/CompileDtracePostJvm.gmk

Print this page




  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         CC := $(BUILD_CXX), \
  53         CXX := $(BUILD_CXX), \
  54         LDEXE := $(BUILD_CXX), \
  55         generateJvmOffsets.cpp_CXXFLAGS := $(JVM_CFLAGS) -mt -xnolib -norunpath, \
  56         generateJvmOffsetsMain.c_CFLAGS := -mt -m64 -norunpath -z nodefs, \
  57         LDFLAGS := -m64, \
  58         LIBS := -lc, \
  59         OBJECT_DIR := $(JVM_VARIANT_OUTPUTDIR)/tools/dtrace-gen-offsets/objs, \
  60         OUTPUT_DIR := $(JVM_VARIANT_OUTPUTDIR)/tools/dtrace-gen-offsets, \
  61     ))
  62 
  63     DTRACE_GEN_OFFSETS_TOOL := $(BUILD_DTRACE_GEN_OFFSETS_TARGET)
  64 
  65     # Argument 1: Output filename
  66     # Argument 2: dtrace-gen-offset tool command line option
  67     define SetupDtraceOffsetsGeneration
  68       $1: $$(BUILD_DTRACE_GEN_OFFSETS)
  69         $$(call LogInfo, Generating dtrace $2 file $$(@F))
  70         $$(call MakeDir, $$(@D))
  71         $$(call ExecuteWithLog, $$@, ( $$(DTRACE_GEN_OFFSETS_TOOL) -$$(strip $2) > $$@ ) )
  72 
  73       TARGETS += $1
  74     endef
  75 
  76     JVM_OFFSETS_H := $(DTRACE_SUPPORT_DIR)/JvmOffsets.h
  77     JVM_OFFSETS_CPP := $(DTRACE_SUPPORT_DIR)/JvmOffsets.cpp
  78     JVM_OFFSETS_INDEX_H := $(DTRACE_SUPPORT_DIR)/JvmOffsetsIndex.h
  79 
  80     # Run the dtrace-gen-offset tool to generate these three files.

  81     $(eval $(call SetupDtraceOffsetsGeneration, $(JVM_OFFSETS_H), header))
  82     $(eval $(call SetupDtraceOffsetsGeneration, $(JVM_OFFSETS_INDEX_H), index))
  83     $(eval $(call SetupDtraceOffsetsGeneration, $(JVM_OFFSETS_CPP), table))
  84 
  85     ############################################################################
  86     # Compile JVM_OFFSETS_OBJ which is linked with libjvm.so.
  87 
  88     # JvmOffsets.cpp is compiled without the common JVM_CFLAGS. Otherwise, the
  89     # natural way would have been to included this source code in BUILD_LIBJVM.
  90     JVM_OFFSETS_CFLAGS := -m64
  91     ifeq ($(OPENJDK_TARGET_CPU), sparcv9)
  92       JVM_OFFSETS_CFLAGS += -xarch=sparc
  93     endif
  94 
  95     $(JVM_OFFSETS_OBJ): $(JVM_OFFSETS_CPP) $(JVM_OFFSETS_H)
  96         $(call LogInfo, Compiling dtrace file JvmOffsets.cpp (for libjvm.so))
  97         $(call ExecuteWithLog, $@, $(CXX) -c -I$(<D) -o $@ $(JVM_OFFSETS_CFLAGS) $<)
  98 
  99     ############################################################################
 100     # Generate DTRACE_OBJ which is linked with libjvm.so.
 101 
 102     # Concatenate all *.d files into a single file
 103     DTRACE_SOURCE_FILES := $(addprefix $(TOPDIR)/src/hotspot/os/posix/dtrace/, \
 104         hotspot_jni.d \
 105         hotspot.d \
 106         hs_private.d \
 107     )
 108 
 109     $(JVM_OUTPUTDIR)/objs/dtrace.d: $(DTRACE_SOURCE_FILES)
 110         $(call LogInfo, Generating $(@F))
 111         $(call MakeDir, $(@D))
 112         $(CAT) $^ > $@
 113 
 114     DTRACE_INSTRUMENTED_OBJS := $(addprefix $(JVM_OUTPUTDIR)/objs/, \
 115         ciEnv.o \
 116         classLoadingService.o \
 117         compileBroker.o \
 118         hashtable.o \
 119         instanceKlass.o \


 130         unsafe.o \
 131         vmThread.o \
 132         vmGCOperations.o \
 133     )
 134 
 135     ifeq ($(call check-jvm-feature, all-gcs), true)
 136       DTRACE_INSTRUMENTED_OBJS += $(addprefix $(JVM_OUTPUTDIR)/objs/, \
 137           vmCMSOperations.o \
 138           vmPSOperations.o \
 139       )
 140     endif
 141 
 142     DTRACE_FLAGS := -64 -G
 143     DTRACE_CPP_FLAGS := -D_LP64
 144 
 145     # Make sure we run our selected compiler for preprocessing instead of letting
 146     # the dtrace tool pick it on it's own.
 147     $(DTRACE_OBJ): $(JVM_OUTPUTDIR)/objs/dtrace.d $(DTRACE_INSTRUMENTED_OBJS)
 148         $(call LogInfo, Generating $(@F) from $(<F) and object files)
 149         $(call MakeDir, $(DTRACE_SUPPORT_DIR))
 150         $(call ExecuteWithLog, $(DTRACE_SUPPORT_DIR)/$(@F).d, $(CC) -E \
 151             $(DTRACE_CPP_FLAGS) $< > $(DTRACE_SUPPORT_DIR)/$(@F).d)
 152         $(call ExecuteWithLog, $@, $(DTRACE) $(DTRACE_FLAGS) -xlazyload -o $@ \
 153             -s $(DTRACE_SUPPORT_DIR)/$(@F).d $(sort $(DTRACE_INSTRUMENTED_OBJS)))
 154 
 155     ############################################################################
 156     # Generate DTRACE_JHELPER_OBJ which is linked with libjvm.so.
 157 
 158     # Unfortunately dtrace generates incorrect types for some symbols in
 159     # dtrace_jhelper.o, resulting in "warning: symbol X has differing types"
 160     # See JDK-6890703 for details.
 161     # We work around this by fixing the types for these symbols using elfedit,
 162     # after dtrace has generated the .o file.
 163     JHELPER_DTRACE_SRC := $(TOPDIR)/src/hotspot/os/solaris/dtrace/jhelper.d
 164     DTRACE_EXTERNAL_SYMBOLS := $(shell $(GREP) ^extern $(JHELPER_DTRACE_SRC) | $(AWK) '{ gsub(";","") ; print $$3 }')
 165     DTRACE_ELFEDIT_COMMANDS := $(foreach symbol, $(DTRACE_EXTERNAL_SYMBOLS), \


 166       -e 'sym:st_type $(symbol) 1')
 167 


 168     $(DTRACE_JHELPER_OBJ): $(JHELPER_DTRACE_SRC) $(JVM_OFFSETS_INDEX_H)
 169         $(call LogInfo, Running dtrace for $(<F))
 170         $(call ExecuteWithLog, $@, $(DTRACE) $(DTRACE_FLAGS) $(DTRACE_CPP_FLAGS) -C \
 171             -I$(DTRACE_SUPPORT_DIR) -o $@ -s $<)
 172         $(call ExecuteWithLog, $@.elfedit, $(ELFEDIT) $(DTRACE_ELFEDIT_COMMANDS) $@)




 173 
 174     ############################################################################
 175     # Build the stand-alone dtrace libraries
 176 
 177     LIBJVM_DTRACE_OUTPUTDIR := $(JVM_VARIANT_OUTPUTDIR)/libjvm_dtrace
 178 
 179     $(eval $(call SetupNativeCompilation, BUILD_LIBJVM_DTRACE, \
 180         NAME := jvm_dtrace, \
 181         OUTPUT_DIR := $(JVM_LIB_OUTPUTDIR), \
 182         SRC := $(TOPDIR)/src/java.base/solaris/native/libjvm_dtrace, \
 183         CFLAGS := -m64 -G -mt -KPIC, \
 184         LDFLAGS := -m64 -mt -xnolib $(SHARED_LIBRARY_FLAGS), \
 185         LIBS := $(LIBDL) -lc -lthread -ldoor, \
 186         MAPFILE := $(TOPDIR)/make/mapfiles/libjvm_dtrace/mapfile-vers, \
 187         OBJECT_DIR := $(LIBJVM_DTRACE_OUTPUTDIR)/objs, \
 188     ))
 189 
 190     LIBJVM_DB_OUTPUTDIR := $(JVM_VARIANT_OUTPUTDIR)/libjvm_db
 191 
 192     # Note that libjvm_db.c has tests for COMPILER2, but this was never set by


  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 \


 113         unsafe.o \
 114         vmThread.o \
 115         vmGCOperations.o \
 116     )
 117 
 118     ifeq ($(call check-jvm-feature, all-gcs), true)
 119       DTRACE_INSTRUMENTED_OBJS += $(addprefix $(JVM_OUTPUTDIR)/objs/, \
 120           vmCMSOperations.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         $(call ExecuteWithLog, $@.elfedit, $(ELFEDIT) $(call GetElfeditCommands) $@)
 164 
 165     ############################################################################
 166     # Build the stand-alone dtrace libraries
 167 
 168     LIBJVM_DTRACE_OUTPUTDIR := $(JVM_VARIANT_OUTPUTDIR)/libjvm_dtrace
 169 
 170     $(eval $(call SetupNativeCompilation, BUILD_LIBJVM_DTRACE, \
 171         NAME := jvm_dtrace, \
 172         OUTPUT_DIR := $(JVM_LIB_OUTPUTDIR), \
 173         SRC := $(TOPDIR)/src/java.base/solaris/native/libjvm_dtrace, \
 174         CFLAGS := -m64 -G -mt -KPIC, \
 175         LDFLAGS := -m64 -mt -xnolib $(SHARED_LIBRARY_FLAGS), \
 176         LIBS := $(LIBDL) -lc -lthread -ldoor, \
 177         MAPFILE := $(TOPDIR)/make/mapfiles/libjvm_dtrace/mapfile-vers, \
 178         OBJECT_DIR := $(LIBJVM_DTRACE_OUTPUTDIR)/objs, \
 179     ))
 180 
 181     LIBJVM_DB_OUTPUTDIR := $(JVM_VARIANT_OUTPUTDIR)/libjvm_db
 182 
 183     # Note that libjvm_db.c has tests for COMPILER2, but this was never set by
< prev index next >