Skip to content

Commit

Permalink
build: fix detection of USDT support on macOS and generate probes.h
Browse files Browse the repository at this point in the history
- Partially revert bitcoin#22238 as after the macOS USDT support, just checking
for the `sys/sdt.h` header is enough.
- Generate `util/probes.h` during build time when supported.
  • Loading branch information
kouloumos committed Jul 6, 2022
1 parent b4d4a42 commit 72ede09
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ libtool
src/config/bitcoin-config.h
src/config/bitcoin-config.h.in
src/config/stamp-h1
src/util/probes.h
src/obj
share/setup.nsi
share/qt/Info.plist
Expand Down
30 changes: 22 additions & 8 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1385,14 +1385,28 @@ fi

if test "$use_usdt" != "no"; then
AC_MSG_CHECKING([whether Userspace, Statically Defined Tracing tracepoints are supported])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM(
[#include <sys/sdt.h>],
[DTRACE_PROBE("context", "event");]
)],
[AC_MSG_RESULT([yes]); AC_DEFINE([ENABLE_TRACING], [1], [Define to 1 to enable tracepoints for Userspace, Statically Defined Tracing])],
[AC_MSG_RESULT([no]); use_usdt=no;]
)
AC_CHECK_HEADER([sys/sdt.h], [use_usdt=yes], [use_usdt=no])
else
use_usdt=no
fi

dnl Check for dtrace(1)
if test x$use_usdt = xyes; then
AC_PATH_PROG([DTRACE], [dtrace])
if test "$TARGET_OS" = "darwin"; then
dnl USDT is only supported on darwin if dtrace exists
if test -n "$DTRACE"; then
AM_CONDITIONAL([HAVE_DTRACE], [test -n "$DTRACE"])
else
use_usdt=no
fi
else
AM_CONDITIONAL([HAVE_DTRACE], [test -n "$DTRACE"])
fi
fi

if test x$use_usdt = xyes; then
AC_DEFINE([ENABLE_TRACING], [1], [Define to 1 to enable tracepoints for Userspace, Statically Defined Tracing])
fi
AM_CONDITIONAL([ENABLE_USDT_TRACEPOINTS], [test "$use_usdt" = "yes"])

Expand Down
8 changes: 8 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,13 @@ BITCOIN_CORE_H = \
zmq/zmqrpc.h \
zmq/zmqutil.h

if HAVE_DTRACE
util/probes.h: util/probes.d
$(AM_V_GEN) $(DTRACE) -h -s $< -o $@

BUILT_SOURCES = util/probes.h
BITCOIN_CORE_H += util/probes.h
endif

obj/build.h: FORCE
@$(MKDIR_P) $(builddir)/obj
Expand Down Expand Up @@ -979,6 +986,7 @@ CLEANFILES += wallet/*.gcda wallet/*.gcno
CLEANFILES += wallet/test/*.gcda wallet/test/*.gcno
CLEANFILES += zmq/*.gcda zmq/*.gcno
CLEANFILES += obj/build.h
CLEANFILES += util/probes.h

EXTRA_DIST = $(CTAES_DIST)

Expand Down

0 comments on commit 72ede09

Please sign in to comment.