< prev index next >

make/hotspot/lib/CompileDtracePostJvm.gmk

Print this page


   1 #
   2 # Copyright (c) 2013, 2017, 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.  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


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


 161         $(JVM_OFFSETS_INDEX_H)
 162         $(call LogInfo, Running dtrace for $(<F))
 163         $(call ExecuteWithLog, $@, $(DTRACE) $(DTRACE_FLAGS) $(DTRACE_CPP_FLAGS) -C \
 164             -I$(DTRACE_SUPPORT_DIR) -o $@ -s $<)
 165 
 166     # NOTE: We should really do something like this, but unfortunately this
 167     # results in a compilation error. :-(
 168     # $(call MakeDir, $(DTRACE_SUPPORT_DIR))
 169     # $(call ExecuteWithLog, $(DTRACE_SUPPORT_DIR)/$(@F).d, $(CC) -E \
 170     #     $(DTRACE_CPP_FLAGS) -I$(DTRACE_SUPPORT_DIR) $^ \
 171     #     > $(DTRACE_SUPPORT_DIR)/$(@F).d)
 172     # $(call ExecuteWithLog, $@, $(DTRACE) $(DTRACE_FLAGS) -o $@ \
 173     #     -s $(DTRACE_SUPPORT_DIR)/$(@F).d)
 174 
 175     ############################################################################
 176     # Build the stand-alone dtrace libraries
 177 
 178     LIBJVM_DTRACE_OUTPUTDIR := $(JVM_VARIANT_OUTPUTDIR)/libjvm_dtrace
 179 
 180     $(eval $(call SetupNativeCompilation, BUILD_LIBJVM_DTRACE, \
 181         LIBRARY := jvm_dtrace, \
 182         OUTPUT_DIR := $(JVM_LIB_OUTPUTDIR), \
 183         SRC := $(TOPDIR)/src/java.base/solaris/native/libjvm_dtrace, \
 184         CFLAGS := -m64 -G -mt -KPIC, \
 185         LDFLAGS := -m64 -mt -xnolib $(SHARED_LIBRARY_FLAGS), \
 186         LIBS := $(LIBDL) -lc -lthread -ldoor, \
 187         MAPFILE := $(TOPDIR)/make/mapfiles/libjvm_dtrace/mapfile-vers, \
 188         OBJECT_DIR := $(LIBJVM_DTRACE_OUTPUTDIR)/objs, \
 189     ))
 190 
 191     LIBJVM_DB_OUTPUTDIR := $(JVM_VARIANT_OUTPUTDIR)/libjvm_db
 192 
 193     # Note that libjvm_db.c has tests for COMPILER2, but this was never set by
 194     # the old build.
 195     $(eval $(call SetupNativeCompilation, BUILD_LIBJVM_DB, \
 196         LIBRARY := jvm_db, \
 197         OUTPUT_DIR := $(JVM_LIB_OUTPUTDIR), \
 198         SRC := $(TOPDIR)/src/java.base/solaris/native/libjvm_db, \
 199         CFLAGS := -I$(JVM_VARIANT_OUTPUTDIR)/gensrc -I$(DTRACE_SUPPORT_DIR) \
 200             -m64 -G -mt -KPIC, \
 201         LDFLAGS := -m64 -mt -xnolib $(SHARED_LIBRARY_FLAGS), \
 202         LIBS := -lc, \
 203         MAPFILE := $(TOPDIR)/make/mapfiles/libjvm_db/mapfile-vers, \
 204         OBJECT_DIR := $(LIBJVM_DB_OUTPUTDIR)/objs, \
 205     ))
 206 
 207     # We need the generated JvmOffsets.h before we can compile the libjvm_db source code.
 208     $(BUILD_LIBJVM_DB_ALL_OBJS): $(JVM_OFFSETS_H)
 209 
 210     TARGETS += $(BUILD_LIBJVM_DTRACE) $(BUILD_LIBJVM_DB)
 211   endif
 212 endif
   1 #
   2 # Copyright (c) 2013, 2018, 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.  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


  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         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.


 162         $(JVM_OFFSETS_INDEX_H)
 163         $(call LogInfo, Running dtrace for $(<F))
 164         $(call ExecuteWithLog, $@, $(DTRACE) $(DTRACE_FLAGS) $(DTRACE_CPP_FLAGS) -C \
 165             -I$(DTRACE_SUPPORT_DIR) -o $@ -s $<)
 166 
 167     # NOTE: We should really do something like this, but unfortunately this
 168     # results in a compilation error. :-(
 169     # $(call MakeDir, $(DTRACE_SUPPORT_DIR))
 170     # $(call ExecuteWithLog, $(DTRACE_SUPPORT_DIR)/$(@F).d, $(CC) -E \
 171     #     $(DTRACE_CPP_FLAGS) -I$(DTRACE_SUPPORT_DIR) $^ \
 172     #     > $(DTRACE_SUPPORT_DIR)/$(@F).d)
 173     # $(call ExecuteWithLog, $@, $(DTRACE) $(DTRACE_FLAGS) -o $@ \
 174     #     -s $(DTRACE_SUPPORT_DIR)/$(@F).d)
 175 
 176     ############################################################################
 177     # Build the stand-alone dtrace libraries
 178 
 179     LIBJVM_DTRACE_OUTPUTDIR := $(JVM_VARIANT_OUTPUTDIR)/libjvm_dtrace
 180 
 181     $(eval $(call SetupNativeCompilation, BUILD_LIBJVM_DTRACE, \
 182         NAME := jvm_dtrace, \
 183         OUTPUT_DIR := $(JVM_LIB_OUTPUTDIR), \
 184         SRC := $(TOPDIR)/src/java.base/solaris/native/libjvm_dtrace, \
 185         CFLAGS := -m64 -G -mt -KPIC, \
 186         LDFLAGS := -m64 -mt -xnolib $(SHARED_LIBRARY_FLAGS), \
 187         LIBS := $(LIBDL) -lc -lthread -ldoor, \
 188         MAPFILE := $(TOPDIR)/make/mapfiles/libjvm_dtrace/mapfile-vers, \
 189         OBJECT_DIR := $(LIBJVM_DTRACE_OUTPUTDIR)/objs, \
 190     ))
 191 
 192     LIBJVM_DB_OUTPUTDIR := $(JVM_VARIANT_OUTPUTDIR)/libjvm_db
 193 
 194     # Note that libjvm_db.c has tests for COMPILER2, but this was never set by
 195     # the old build.
 196     $(eval $(call SetupNativeCompilation, BUILD_LIBJVM_DB, \
 197         NAME := jvm_db, \
 198         OUTPUT_DIR := $(JVM_LIB_OUTPUTDIR), \
 199         SRC := $(TOPDIR)/src/java.base/solaris/native/libjvm_db, \
 200         CFLAGS := -I$(JVM_VARIANT_OUTPUTDIR)/gensrc -I$(DTRACE_SUPPORT_DIR) \
 201             -m64 -G -mt -KPIC, \
 202         LDFLAGS := -m64 -mt -xnolib $(SHARED_LIBRARY_FLAGS), \
 203         LIBS := -lc, \
 204         MAPFILE := $(TOPDIR)/make/mapfiles/libjvm_db/mapfile-vers, \
 205         OBJECT_DIR := $(LIBJVM_DB_OUTPUTDIR)/objs, \
 206     ))
 207 
 208     # We need the generated JvmOffsets.h before we can compile the libjvm_db source code.
 209     $(BUILD_LIBJVM_DB_ALL_OBJS): $(JVM_OFFSETS_H)
 210 
 211     TARGETS += $(BUILD_LIBJVM_DTRACE) $(BUILD_LIBJVM_DB)
 212   endif
 213 endif
< prev index next >