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

perf build: Install libsymbol locally when building

The perf build currently has a '-Itools/lib' on the CC command
line. This causes issues as the libapi, libsubcmd, libtraceevent,
libbpf and libsymbol headers are all found via this path, making it
impossible to override include behavior.

Change the libsymbol build mirroring the libbpf, libsubcmd, libapi,
libperf and libtraceevent build, so that it is installed in a directory
along with its headers.

A later change will modify the include behavior. Don't build kallsyms.o
as part of util as this will lead to duplicate definitions. Add
kallsym's directory to the MANIFEST rather than individual files, so
that the Build and Makefile are added to a source tar ball.

Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Nicolas Schier <nicolas@fjasle.eu>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: bpf@vger.kernel.org
Link: http://lore.kernel.org/lkml/20221109184914.1357295-11-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
84bec6f0 160be157

+24 -10
+1
tools/perf/.gitignore
··· 43 43 libbpf/ 44 44 libperf/ 45 45 libsubcmd/ 46 + libsymbol/ 46 47 libtraceevent/ 47 48 libtraceevent_plugins/ 48 49 fixdep
+1 -2
tools/perf/MANIFEST
··· 13 13 tools/lib/hweight.c 14 14 tools/lib/rbtree.c 15 15 tools/lib/string.c 16 - tools/lib/symbol/kallsyms.c 17 - tools/lib/symbol/kallsyms.h 16 + tools/lib/symbol 18 17 tools/lib/find_bit.c 19 18 tools/lib/bitmap.c 20 19 tools/lib/list_sort.c
+22 -3
tools/perf/Makefile.perf
··· 246 246 LIBTRACEEVENT_PLUGINS_DIR = $(LIBTRACEEVENT_DIR)/plugins 247 247 LIBBPF_DIR = $(srctree)/tools/lib/bpf/ 248 248 LIBSUBCMD_DIR = $(srctree)/tools/lib/subcmd/ 249 + LIBSYMBOL_DIR = $(srctree)/tools/lib/symbol/ 249 250 LIBPERF_DIR = $(srctree)/tools/lib/perf/ 250 251 DOC_DIR = $(srctree)/tools/perf/Documentation/ 251 252 ··· 342 341 LIBSUBCMD = $(LIBSUBCMD_OUTPUT)/libsubcmd.a 343 342 344 343 ifneq ($(OUTPUT),) 344 + LIBSYMBOL_OUTPUT = $(abspath $(OUTPUT))/libsymbol 345 + else 346 + LIBSYMBOL_OUTPUT = $(CURDIR)/libsymbol 347 + endif 348 + LIBSYMBOL_DESTDIR = $(LIBSYMBOL_OUTPUT) 349 + LIBSYMBOL_INCLUDE = $(LIBSYMBOL_DESTDIR)/include 350 + LIBSYMBOL = $(LIBSYMBOL_OUTPUT)/libsymbol.a 351 + 352 + ifneq ($(OUTPUT),) 345 353 LIBPERF_OUTPUT = $(abspath $(OUTPUT))/libperf 346 354 else 347 355 LIBPERF_OUTPUT = $(CURDIR)/libperf ··· 408 398 409 399 export PERL_PATH 410 400 411 - PERFLIBS = $(LIBAPI) $(LIBSUBCMD) $(LIBPERF) 401 + PERFLIBS = $(LIBAPI) $(LIBPERF) $(LIBSUBCMD) $(LIBSYMBOL) 412 402 ifndef NO_LIBBPF 413 403 ifndef LIBBPF_DYNAMIC 414 404 PERFLIBS += $(LIBBPF) ··· 897 887 $(call QUIET_CLEAN, libsubcmd) 898 888 $(Q)$(RM) -r -- $(LIBSUBCMD_OUTPUT) 899 889 890 + $(LIBSYMBOL): FORCE | $(LIBSYMBOL_OUTPUT) 891 + $(Q)$(MAKE) -C $(LIBSYMBOL_DIR) O=$(LIBSYMBOL_OUTPUT) \ 892 + DESTDIR=$(LIBSYMBOL_DESTDIR) prefix= \ 893 + $@ install_headers 894 + 895 + $(LIBSYMBOL)-clean: 896 + $(call QUIET_CLEAN, libsymbol) 897 + $(Q)$(RM) -r -- $(LIBSYMBOL_OUTPUT) 898 + 900 899 help: 901 900 @echo 'Perf make targets:' 902 901 @echo ' doc - make *all* documentation (see below)' ··· 1090 1071 SKELETONS += $(SKEL_OUT)/off_cpu.skel.h $(SKEL_OUT)/lock_contention.skel.h 1091 1072 SKELETONS += $(SKEL_OUT)/kwork_trace.skel.h 1092 1073 1093 - $(SKEL_TMP_OUT) $(LIBAPI_OUTPUT) $(LIBBPF_OUTPUT) $(LIBPERF_OUTPUT) $(LIBSUBCMD_OUTPUT): 1074 + $(SKEL_TMP_OUT) $(LIBAPI_OUTPUT) $(LIBBPF_OUTPUT) $(LIBPERF_OUTPUT) $(LIBSUBCMD_OUTPUT) $(LIBSYMBOL_OUTPUT): 1094 1075 $(Q)$(MKDIR) -p $@ 1095 1076 1096 1077 ifndef LIBTRACEEVENT_DYNAMIC ··· 1140 1121 bpf-skel-clean: 1141 1122 $(call QUIET_CLEAN, bpf-skel) $(RM) -r $(SKEL_TMP_OUT) $(SKELETONS) 1142 1123 1143 - clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBPERF)-clean fixdep-clean python-clean bpf-skel-clean tests-coresight-targets-clean libtraceevent_plugins-clean 1124 + clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBSYMBOL)-clean $(LIBPERF)-clean fixdep-clean python-clean bpf-skel-clean tests-coresight-targets-clean libtraceevent_plugins-clean 1144 1125 $(call QUIET_CLEAN, core-objs) $(RM) $(LIBPERF_A) $(OUTPUT)perf-archive $(OUTPUT)perf-iostat $(LANG_BINDINGS) 1145 1126 $(Q)find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete 1146 1127 $(Q)$(RM) $(OUTPUT).config-detected
-5
tools/perf/util/Build
··· 19 19 perf-y += evswitch.o 20 20 perf-y += find_bit.o 21 21 perf-y += get_current_dir_name.o 22 - perf-y += kallsyms.o 23 22 perf-y += levenshtein.o 24 23 perf-y += llvm-utils.o 25 24 perf-y += mmap.o ··· 292 293 CFLAGS_expr.o += -Wno-redundant-decls 293 294 CFLAGS_header.o += -include $(OUTPUT)PERF-VERSION-FILE 294 295 CFLAGS_arm-spe.o += -I$(srctree)/tools/arch/arm64/include/ 295 - 296 - $(OUTPUT)util/kallsyms.o: ../lib/symbol/kallsyms.c FORCE 297 - $(call rule_mkdir) 298 - $(call if_changed_dep,cc_o_c) 299 296 300 297 $(OUTPUT)util/argv_split.o: ../lib/argv_split.c FORCE 301 298 $(call rule_mkdir)