author | ihse |
Mon, 05 Mar 2018 22:29:59 +0100 | |
branch | ihse-cflags-rewrite-branch |
changeset 56241 | 0b5822abe04a |
parent 56237 | 9ccbd02e0c2c |
child 56245 | d232728af5cf |
permissions | -rw-r--r-- |
37437 | 1 |
# |
49070
d7859531621b
8198751: Refactor SetupNativeCompilation to take NAME and TYPE
ihse
parents:
47217
diff
changeset
|
2 |
# Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. |
37437 | 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 |
|
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, \ |
|
49070
d7859531621b
8198751: Refactor SetupNativeCompilation to take NAME and TYPE
ihse
parents:
47217
diff
changeset
|
49 |
NAME := dtraceGenOffsets, \ |
d7859531621b
8198751: Refactor SetupNativeCompilation to take NAME and TYPE
ihse
parents:
47217
diff
changeset
|
50 |
TYPE := EXECUTABLE, \ |
47217 | 51 |
SRC := $(TOPDIR)/make/hotspot/src/native/dtrace, \ |
56213 | 52 |
TOOLCHAIN := $(TOOLCHAIN_BUILD), \ |
37437 | 53 |
LDFLAGS := -m64, \ |
56213 | 54 |
CFLAGS := -m64 $(JVM_CFLAGS), \ |
56222 | 55 |
DISABLED_WARNINGS_solstudio := hidef nokeyworddefine unknownpragma \ |
56237
9ccbd02e0c2c
Push wunreachable on solstudio down to where it belongs.
ihse
parents:
56236
diff
changeset
|
56 |
w_novirtualdescr doubunder wunreachable,, \ |
37437 | 57 |
OBJECT_DIR := $(JVM_VARIANT_OUTPUTDIR)/tools/dtrace-gen-offsets/objs, \ |
58 |
OUTPUT_DIR := $(JVM_VARIANT_OUTPUTDIR)/tools/dtrace-gen-offsets, \ |
|
59 |
)) |
|
60 |
||
61 |
DTRACE_GEN_OFFSETS_TOOL := $(BUILD_DTRACE_GEN_OFFSETS_TARGET) |
|
62 |
||
63 |
# Argument 1: Output filename |
|
64 |
# Argument 2: dtrace-gen-offset tool command line option |
|
65 |
define SetupDtraceOffsetsGeneration |
|
66 |
$1: $$(BUILD_DTRACE_GEN_OFFSETS) |
|
67 |
$$(call LogInfo, Generating dtrace $2 file $$(@F)) |
|
68 |
$$(call MakeDir, $$(@D)) |
|
56213 | 69 |
$$(call ExecuteWithLog, $$@, $$(DTRACE_GEN_OFFSETS_TOOL) -$$(strip $2) > $$@) |
37437 | 70 |
|
71 |
TARGETS += $1 |
|
72 |
endef |
|
73 |
||
74 |
JVM_OFFSETS_H := $(DTRACE_SUPPORT_DIR)/JvmOffsets.h |
|
75 |
JVM_OFFSETS_CPP := $(DTRACE_SUPPORT_DIR)/JvmOffsets.cpp |
|
76 |
JVM_OFFSETS_INDEX_H := $(DTRACE_SUPPORT_DIR)/JvmOffsetsIndex.h |
|
77 |
||
78 |
# Run the dtrace-gen-offset tool to generate these three files. |
|
56213 | 79 |
# The generated JvmOffsets.cpp is compiled with the rest of libjvm. |
37437 | 80 |
$(eval $(call SetupDtraceOffsetsGeneration, $(JVM_OFFSETS_H), header)) |
81 |
$(eval $(call SetupDtraceOffsetsGeneration, $(JVM_OFFSETS_INDEX_H), index)) |
|
82 |
$(eval $(call SetupDtraceOffsetsGeneration, $(JVM_OFFSETS_CPP), table)) |
|
83 |
||
84 |
############################################################################ |
|
85 |
# Generate DTRACE_OBJ which is linked with libjvm.so. |
|
86 |
||
87 |
# Concatenate all *.d files into a single file |
|
47217 | 88 |
DTRACE_SOURCE_FILES := $(addprefix $(TOPDIR)/src/hotspot/os/posix/dtrace/, \ |
37437 | 89 |
hotspot_jni.d \ |
90 |
hotspot.d \ |
|
91 |
hs_private.d \ |
|
92 |
) |
|
93 |
||
94 |
$(JVM_OUTPUTDIR)/objs/dtrace.d: $(DTRACE_SOURCE_FILES) |
|
95 |
$(call LogInfo, Generating $(@F)) |
|
96 |
$(call MakeDir, $(@D)) |
|
97 |
$(CAT) $^ > $@ |
|
98 |
||
99 |
DTRACE_INSTRUMENTED_OBJS := $(addprefix $(JVM_OUTPUTDIR)/objs/, \ |
|
100 |
ciEnv.o \ |
|
101 |
classLoadingService.o \ |
|
102 |
compileBroker.o \ |
|
103 |
hashtable.o \ |
|
104 |
instanceKlass.o \ |
|
105 |
java.o \ |
|
106 |
jni.o \ |
|
107 |
jvm.o \ |
|
108 |
memoryManager.o \ |
|
109 |
nmethod.o \ |
|
110 |
objectMonitor.o \ |
|
111 |
runtimeService.o \ |
|
112 |
sharedRuntime.o \ |
|
113 |
synchronizer.o \ |
|
114 |
thread.o \ |
|
115 |
unsafe.o \ |
|
116 |
vmThread.o \ |
|
117 |
vmGCOperations.o \ |
|
118 |
) |
|
119 |
||
120 |
ifeq ($(call check-jvm-feature, all-gcs), true) |
|
121 |
DTRACE_INSTRUMENTED_OBJS += $(addprefix $(JVM_OUTPUTDIR)/objs/, \ |
|
122 |
vmCMSOperations.o \ |
|
123 |
vmPSOperations.o \ |
|
124 |
) |
|
125 |
endif |
|
126 |
||
127 |
DTRACE_FLAGS := -64 -G |
|
128 |
DTRACE_CPP_FLAGS := -D_LP64 |
|
129 |
||
130 |
# Make sure we run our selected compiler for preprocessing instead of letting |
|
131 |
# the dtrace tool pick it on it's own. |
|
132 |
$(DTRACE_OBJ): $(JVM_OUTPUTDIR)/objs/dtrace.d $(DTRACE_INSTRUMENTED_OBJS) |
|
133 |
$(call LogInfo, Generating $(@F) from $(<F) and object files) |
|
134 |
$(call MakeDir, $(DTRACE_SUPPORT_DIR)) |
|
56213 | 135 |
$(call ExecuteWithLog, $(DTRACE_SUPPORT_DIR)/$(@F).d, $(CPP) \ |
37437 | 136 |
$(DTRACE_CPP_FLAGS) $< > $(DTRACE_SUPPORT_DIR)/$(@F).d) |
137 |
$(call ExecuteWithLog, $@, $(DTRACE) $(DTRACE_FLAGS) -xlazyload -o $@ \ |
|
138 |
-s $(DTRACE_SUPPORT_DIR)/$(@F).d $(sort $(DTRACE_INSTRUMENTED_OBJS))) |
|
139 |
||
140 |
############################################################################ |
|
141 |
# Generate DTRACE_JHELPER_OBJ which is linked with libjvm.so. |
|
142 |
||
143 |
# Unfortunately dtrace generates incorrect types for some symbols in |
|
144 |
# dtrace_jhelper.o, resulting in "warning: symbol X has differing types" |
|
49078
039e63e471e1
8198859: Use elfedit to silence linker warnings on solaris
ihse
parents:
49070
diff
changeset
|
145 |
# See JDK-6890703 for details. |
039e63e471e1
8198859: Use elfedit to silence linker warnings on solaris
ihse
parents:
49070
diff
changeset
|
146 |
# We work around this by fixing the types for these symbols using elfedit, |
039e63e471e1
8198859: Use elfedit to silence linker warnings on solaris
ihse
parents:
49070
diff
changeset
|
147 |
# after dtrace has generated the .o file. |
039e63e471e1
8198859: Use elfedit to silence linker warnings on solaris
ihse
parents:
49070
diff
changeset
|
148 |
JHELPER_DTRACE_SRC := $(TOPDIR)/src/hotspot/os/solaris/dtrace/jhelper.d |
039e63e471e1
8198859: Use elfedit to silence linker warnings on solaris
ihse
parents:
49070
diff
changeset
|
149 |
DTRACE_EXTERNAL_SYMBOLS := $(shell $(GREP) ^extern $(JHELPER_DTRACE_SRC) | $(AWK) '{ gsub(";","") ; print $$3 }') |
039e63e471e1
8198859: Use elfedit to silence linker warnings on solaris
ihse
parents:
49070
diff
changeset
|
150 |
DTRACE_ELFEDIT_COMMANDS := $(foreach symbol, $(DTRACE_EXTERNAL_SYMBOLS), \ |
039e63e471e1
8198859: Use elfedit to silence linker warnings on solaris
ihse
parents:
49070
diff
changeset
|
151 |
-e 'sym:st_type $(symbol) 1') |
56213 | 152 |
# |
153 |
# Make sure we run our selected compiler for preprocessing instead of letting |
|
154 |
# the dtrace tool pick it on it's own. |
|
49078
039e63e471e1
8198859: Use elfedit to silence linker warnings on solaris
ihse
parents:
49070
diff
changeset
|
155 |
$(DTRACE_JHELPER_OBJ): $(JHELPER_DTRACE_SRC) $(JVM_OFFSETS_INDEX_H) |
37437 | 156 |
$(call LogInfo, Running dtrace for $(<F)) |
56213 | 157 |
$(call MakeDir, $(DTRACE_SUPPORT_DIR)) |
158 |
$(call ExecuteWithLog, $(DTRACE_SUPPORT_DIR)/$(@F).d, $(CPP) \ |
|
159 |
$(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) |
|
49078
039e63e471e1
8198859: Use elfedit to silence linker warnings on solaris
ihse
parents:
49070
diff
changeset
|
163 |
$(call ExecuteWithLog, $@.elfedit, $(ELFEDIT) $(DTRACE_ELFEDIT_COMMANDS) $@) |
37437 | 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, \ |
|
49070
d7859531621b
8198751: Refactor SetupNativeCompilation to take NAME and TYPE
ihse
parents:
47217
diff
changeset
|
171 |
NAME := jvm_dtrace, \ |
41277 | 172 |
OUTPUT_DIR := $(JVM_LIB_OUTPUTDIR), \ |
47217 | 173 |
SRC := $(TOPDIR)/src/java.base/solaris/native/libjvm_dtrace, \ |
37437 | 174 |
CFLAGS := -m64 -G -mt -KPIC, \ |
175 |
LDFLAGS := -m64 -mt -xnolib $(SHARED_LIBRARY_FLAGS), \ |
|
176 |
LIBS := $(LIBDL) -lc -lthread -ldoor, \ |
|
47217 | 177 |
MAPFILE := $(TOPDIR)/make/mapfiles/libjvm_dtrace/mapfile-vers, \ |
37437 | 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 |
|
184 |
# the old build. |
|
185 |
$(eval $(call SetupNativeCompilation, BUILD_LIBJVM_DB, \ |
|
49070
d7859531621b
8198751: Refactor SetupNativeCompilation to take NAME and TYPE
ihse
parents:
47217
diff
changeset
|
186 |
NAME := jvm_db, \ |
41277 | 187 |
OUTPUT_DIR := $(JVM_LIB_OUTPUTDIR), \ |
47217 | 188 |
SRC := $(TOPDIR)/src/java.base/solaris/native/libjvm_db, \ |
37437 | 189 |
CFLAGS := -I$(JVM_VARIANT_OUTPUTDIR)/gensrc -I$(DTRACE_SUPPORT_DIR) \ |
190 |
-m64 -G -mt -KPIC, \ |
|
191 |
LDFLAGS := -m64 -mt -xnolib $(SHARED_LIBRARY_FLAGS), \ |
|
192 |
LIBS := -lc, \ |
|
47217 | 193 |
MAPFILE := $(TOPDIR)/make/mapfiles/libjvm_db/mapfile-vers, \ |
37437 | 194 |
OBJECT_DIR := $(LIBJVM_DB_OUTPUTDIR)/objs, \ |
195 |
)) |
|
196 |
||
197 |
# We need the generated JvmOffsets.h before we can compile the libjvm_db source code. |
|
198 |
$(BUILD_LIBJVM_DB_ALL_OBJS): $(JVM_OFFSETS_H) |
|
199 |
||
200 |
TARGETS += $(BUILD_LIBJVM_DTRACE) $(BUILD_LIBJVM_DB) |
|
201 |
endif |
|
202 |
endif |