make/hotspot/lib/CompileDtracePostJvm.gmk
changeset 49124 6abbc1f5c2a1
parent 49078 039e63e471e1
child 49157 2478f56cf409
--- a/make/hotspot/lib/CompileDtracePostJvm.gmk	Fri Mar 02 18:08:50 2018 -0500
+++ b/make/hotspot/lib/CompileDtracePostJvm.gmk	Sat Mar 03 08:39:08 2018 +0100
@@ -49,13 +49,9 @@
         NAME := dtraceGenOffsets, \
         TYPE := EXECUTABLE, \
         SRC := $(TOPDIR)/make/hotspot/src/native/dtrace, \
-        CC := $(BUILD_CXX), \
-        CXX := $(BUILD_CXX), \
-        LDEXE := $(BUILD_CXX), \
-        generateJvmOffsets.cpp_CXXFLAGS := $(JVM_CFLAGS) -mt -xnolib -norunpath, \
-        generateJvmOffsetsMain.c_CFLAGS := -mt -m64 -norunpath -z nodefs, \
+        TOOLCHAIN := $(TOOLCHAIN_BUILD), \
         LDFLAGS := -m64, \
-        LIBS := -lc, \
+        CFLAGS := -m64 $(JVM_CFLAGS), \
         OBJECT_DIR := $(JVM_VARIANT_OUTPUTDIR)/tools/dtrace-gen-offsets/objs, \
         OUTPUT_DIR := $(JVM_VARIANT_OUTPUTDIR)/tools/dtrace-gen-offsets, \
     ))
@@ -78,25 +74,12 @@
     JVM_OFFSETS_INDEX_H := $(DTRACE_SUPPORT_DIR)/JvmOffsetsIndex.h
 
     # Run the dtrace-gen-offset tool to generate these three files.
+    # The generated JvmOffsets.cpp is compiled with the rest of libjvm.
     $(eval $(call SetupDtraceOffsetsGeneration, $(JVM_OFFSETS_H), header))
     $(eval $(call SetupDtraceOffsetsGeneration, $(JVM_OFFSETS_INDEX_H), index))
     $(eval $(call SetupDtraceOffsetsGeneration, $(JVM_OFFSETS_CPP), table))
 
     ############################################################################
-    # Compile JVM_OFFSETS_OBJ which is linked with libjvm.so.
-
-    # JvmOffsets.cpp is compiled without the common JVM_CFLAGS. Otherwise, the
-    # natural way would have been to included this source code in BUILD_LIBJVM.
-    JVM_OFFSETS_CFLAGS := -m64
-    ifeq ($(OPENJDK_TARGET_CPU), sparcv9)
-      JVM_OFFSETS_CFLAGS += -xarch=sparc
-    endif
-
-    $(JVM_OFFSETS_OBJ): $(JVM_OFFSETS_CPP) $(JVM_OFFSETS_H)
-	$(call LogInfo, Compiling dtrace file JvmOffsets.cpp (for libjvm.so))
-	$(call ExecuteWithLog, $@, $(CXX) -c -I$(<D) -o $@ $(JVM_OFFSETS_CFLAGS) $<)
-
-    ############################################################################
     # Generate DTRACE_OBJ which is linked with libjvm.so.
 
     # Concatenate all *.d files into a single file
@@ -147,8 +130,8 @@
     $(DTRACE_OBJ): $(JVM_OUTPUTDIR)/objs/dtrace.d $(DTRACE_INSTRUMENTED_OBJS)
 	$(call LogInfo, Generating $(@F) from $(<F) and object files)
 	$(call MakeDir, $(DTRACE_SUPPORT_DIR))
-	$(call ExecuteWithLog, $(DTRACE_SUPPORT_DIR)/$(@F).d, $(CC) -E \
-	    $(DTRACE_CPP_FLAGS) $< > $(DTRACE_SUPPORT_DIR)/$(@F).d)
+	$(call ExecuteWithLog, $(DTRACE_SUPPORT_DIR)/$(@F).d, \
+	    ($(CPP) $(DTRACE_CPP_FLAGS) $< > $(DTRACE_SUPPORT_DIR)/$(@F).d))
 	$(call ExecuteWithLog, $@, $(DTRACE) $(DTRACE_FLAGS) -xlazyload -o $@ \
 	    -s $(DTRACE_SUPPORT_DIR)/$(@F).d $(sort $(DTRACE_INSTRUMENTED_OBJS)))
 
@@ -161,15 +144,23 @@
     # We work around this by fixing the types for these symbols using elfedit,
     # after dtrace has generated the .o file.
     JHELPER_DTRACE_SRC := $(TOPDIR)/src/hotspot/os/solaris/dtrace/jhelper.d
-    DTRACE_EXTERNAL_SYMBOLS := $(shell $(GREP) ^extern $(JHELPER_DTRACE_SRC) | $(AWK) '{ gsub(";","") ; print $$3 }')
-    DTRACE_ELFEDIT_COMMANDS := $(foreach symbol, $(DTRACE_EXTERNAL_SYMBOLS), \
-      -e 'sym:st_type $(symbol) 1')
 
+    GetElfeditCommands = \
+      $(foreach symbol, \
+          $(shell $(GREP) ^extern $(JHELPER_DTRACE_SRC) | $(AWK) '{ gsub(";","") ; print $$3 }'), \
+          -e 'sym:st_type $(symbol) 1')
+
+    # Make sure we run our selected compiler for preprocessing instead of letting
+    # the dtrace tool pick it on it's own.
     $(DTRACE_JHELPER_OBJ): $(JHELPER_DTRACE_SRC) $(JVM_OFFSETS_INDEX_H)
 	$(call LogInfo, Running dtrace for $(<F))
-	$(call ExecuteWithLog, $@, $(DTRACE) $(DTRACE_FLAGS) $(DTRACE_CPP_FLAGS) -C \
-	    -I$(DTRACE_SUPPORT_DIR) -o $@ -s $<)
-	$(call ExecuteWithLog, $@.elfedit, $(ELFEDIT) $(DTRACE_ELFEDIT_COMMANDS) $@)
+	$(call MakeDir, $(DTRACE_SUPPORT_DIR))
+	$(call ExecuteWithLog, $(DTRACE_SUPPORT_DIR)/$(@F).d, \
+	    ($(CPP) $(DTRACE_CPP_FLAGS) -I$(DTRACE_SUPPORT_DIR) $^ \
+	    > $(DTRACE_SUPPORT_DIR)/$(@F).d))
+	$(call ExecuteWithLog, $@, $(DTRACE) $(DTRACE_FLAGS) -o $@ \
+	    -s $(DTRACE_SUPPORT_DIR)/$(@F).d)
+	$(call ExecuteWithLog, $@.elfedit, $(ELFEDIT) $(call GetElfeditCommands) $@)
 
     ############################################################################
     # Build the stand-alone dtrace libraries