make/hotspot/lib/CompileDtracePostJvm.gmk
branchihse-cflags-rewrite-branch
changeset 56231 66bf73fcdf4d
parent 47217 72e3ae9a25eb
child 56214 0544ba555e67
--- a/make/hotspot/lib/CompileDtracePostJvm.gmk	Wed Feb 28 20:59:50 2018 +0100
+++ b/make/hotspot/lib/CompileDtracePostJvm.gmk	Thu Mar 01 01:24:12 2018 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -47,13 +47,9 @@
     # this would preferrably have been done as a part of GensrcDtrace.gmk.
     $(eval $(call SetupNativeCompilation, BUILD_DTRACE_GEN_OFFSETS, \
         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, \
         PROGRAM := dtraceGenOffsets, \
@@ -67,7 +63,7 @@
       $1: $$(BUILD_DTRACE_GEN_OFFSETS)
 	$$(call LogInfo, Generating dtrace $2 file $$(@F))
 	$$(call MakeDir, $$(@D))
-	$$(call ExecuteWithLog, $$@, ( $$(DTRACE_GEN_OFFSETS_TOOL) -$$(strip $2) > $$@ ) )
+	$$(call ExecuteWithLog, $$@, $$(DTRACE_GEN_OFFSETS_TOOL) -$$(strip $2) > $$@)
 
       TARGETS += $1
     endef
@@ -77,25 +73,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
@@ -146,7 +129,7 @@
     $(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 \
+	$(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)))
@@ -157,20 +140,18 @@
     # Unfortunately dtrace generates incorrect types for some symbols in
     # dtrace_jhelper.o, resulting in "warning: symbol X has differing types"
     # This is tracked in JDK-6890703.
+    #
+    # Make sure we run our selected compiler for preprocessing instead of letting
+    # the dtrace tool pick it on it's own.
     $(DTRACE_JHELPER_OBJ): $(TOPDIR)/src/hotspot/os/solaris/dtrace/jhelper.d \
         $(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 $<)
-
-    # NOTE: We should really do something like this, but unfortunately this
-    # results in a compilation error. :-(
-    # $(call MakeDir, $(DTRACE_SUPPORT_DIR))
-    # $(call ExecuteWithLog, $(DTRACE_SUPPORT_DIR)/$(@F).d, $(CC) -E \
-    #     $(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 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)
 
     ############################################################################
     # Build the stand-alone dtrace libraries