Skip to content

Commit

Permalink
build: Add dependency check for libtraceevent
Browse files Browse the repository at this point in the history
From now on, it'd use libtraceevent to trace kernel functions and
events.  The configure and uftrace version string will look like:

  $ ./configure
  uftrace detected system features:
  ...         prefix: /usr/local
  ...         libelf: [ on  ] - more flexible ELF data handling
  ...          libdw: [ on  ] - DWARF debug info support
  ...      libpython: [ on  ] - python tracing & scripting support
  ...      libluajit: [ OFF ] - luajit scripting support
  ...    libncursesw: [ on  ] - TUI support
  ...   cxa_demangle: [ on  ] - full demangler support with libstdc++
  ...     perf_event: [ on  ] - perf (PMU) event support
  ...       schedule: [ on  ] - scheduler event support
  ...       capstone: [ on  ] - full dynamic tracing support
  ...  libtraceevent: [ on  ] - kernel tracing support
  ...      libunwind: [ OFF ] - stacktrace support (optional for debugging)

  $ ./uftrace --version
  uftrace v0.14-57-geb66 ( x86_64 dwarf python3 tui perf sched dynamic kernel )

Note that the actual build still uses the old copy of libtraceevent in
our source tree.  It'll switch to the new one in the next patch.

Signed-off-by: Namhyung Kim <[email protected]>
  • Loading branch information
namhyung committed Oct 25, 2023
1 parent dab3092 commit 736c6a2
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 11 deletions.
3 changes: 3 additions & 0 deletions check-deps/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ CHECK_LIST += have_libdw
CHECK_LIST += have_libunwind
CHECK_LIST += have_libcapstone
CHECK_LIST += cc_has_minline_all_stringops
CHECK_LIST += have_libtraceevent

#
# This is needed for checking build dependency
Expand Down Expand Up @@ -51,6 +52,8 @@ LDFLAGS_have_libcapstone = $(shell pkg-config --libs capstone 2> /dev/null)
CFLAGS_have_libunwind = $(shell pkg-config --cflags libunwind 2> /dev/null)
LDFLAGS_have_libunwind = $(shell pkg-config --libs libunwind 2> /dev/null)
CFLAGS_cc_has_minline_all_stringops = -minline-all-stringops
CFLAGS_have_libtraceevent = $(shell pkg-config --cflags libtraceevent 2> /dev/null)
LDFLAGS_have_libtraceevent = $(shell pkg-config --libs libtraceevent 2> /dev/null)

check-build: $(CHECK_LIST)

Expand Down
7 changes: 7 additions & 0 deletions check-deps/Makefile.check
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,10 @@ endif
ifneq ($(wildcard $(objdir)/check-deps/cc_has_minline_all_stringops),)
LIB_CFLAGS += -minline-all-stringops
endif

ifneq ($(wildcard $(objdir)/check-deps/have_libtraceevent),)
COMMON_CFLAGS += -DHAVE_LIBTRACEEVENT
# Disable new libtraceevent until the kparser switches to new APIs
# COMMON_CFLAGS += $(shell pkg-config --cflags libtraceevent 2> /dev/null)
# COMMON_LDFLAGS += $(shell pkg-config --libs libtraceevent 2> /dev/null)
endif
11 changes: 11 additions & 0 deletions check-deps/__have_libtraceevent.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <event-parse.h>

int main(void)
{
struct tep_handle *tep;

tep = tep_alloc();
tep_free(tep);

return 0;
}
26 changes: 15 additions & 11 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ usage() {
--without-capstone build without libcapstone (even if found on the system)
--without-perf build without perf event (even if available)
--without-schedule build without scheduler event (even if available)
--without-libtraceevent
build without libtraceevent (even if found on the system)
--arch=<ARCH> set target architecture (default: system default arch)
e.g. x86_64, aarch64, i386, or arm
Expand Down Expand Up @@ -188,17 +190,18 @@ make -siC ${srcdir}/check-deps O=${objdir} check-build
for dep in $IGNORE; do
TARGET=
case "$dep" in
libelf) TARGET=have_libelf ;;
libdw) TARGET=have_libdw ;;
libpython*) TARGET='have_libpython*' ;;
libluajit*) TARGET=have_libluajit ;;
libncurse*) TARGET=have_libncurses ;;
libunwind) TARGET=have_libunwind ;;
libstdc++) TARGET=cxa_demangle ;;
capstone) TARGET=have_libcapstone ;;
perf*) TARGET=perf_clockid ;;
sched*) TARGET=perf_context_switch;;
*) ;;
libelf) TARGET=have_libelf ;;
libdw) TARGET=have_libdw ;;
libpython*) TARGET='have_libpython*' ;;
libluajit*) TARGET=have_libluajit ;;
libncurse*) TARGET=have_libncurses ;;
libunwind) TARGET=have_libunwind ;;
libstdc++) TARGET=cxa_demangle ;;
capstone) TARGET=have_libcapstone ;;
perf*) TARGET=perf_clockid ;;
sched*) TARGET=perf_context_switch;;
libtraceevent) TARGET=have_libtraceevent ;;
*) ;;
esac
if [ ! -z "$TARGET" ]; then
rm -f ${objdir}/check-deps/$TARGET
Expand Down Expand Up @@ -264,6 +267,7 @@ print_feature "cxa_demangle" "cxa_demangle" "full demangler support with libstdc
print_feature "perf_event" "perf_clockid" "perf (PMU) event support"
print_feature "schedule" "perf_context_switch" "scheduler event support"
print_feature "capstone" "have_libcapstone" "full dynamic tracing support"
print_feature "libtraceevent" "have_libtraceevent" "kernel tracing support"
print_feature "libunwind" "have_libunwind" "stacktrace support (optional for debugging)"

cat >$output <<EOF
Expand Down
5 changes: 5 additions & 0 deletions misc/install-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,36 @@ install_packages() {
apt-get install $OPT pandoc libdw-dev python3-dev libncursesw5-dev pkg-config
apt-get install $OPT libluajit-5.1-dev || true
apt-get install $OPT libcapstone-dev || true
apt-get install $OPT libtraceevent-dev || true
exit
;;
"fedora")
dnf install $OPT pandoc elfutils-devel python3-devel ncurses-devel pkgconf-pkg-config
dnf install $OPT luajit-devel || true
dnf install $OPT capstone-devel || true
dnf install $OPT libtraceevent-devel || true
exit
;;
"rhel" | "centos")
rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum install $OPT pandoc elfutils-devel python3-devel ncurses-devel pkgconfig
yum install $OPT luajit-devel || true
yum install $OPT capstone-devel || true
dnf install $OPT libtraceevent-devel || true
exit
;;
"arch" | "manjaro")
pacman $OPT -S pandoc libelf python3 ncurses pkgconf
pacman $OPT -S luajit || true
pacman $OPT -S capstone || true
pacman $OPT -S libtraceevent || true
exit
;;
"alpine")
apk add $OPT elfutils-dev python3-dev ncurses-dev pkgconf
apk add $OPT luajit-dev || true
apk add $OPT capstone-dev || true
apk add $OPT libtraceevent-dev || true
exit
;;
esac
Expand Down
3 changes: 3 additions & 0 deletions misc/version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ fi
if test -f ${SRCDIR}/check-deps/have_libcapstone; then
DEPS="${DEPS} dynamic"
fi
if test -f ${SRCDIR}/check-deps/have_libtraceevent; then
DEPS="${DEPS} kernel"
fi
if [ "x${DEPS}" != "x" ]; then
DEPS=" (${DEPS} )"
fi
Expand Down

0 comments on commit 736c6a2

Please sign in to comment.