diff options
author | Guilherme Amadio <amadio@gentoo.org> | 2024-06-06 17:33:01 +0200 |
---|---|---|
committer | Namhyung Kim <namhyung@kernel.org> | 2024-06-22 01:19:03 +0200 |
commit | 0f0e1f44569061e3dc590cd0b8cb74d8fd53706b (patch) | |
tree | 10dd5ce96d16e17f90e9c7cd8c5e79eac561ea7b | |
parent | perf arm: Workaround ARM PMUs cpu maps having offline cpus (diff) | |
download | linux-0f0e1f44569061e3dc590cd0b8cb74d8fd53706b.tar.xz linux-0f0e1f44569061e3dc590cd0b8cb74d8fd53706b.zip |
perf build: Use pkg-config for feature check for libtrace{event,fs}
Needed to add required include directories for the feature detection
to succeed. The header tracefs.h is installed either into the include
directory /usr/include/tracefs/tracefs.h when using the Makefile, or
into /usr/include/libtracefs/tracefs.h when using meson to build
libtracefs. The header tracefs.h uses #include <event-parse.h> from
libtraceevent, so pkg-config needs to pick the correct include directory
for libtracefs and add the one for libtraceevent to succeed.
Note that in baa2ca59ec1e31ccbe3f24ff0368152b36f68720 the variable
LIBTRACEEVENT_DIR was introduced, and now the method to compile against
non-standard locations requires PKG_CONFIG_PATH to be set instead, which
works for both libtraceevent and libtracefs.
Signed-off-by: Guilherme Amadio <amadio@gentoo.org>
Reviewed-by: Leo Yan <leo.yan@arm.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20240606153625.2255470-2-amadio@gentoo.org
-rw-r--r-- | tools/build/feature/test-libtracefs.c | 2 | ||||
-rw-r--r-- | tools/perf/Makefile.config | 27 |
2 files changed, 14 insertions, 15 deletions
diff --git a/tools/build/feature/test-libtracefs.c b/tools/build/feature/test-libtracefs.c index 8eff16c0c10b..29a757a7d848 100644 --- a/tools/build/feature/test-libtracefs.c +++ b/tools/build/feature/test-libtracefs.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -#include <tracefs/tracefs.h> +#include <tracefs.h> int main(void) { diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config index 7f1e016a9253..54a6c6bf23c7 100644 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config @@ -183,14 +183,12 @@ FEATURE_CHECK_CFLAGS-libzstd := $(LIBZSTD_CFLAGS) FEATURE_CHECK_LDFLAGS-libzstd := $(LIBZSTD_LDFLAGS) # for linking with debug library, run like: -# make DEBUG=1 LIBTRACEEVENT_DIR=/opt/libtraceevent/ -TRACEEVENTLIBS := -ltraceevent -ifdef LIBTRACEEVENT_DIR - LIBTRACEEVENT_CFLAGS := -I$(LIBTRACEEVENT_DIR)/include - LIBTRACEEVENT_LDFLAGS := -L$(LIBTRACEEVENT_DIR)/lib -endif -FEATURE_CHECK_CFLAGS-libtraceevent := $(LIBTRACEEVENT_CFLAGS) -FEATURE_CHECK_LDFLAGS-libtraceevent := $(LIBTRACEEVENT_LDFLAGS) $(TRACEEVENTLIBS) +# make DEBUG=1 PKG_CONFIG_PATH=/opt/libtraceevent/(lib|lib64)/pkgconfig +FEATURE_CHECK_CFLAGS-libtraceevent := $(shell $(PKG_CONFIG) --cflags libtraceevent) +FEATURE_CHECK_LDFLAGS-libtraceevent := $(shell $(PKG_CONFIG) --libs libtraceevent) + +FEATURE_CHECK_CFLAGS-libtracefs := $(shell $(PKG_CONFIG) --cflags libtracefs) +FEATURE_CHECK_LDFLAGS-libtracefs := $(shell $(PKG_CONFIG) --libs libtracefs) FEATURE_CHECK_CFLAGS-bpf = -I. -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi -I$(srctree)/tools/include/uapi # include ARCH specific config @@ -1178,10 +1176,10 @@ endif ifneq ($(NO_LIBTRACEEVENT),1) $(call feature_check,libtraceevent) ifeq ($(feature-libtraceevent), 1) - CFLAGS += -DHAVE_LIBTRACEEVENT $(LIBTRACEEVENT_CFLAGS) - LDFLAGS += $(LIBTRACEEVENT_LDFLAGS) - EXTLIBS += ${TRACEEVENTLIBS} - LIBTRACEEVENT_VERSION := $(shell PKG_CONFIG_PATH=$(LIBTRACEEVENT_DIR) $(PKG_CONFIG) --modversion libtraceevent) + CFLAGS += -DHAVE_LIBTRACEEVENT + LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L libtraceevent) + EXTLIBS += $(shell $(PKG_CONFIG) --libs-only-l libtraceevent) + LIBTRACEEVENT_VERSION := $(shell $(PKG_CONFIG) --modversion libtraceevent) LIBTRACEEVENT_VERSION_1 := $(word 1, $(subst ., ,$(LIBTRACEEVENT_VERSION))) LIBTRACEEVENT_VERSION_2 := $(word 2, $(subst ., ,$(LIBTRACEEVENT_VERSION))) LIBTRACEEVENT_VERSION_3 := $(word 3, $(subst ., ,$(LIBTRACEEVENT_VERSION))) @@ -1194,7 +1192,9 @@ ifneq ($(NO_LIBTRACEEVENT),1) $(call feature_check,libtracefs) ifeq ($(feature-libtracefs), 1) - EXTLIBS += -ltracefs + CFLAGS += $(shell $(PKG_CONFIG) --cflags libtracefs) + LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L libtracefs) + EXTLIBS += $(shell $(PKG_CONFIG) --libs-only-l libtracefs) LIBTRACEFS_VERSION := $(shell $(PKG_CONFIG) --modversion libtracefs) LIBTRACEFS_VERSION_1 := $(word 1, $(subst ., ,$(LIBTRACEFS_VERSION))) LIBTRACEFS_VERSION_2 := $(word 2, $(subst ., ,$(LIBTRACEFS_VERSION))) @@ -1315,7 +1315,6 @@ ifeq ($(VF),1) $(call print_var,LIBUNWIND_DIR) $(call print_var,LIBDW_DIR) $(call print_var,JDIR) - $(call print_var,LIBTRACEEVENT_DIR) ifeq ($(dwarf-post-unwind),1) $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text)) $(info $(MSG)) |