Skip to content

Commit 786c824

Browse files
committed
Merge tag 'perf-tools-fixes-for-v6.11-2024-07-23' of git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools
Pull perf tools fixes from Namhyung Kim: "Two fixes for building perf and other tools: - Fix breakage in tracing tools due to pkg-config for libtrace{event,fs} - Fix build of perf when libunwind is used" * tag 'perf-tools-fixes-for-v6.11-2024-07-23' of git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools: perf dso: Fix build when libunwind is enabled tools/latency: Use pkg-config in lib_setup of Makefile.config tools/rtla: Use pkg-config in lib_setup of Makefile.config tools/verification: Use pkg-config in lib_setup of Makefile.config tools: Make pkg-config dependency checks usable by other tools perf build: Warn if libtracefs is not found
2 parents e9e9697 + 92717bc commit 786c824

File tree

8 files changed

+36
-13
lines changed

8 files changed

+36
-13
lines changed

tools/build/Makefile.feature

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,24 @@ FEATURE_DISPLAY ?= \
149149
#
150150
FEATURE_GROUP_MEMBERS-libbfd = libbfd-liberty libbfd-liberty-z
151151

152+
#
153+
# Declare list of feature dependency packages that provide pkg-config files.
154+
#
155+
FEATURE_PKG_CONFIG ?= \
156+
libtraceevent \
157+
libtracefs
158+
159+
feature_pkg_config = $(eval $(feature_pkg_config_code))
160+
define feature_pkg_config_code
161+
FEATURE_CHECK_CFLAGS-$(1) := $(shell $(PKG_CONFIG) --cflags $(1) 2>/dev/null)
162+
FEATURE_CHECK_LDFLAGS-$(1) := $(shell $(PKG_CONFIG) --libs $(1) 2>/dev/null)
163+
endef
164+
165+
# Set FEATURE_CHECK_(C|LD)FLAGS-$(package) for packages using pkg-config.
166+
ifneq ($(PKG_CONFIG),)
167+
$(foreach package,$(FEATURE_PKG_CONFIG),$(call feature_pkg_config,$(package)))
168+
endif
169+
152170
# Set FEATURE_CHECK_(C|LD)FLAGS-all for all FEATURE_TESTS features.
153171
# If in the future we need per-feature checks/flags for features not
154172
# mentioned in this list we need to refactor this ;-).

tools/perf/Makefile.config

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -182,20 +182,15 @@ endif
182182
FEATURE_CHECK_CFLAGS-libzstd := $(LIBZSTD_CFLAGS)
183183
FEATURE_CHECK_LDFLAGS-libzstd := $(LIBZSTD_LDFLAGS)
184184

185+
# for linking with debug library, run like:
186+
# make DEBUG=1 PKG_CONFIG_PATH=/opt/libtraceevent/(lib|lib64)/pkgconfig
187+
185188
ifneq ($(NO_LIBTRACEEVENT),1)
186189
ifeq ($(call get-executable,$(PKG_CONFIG)),)
187190
$(error Error: $(PKG_CONFIG) needed by libtraceevent is missing on this system, please install it)
188191
endif
189192
endif
190193

191-
# for linking with debug library, run like:
192-
# make DEBUG=1 PKG_CONFIG_PATH=/opt/libtraceevent/(lib|lib64)/pkgconfig
193-
FEATURE_CHECK_CFLAGS-libtraceevent := $(shell $(PKG_CONFIG) --cflags libtraceevent 2>/dev/null)
194-
FEATURE_CHECK_LDFLAGS-libtraceevent := $(shell $(PKG_CONFIG) --libs libtraceevent 2>/dev/null)
195-
196-
FEATURE_CHECK_CFLAGS-libtracefs := $(shell $(PKG_CONFIG) --cflags libtracefs 2>/dev/null)
197-
FEATURE_CHECK_LDFLAGS-libtracefs := $(shell $(PKG_CONFIG) --libs libtracefs 2>/dev/null)
198-
199194
FEATURE_CHECK_CFLAGS-bpf = -I. -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi -I$(srctree)/tools/include/uapi
200195
# include ARCH specific config
201196
-include $(src-perf)/arch/$(SRCARCH)/Makefile
@@ -1206,6 +1201,8 @@ ifneq ($(NO_LIBTRACEEVENT),1)
12061201
LIBTRACEFS_VERSION_3 := $(word 3, $(subst ., ,$(LIBTRACEFS_VERSION)))
12071202
LIBTRACEFS_VERSION_CPP := $(shell expr $(LIBTRACEFS_VERSION_1) \* 255 \* 255 + $(LIBTRACEFS_VERSION_2) \* 255 + $(LIBTRACEFS_VERSION_3))
12081203
CFLAGS += -DLIBTRACEFS_VERSION=$(LIBTRACEFS_VERSION_CPP)
1204+
else
1205+
$(warning libtracefs is missing. Please install libtracefs-dev/libtracefs-devel)
12091206
endif
12101207
endif
12111208

tools/perf/util/dso.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1501,7 +1501,7 @@ void dso__delete(struct dso *dso)
15011501
auxtrace_cache__free(RC_CHK_ACCESS(dso)->auxtrace_cache);
15021502
dso_cache__free(dso);
15031503
dso__free_a2l(dso);
1504-
zfree(&RC_CHK_ACCESS(dso)->symsrc_filename);
1504+
dso__free_symsrc_filename(dso);
15051505
nsinfo__zput(RC_CHK_ACCESS(dso)->nsinfo);
15061506
mutex_destroy(dso__lock(dso));
15071507
RC_CHK_FREE(dso);

tools/perf/util/dso.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,11 @@ static inline void dso__set_symsrc_filename(struct dso *dso, char *val)
602602
RC_CHK_ACCESS(dso)->symsrc_filename = val;
603603
}
604604

605+
static inline void dso__free_symsrc_filename(struct dso *dso)
606+
{
607+
zfree(&RC_CHK_ACCESS(dso)->symsrc_filename);
608+
}
609+
605610
static inline enum dso_binary_type dso__symtab_type(const struct dso *dso)
606611
{
607612
return RC_CHK_ACCESS(dso)->symtab_type;

tools/perf/util/unwind-libunwind-local.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ static int read_unwind_spec_debug_frame(struct dso *dso,
413413
__func__,
414414
dso__symsrc_filename(dso),
415415
debuglink);
416-
zfree(&dso__symsrc_filename(dso));
416+
dso__free_symsrc_filename(dso);
417417
}
418418
dso__set_symsrc_filename(dso, debuglink);
419419
} else {

tools/tracing/latency/Makefile.config

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
STOP_ERROR :=
44

55
define lib_setup
6-
$(eval EXTLIBS += -l$(1))
76
$(eval LIB_INCLUDES += $(shell sh -c "$(PKG_CONFIG) --cflags lib$(1)"))
7+
$(eval LDFLAGS += $(shell sh -c "$(PKG_CONFIG) --libs-only-L lib$(1)"))
8+
$(eval EXTLIBS += $(shell sh -c "$(PKG_CONFIG) --libs-only-l lib$(1)"))
89
endef
910

1011
$(call feature_check,libtraceevent)

tools/tracing/rtla/Makefile.config

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ LIBTRACEFS_MIN_VERSION = 1.6
77

88
define lib_setup
99
$(eval LIB_INCLUDES += $(shell sh -c "$(PKG_CONFIG) --cflags lib$(1)"))
10-
$(eval EXTLIBS += -l$(1))
10+
$(eval LDFLAGS += $(shell sh -c "$(PKG_CONFIG) --libs-only-L lib$(1)"))
11+
$(eval EXTLIBS += $(shell sh -c "$(PKG_CONFIG) --libs-only-l lib$(1)"))
1112
endef
1213

1314
$(call feature_check,libtraceevent)

tools/verification/rv/Makefile.config

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ LIBTRACEFS_MIN_VERSION = 1.3
77

88
define lib_setup
99
$(eval LIB_INCLUDES += $(shell sh -c "$(PKG_CONFIG) --cflags lib$(1)"))
10-
$(eval EXTLIBS += -l$(1))
10+
$(eval LDFLAGS += $(shell sh -c "$(PKG_CONFIG) --libs-only-L lib$(1)"))
11+
$(eval EXTLIBS += $(shell sh -c "$(PKG_CONFIG) --libs-only-l lib$(1)"))
1112
endef
1213

1314
$(call feature_check,libtraceevent)

0 commit comments

Comments
 (0)