Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf tools: Enable libtraceevent dynamic linking

Currently we support only static linking with kernel's libtraceevent
(tools/lib/traceevent). This patch adds libtraceevent package detection
and support to link perf with it dynamically.

The libtraceevent package status is displayed with:
$ make VF=1 LIBTRACEEVENT_DYNAMIC=1
...
... libtraceevent: [ on ]

Default behavior remains the same (static linking).

Committer testing:

$ make LIBTRACEEVENT_DYNAMIC=1 VF=1 O=/tmp/build/perf -C tools/perf install-bin |& grep traceevent
Makefile.config:1090: *** Error: No libtraceevent devel library found, please install libtraceevent-devel. Stop.
$

Signed-off-by: Michael Petlan <mpetlan@redhat.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
LPU-Reference: 20210428092023.4009-1-mpetlan@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Michael Petlan and committed by
Arnaldo Carvalho de Melo
56d32d4c 2750ce1d

+32 -2
+1
tools/build/Makefile.feature
··· 52 52 libpython-version \ 53 53 libslang \ 54 54 libslang-include-subdir \ 55 + libtraceevent \ 55 56 libcrypto \ 56 57 libunwind \ 57 58 pthread-attr-setaffinity-np \
+4
tools/build/feature/Makefile
··· 36 36 test-libpython-version.bin \ 37 37 test-libslang.bin \ 38 38 test-libslang-include-subdir.bin \ 39 + test-libtraceevent.bin \ 39 40 test-libcrypto.bin \ 40 41 test-libunwind.bin \ 41 42 test-libunwind-debug-frame.bin \ ··· 196 195 197 196 $(OUTPUT)test-libslang-include-subdir.bin: 198 197 $(BUILD) -lslang 198 + 199 + $(OUTPUT)test-libtraceevent.bin: 200 + $(BUILD) -ltraceevent 199 201 200 202 $(OUTPUT)test-libcrypto.bin: 201 203 $(BUILD) -lcrypto
+12
tools/build/feature/test-libtraceevent.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + #include <traceevent/trace-seq.h> 3 + 4 + int main(void) 5 + { 6 + int rv = 0; 7 + struct trace_seq s; 8 + trace_seq_init(&s); 9 + rv += !(s.state == TRACE_SEQ__GOOD); 10 + trace_seq_destroy(&s); 11 + return rv; 12 + }
+9
tools/perf/Makefile.config
··· 1079 1079 endif 1080 1080 endif 1081 1081 1082 + ifdef LIBTRACEEVENT_DYNAMIC 1083 + $(call feature_check,libtraceevent) 1084 + ifeq ($(feature-libtraceevent), 1) 1085 + EXTLIBS += -ltraceevent 1086 + else 1087 + dummy := $(error Error: No libtraceevent devel library found, please install libtraceevent-devel); 1088 + endif 1089 + endif 1090 + 1082 1091 # Among the variables below, these: 1083 1092 # perfexecdir 1084 1093 # perf_include_dir
+6 -2
tools/perf/Makefile.perf
··· 128 128 # 129 129 # Define BUILD_BPF_SKEL to enable BPF skeletons 130 130 # 131 + # Define LIBTRACEEVENT_DYNAMIC to enable libtraceevent dynamic linking 132 + # 131 133 132 134 # As per kernel Makefile, avoid funny character set dependencies 133 135 unexport LC_ALL ··· 312 310 313 311 LIBTRACEEVENT = $(TE_PATH)libtraceevent.a 314 312 export LIBTRACEEVENT 315 - 316 313 LIBTRACEEVENT_DYNAMIC_LIST = $(PLUGINS_PATH)libtraceevent-dynamic-list 317 314 318 315 # ··· 376 375 377 376 export PERL_PATH 378 377 379 - PERFLIBS = $(LIBAPI) $(LIBTRACEEVENT) $(LIBSUBCMD) $(LIBPERF) 378 + PERFLIBS = $(LIBAPI) $(LIBSUBCMD) $(LIBPERF) 380 379 ifndef NO_LIBBPF 381 380 ifndef LIBBPF_DYNAMIC 382 381 PERFLIBS += $(LIBBPF) 383 382 endif 383 + endif 384 + ifndef LIBTRACEEVENT_DYNAMIC 385 + PERFLIBS += $(LIBTRACEEVENT) 384 386 endif 385 387 386 388 # We choose to avoid "if .. else if .. else .. endif endif"