Commit 5dab5442 authored by Ben Gamari's avatar Ben Gamari 🐢

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
parent fd8b044e
......@@ -794,7 +794,9 @@ dnl ** check for dtrace (currently only implemented for Mac OS X)
HaveDtrace=NO
AC_PATH_PROG(DtraceCmd,dtrace)
if test -n "$DtraceCmd"; then
if test "x$TargetOS_CPP-$TargetVendor_CPP" = "xdarwin-apple" -o "x$TargetOS_CPP-$TargetVendor_CPP" = "xsolaris2-unknown"; then
if test "x$TargetOS_CPP-$TargetVendor_CPP" = "xdarwin-apple" \
-o "x$TargetOS_CPP-$TargetVendor_CPP" = "xfreebsd-portbld" \
-o "x$TargetOS_CPP-$TargetVendor_CPP" = "xsolaris2-unknown"; then
HaveDtrace=YES
fi
fi
......
......@@ -12,6 +12,13 @@
# endif
#endif
#if defined(__FreeBSD__)
/* we need this otherwise dtrace complains about redeclared int types
* TODO: find a better way to do this
*/
#define _INTTYPES_H_
#endif
#include "HsFFI.h"
#include "rts/EventLogFormat.h"
......
......@@ -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"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment