summaryrefslogtreecommitdiff
path: root/rts/ghc.mk
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2017-10-16 15:27:48 -0400
committerBen Gamari <ben@smart-cactus.org>2017-10-16 17:24:49 -0400
commit5dab54428229a8d4f1658c4ad94f616b211851fe (patch)
tree41706e019d2afef2bde44261c32622a1ab8c39a5 /rts/ghc.mk
parentfd8b044e9664181d4815e48e8f83be78bc9fe8d2 (diff)
downloadhaskell-5dab54428229a8d4f1658c4ad94f616b211851fe.tar.gz
FreeBSD dtrace probe support
Reviewers: austin, hvr, erikd, simonmar, bgamari Reviewed By: bgamari Subscribers: snowleopard, raichoo, rwbarton, thomie, erikd Differential Revision: https://phabricator.haskell.org/D3994
Diffstat (limited to 'rts/ghc.mk')
-rw-r--r--rts/ghc.mk40
1 files changed, 33 insertions, 7 deletions
diff --git a/rts/ghc.mk b/rts/ghc.mk
index 924a048552..57db2970da 100644
--- a/rts/ghc.mk
+++ b/rts/ghc.mk
@@ -134,6 +134,13 @@ endif
endif
endif
+
+ifeq "$(USE_DTRACE)" "YES"
+ifneq "$(findstring $(TargetOS_CPP), linux solaris2 freebsd)" ""
+NEED_DTRACE_PROBES_OBJ = YES
+endif
+endif
+
#-----------------------------------------------------------------------------
# Building one way
define build-rts-way # args: $1 = way
@@ -170,10 +177,6 @@ rts_$1_CMM_OBJS = $$(patsubst rts/%.cmm,rts/dist/build/%.$$($1_osuf),$$(rts_CMM_
rts_$1_OBJS = $$(rts_$1_C_OBJS) $$(rts_$1_S_OBJS) $$(rts_$1_CMM_OBJS)
-ifneq "$$(findstring linux solaris2, $(TargetOS_CPP))" ""
-NEED_DTRACE_PROBES_OBJ = YES
-endif
-
ifeq "$(USE_DTRACE)" "YES"
ifeq "$(NEED_DTRACE_PROBES_OBJ)" "YES"
# On Darwin we don't need to generate binary containing probes defined
@@ -181,7 +184,7 @@ ifeq "$(NEED_DTRACE_PROBES_OBJ)" "YES"
# from the DTrace probes definitions
rts_$1_DTRACE_OBJS = rts/dist/build/RtsProbes.$$($1_osuf)
-rts/dist/build/RtsProbes.$$($1_osuf) : $$(rts_$1_OBJS)
+$$(rts_$1_DTRACE_OBJS) : $$(rts_$1_OBJS)
$(DTRACE) -G -C $$(addprefix -I,$$(GHC_INCLUDE_DIRS)) -DDTRACE -s rts/RtsProbes.d -o \
$$@ $$(rts_$1_OBJS)
endif
@@ -248,9 +251,32 @@ $$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS) rts/dist/libs.depend $$(
$$(rts_$1_DTRACE_OBJS) -o $$@
endif
else
-$$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS)
+
+ifeq "$(USE_DTRACE)" "YES"
+ifeq "$(NEED_DTRACE_PROBES_OBJ)" "YES"
+rts_$1_LINKED_OBJS = rts/dist/build/RTS.$$($1_osuf)
+
+$$(rts_$1_LINKED_OBJS) : $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS)
+ "$$(RM)" $$(RM_OPTS) $$@
+
+ # When linking an archive the linker will only include the object files that
+ # are actually needed during linking. It therefore does not include the dtrace
+ # specific code for initializing the probes. By creating a single object that
+ # also includes the probe object code we force the linker to include the
+ # probes when linking the static runtime.
+ $(LD) -r -o $$(rts_$1_LINKED_OBJS) $$(rts_$1_DTRACE_OBJS) $$(rts_$1_OBJS)
+else
+rts_$1_LINKED_OBJS = $$(rts_$1_OBJS)
+endif
+else
+rts_$1_LINKED_OBJS = $$(rts_$1_OBJS)
+endif
+
+
+$$(rts_$1_LIB) : $$(rts_$1_LINKED_OBJS)
"$$(RM)" $$(RM_OPTS) $$@
- echo $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS) | "$$(XARGS)" $$(XARGS_OPTS) "$$(AR_STAGE1)" \
+
+ echo $$(rts_$1_LINKED_OBJS) | "$$(XARGS)" $$(XARGS_OPTS) "$$(AR_STAGE1)" \
$$(AR_OPTS_STAGE1) $$(EXTRA_AR_ARGS_STAGE1) $$@
ifneq "$$(UseSystemLibFFI)" "YES"