Commit e467705a authored by Ian Rogers's avatar Ian Rogers Committed by Namhyung Kim

perf util: Make util its own library

Make the util directory into its own library. This is done to avoid
compiling code twice, once for the perf tool and once for the perf
python module. For convenience:
  arch/common.c
  scripts/perl/Perf-Trace-Util/Context.c
  scripts/python/Perf-Trace-Util/Context.c
are made part of this library.
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Reviewed-by: default avatarJames Clark <james.clark@arm.com>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Nick Terrell <terrelln@fb.com>
Cc: Gary Guo <gary@garyguo.net>
Cc: Alex Gaynor <alex.gaynor@gmail.com>
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: Wedson Almeida Filho <wedsonaf@gmail.com>
Cc: Ze Gao <zegao2021@gmail.com>
Cc: Alice Ryhl <aliceryhl@google.com>
Cc: Andrei Vagin <avagin@google.com>
Cc: Yicong Yang <yangyicong@hisilicon.com>
Cc: Jonathan Cameron <jonathan.cameron@huawei.com>
Cc: Guo Ren <guoren@kernel.org>
Cc: Miguel Ojeda <ojeda@kernel.org>
Cc: Will Deacon <will@kernel.org>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Leo Yan <leo.yan@linux.dev>
Cc: Oliver Upton <oliver.upton@linux.dev>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Benno Lossin <benno.lossin@proton.me>
Cc: Björn Roy Baron <bjorn3_gh@protonmail.com>
Cc: Andreas Hindborg <a.hindborg@samsung.com>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20240625214117.953777-7-irogers@google.com
parent 21cc3bc0
...@@ -53,11 +53,12 @@ CFLAGS_builtin-trace.o += -DSTRACE_GROUPS_DIR="BUILD_STR($(STRACE_GROUPS_DIR_ ...@@ -53,11 +53,12 @@ CFLAGS_builtin-trace.o += -DSTRACE_GROUPS_DIR="BUILD_STR($(STRACE_GROUPS_DIR_
CFLAGS_builtin-report.o += -DTIPDIR="BUILD_STR($(tipdir_SQ))" CFLAGS_builtin-report.o += -DTIPDIR="BUILD_STR($(tipdir_SQ))"
CFLAGS_builtin-report.o += -DDOCDIR="BUILD_STR($(srcdir_SQ)/Documentation)" CFLAGS_builtin-report.o += -DDOCDIR="BUILD_STR($(srcdir_SQ)/Documentation)"
perf-y += util/ perf-util-y += util/
perf-util-y += arch/
perf-y += arch/ perf-y += arch/
perf-test-y += arch/ perf-test-y += arch/
perf-ui-y += ui/ perf-ui-y += ui/
perf-y += scripts/ perf-util-y += scripts/
gtk-y += ui/gtk/ gtk-y += ui/gtk/
......
...@@ -434,6 +434,9 @@ LIBPERF_TEST := $(OUTPUT)libperf-test.a ...@@ -434,6 +434,9 @@ LIBPERF_TEST := $(OUTPUT)libperf-test.a
LIBPERF_UI_IN := $(OUTPUT)perf-ui-in.o LIBPERF_UI_IN := $(OUTPUT)perf-ui-in.o
LIBPERF_UI := $(OUTPUT)libperf-ui.a LIBPERF_UI := $(OUTPUT)libperf-ui.a
LIBPERF_UTIL_IN := $(OUTPUT)perf-util-in.o
LIBPERF_UTIL := $(OUTPUT)libperf-util.a
LIBPMU_EVENTS_IN := $(OUTPUT)pmu-events/pmu-events-in.o LIBPMU_EVENTS_IN := $(OUTPUT)pmu-events/pmu-events-in.o
LIBPMU_EVENTS := $(OUTPUT)libpmu-events.a LIBPMU_EVENTS := $(OUTPUT)libpmu-events.a
...@@ -441,7 +444,8 @@ PERFLIBS = $(LIBAPI) $(LIBPERF) $(LIBSUBCMD) $(LIBSYMBOL) ...@@ -441,7 +444,8 @@ PERFLIBS = $(LIBAPI) $(LIBPERF) $(LIBSUBCMD) $(LIBSYMBOL)
ifdef LIBBPF_STATIC ifdef LIBBPF_STATIC
PERFLIBS += $(LIBBPF) PERFLIBS += $(LIBBPF)
endif endif
PERFLIBS += $(LIBPERF_BENCH) $(LIBPERF_TEST) $(LIBPERF_UI) $(LIBPMU_EVENTS) PERFLIBS += $(LIBPERF_BENCH) $(LIBPERF_TEST) $(LIBPERF_UI) $(LIBPERF_UTIL)
PERFLIBS += $(LIBPMU_EVENTS)
# We choose to avoid "if .. else if .. else .. endif endif" # We choose to avoid "if .. else if .. else .. endif endif"
# because maintaining the nesting to match is a pain. If # because maintaining the nesting to match is a pain. If
...@@ -761,6 +765,12 @@ $(LIBPERF_UI_IN): FORCE prepare ...@@ -761,6 +765,12 @@ $(LIBPERF_UI_IN): FORCE prepare
$(LIBPERF_UI): $(LIBPERF_UI_IN) $(LIBPERF_UI): $(LIBPERF_UI_IN)
$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $< $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $<
$(LIBPERF_UTIL_IN): FORCE prepare
$(Q)$(MAKE) $(build)=perf-util
$(LIBPERF_UTIL): $(LIBPERF_UTIL_IN)
$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $<
$(OUTPUT)perf: $(PERFLIBS) $(PERF_IN) $(OUTPUT)perf: $(PERFLIBS) $(PERF_IN)
$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) \ $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) \
$(PERF_IN) $(LIBS) -o $@ $(PERF_IN) $(LIBS) -o $@
......
perf-y += common.o perf-util-y += common.o
perf-y += $(SRCARCH)/
perf-test-y += $(SRCARCH)/ perf-test-y += $(SRCARCH)/
perf-util-y += $(SRCARCH)/
perf-y += util/ perf-util-y += util/
perf-test-$(CONFIG_DWARF_UNWIND) += tests/ perf-test-$(CONFIG_DWARF_UNWIND) += tests/
perf-y += perf_regs.o perf-util-y += perf_regs.o
perf-$(CONFIG_DWARF) += dwarf-regs.o perf-util-$(CONFIG_DWARF) += dwarf-regs.o
perf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o perf-util-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o
perf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o perf-util-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o
perf-$(CONFIG_AUXTRACE) += pmu.o auxtrace.o cs-etm.o perf-util-$(CONFIG_AUXTRACE) += pmu.o auxtrace.o cs-etm.o
perf-y += util/ perf-util-y += util/
perf-test-y += tests/ perf-test-y += tests/
perf-y += header.o perf-util-y += header.o
perf-y += machine.o perf-util-y += machine.o
perf-y += perf_regs.o perf-util-y += perf_regs.o
perf-y += tsc.o perf-util-y += tsc.o
perf-y += pmu.o perf-util-y += pmu.o
perf-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o perf-util-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o
perf-$(CONFIG_DWARF) += dwarf-regs.o perf-util-$(CONFIG_DWARF) += dwarf-regs.o
perf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o perf-util-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o
perf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o perf-util-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o
perf-$(CONFIG_AUXTRACE) += ../../arm/util/pmu.o \ perf-util-$(CONFIG_AUXTRACE) += ../../arm/util/pmu.o \
../../arm/util/auxtrace.o \ ../../arm/util/auxtrace.o \
../../arm/util/cs-etm.o \ ../../arm/util/cs-etm.o \
arm-spe.o mem-events.o hisi-ptt.o arm-spe.o mem-events.o hisi-ptt.o
perf-y += util/ perf-util-y += util/
perf-y += perf_regs.o perf-util-y += perf_regs.o
perf-$(CONFIG_DWARF) += dwarf-regs.o perf-util-$(CONFIG_DWARF) += dwarf-regs.o
perf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o perf-util-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o
perf-y += util/ perf-util-y += util/
perf-y += perf_regs.o perf-util-y += perf_regs.o
perf-$(CONFIG_DWARF) += dwarf-regs.o perf-util-$(CONFIG_DWARF) += dwarf-regs.o
perf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o perf-util-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o
perf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o perf-util-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o
perf-y += util/ perf-util-y += util/
perf-y += perf_regs.o perf-util-y += perf_regs.o
perf-$(CONFIG_DWARF) += dwarf-regs.o perf-util-$(CONFIG_DWARF) += dwarf-regs.o
perf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o perf-util-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o
perf-y += util/ perf-util-y += util/
perf-test-y += tests/ perf-test-y += tests/
perf-y += header.o perf-util-y += header.o
perf-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o perf-util-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o
perf-y += perf_regs.o perf-util-y += perf_regs.o
perf-y += mem-events.o perf-util-y += mem-events.o
perf-y += pmu.o perf-util-y += pmu.o
perf-y += sym-handling.o perf-util-y += sym-handling.o
perf-y += evsel.o perf-util-y += evsel.o
perf-y += event.o perf-util-y += event.o
perf-$(CONFIG_DWARF) += dwarf-regs.o perf-util-$(CONFIG_DWARF) += dwarf-regs.o
perf-$(CONFIG_DWARF) += skip-callchain-idx.o perf-util-$(CONFIG_DWARF) += skip-callchain-idx.o
perf-$(CONFIG_LIBUNWIND) += unwind-libunwind.o perf-util-$(CONFIG_LIBUNWIND) += unwind-libunwind.o
perf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o perf-util-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o
perf-y += util/ perf-util-y += util/
perf-y += perf_regs.o perf-util-y += perf_regs.o
perf-y += header.o perf-util-y += header.o
perf-$(CONFIG_DWARF) += dwarf-regs.o perf-util-$(CONFIG_DWARF) += dwarf-regs.o
perf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o perf-util-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o
perf-y += util/ perf-util-y += util/
perf-y += header.o perf-util-y += header.o
perf-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o perf-util-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o
perf-y += perf_regs.o perf-util-y += perf_regs.o
perf-$(CONFIG_DWARF) += dwarf-regs.o perf-util-$(CONFIG_DWARF) += dwarf-regs.o
perf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o perf-util-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o
perf-y += machine.o perf-util-y += machine.o
perf-y += pmu.o perf-util-y += pmu.o
perf-$(CONFIG_AUXTRACE) += auxtrace.o perf-util-$(CONFIG_AUXTRACE) += auxtrace.o
perf-y += util/ perf-util-y += util/
perf-$(CONFIG_DWARF) += dwarf-regs.o perf-util-$(CONFIG_DWARF) += dwarf-regs.o
perf-y += util/ perf-util-y += util/
perf-$(CONFIG_DWARF) += dwarf-regs.o perf-util-$(CONFIG_DWARF) += dwarf-regs.o
perf-y += util/ perf-util-y += util/
perf-test-y += tests/ perf-test-y += tests/
ifdef SHELLCHECK ifdef SHELLCHECK
......
perf-y += header.o perf-util-y += header.o
perf-y += tsc.o perf-util-y += tsc.o
perf-y += pmu.o perf-util-y += pmu.o
perf-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o perf-util-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o
perf-y += perf_regs.o perf-util-y += perf_regs.o
perf-y += topdown.o perf-util-y += topdown.o
perf-y += machine.o perf-util-y += machine.o
perf-y += event.o perf-util-y += event.o
perf-y += evlist.o perf-util-y += evlist.o
perf-y += mem-events.o perf-util-y += mem-events.o
perf-y += evsel.o perf-util-y += evsel.o
perf-y += iostat.o perf-util-y += iostat.o
perf-y += env.o perf-util-y += env.o
perf-$(CONFIG_DWARF) += dwarf-regs.o perf-util-$(CONFIG_DWARF) += dwarf-regs.o
perf-$(CONFIG_BPF_PROLOGUE) += dwarf-regs.o perf-util-$(CONFIG_BPF_PROLOGUE) += dwarf-regs.o
perf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o perf-util-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o
perf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o perf-util-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o
perf-$(CONFIG_AUXTRACE) += auxtrace.o perf-util-$(CONFIG_AUXTRACE) += auxtrace.o
perf-$(CONFIG_AUXTRACE) += archinsn.o perf-util-$(CONFIG_AUXTRACE) += archinsn.o
perf-$(CONFIG_AUXTRACE) += intel-pt.o perf-util-$(CONFIG_AUXTRACE) += intel-pt.o
perf-$(CONFIG_AUXTRACE) += intel-bts.o perf-util-$(CONFIG_AUXTRACE) += intel-bts.o
perf-y += util/ perf-util-y += util/
ifeq ($(CONFIG_LIBTRACEEVENT),y) ifeq ($(CONFIG_LIBTRACEEVENT),y)
perf-$(CONFIG_LIBPERL) += perl/Perf-Trace-Util/ perf-util-$(CONFIG_LIBPERL) += perl/Perf-Trace-Util/
endif endif
perf-$(CONFIG_LIBPYTHON) += python/Perf-Trace-Util/ perf-util-$(CONFIG_LIBPYTHON) += python/Perf-Trace-Util/
perf-y += Context.o perf-util-y += Context.o
CFLAGS_Context.o += $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-bad-function-cast -Wno-declaration-after-statement -Wno-switch-enum CFLAGS_Context.o += $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-bad-function-cast -Wno-declaration-after-statement -Wno-switch-enum
CFLAGS_Context.o += -Wno-unused-parameter -Wno-nested-externs -Wno-undef CFLAGS_Context.o += -Wno-unused-parameter -Wno-nested-externs -Wno-undef
......
perf-y += Context.o perf-util-y += Context.o
# -Wno-declaration-after-statement: The python headers have mixed code with declarations (decls after asserts, for instance) # -Wno-declaration-after-statement: The python headers have mixed code with declarations (decls after asserts, for instance)
CFLAGS_Context.o += $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs -Wno-declaration-after-statement CFLAGS_Context.o += $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs -Wno-declaration-after-statement
This diff is collapsed.
perf-$(CONFIG_AUXTRACE) += arm-spe-pkt-decoder.o arm-spe-decoder.o perf-util-$(CONFIG_AUXTRACE) += arm-spe-pkt-decoder.o arm-spe-decoder.o
perf-$(CONFIG_AUXTRACE) += cs-etm-decoder.o perf-util-$(CONFIG_AUXTRACE) += cs-etm-decoder.o
perf-$(CONFIG_AUXTRACE) += hisi-ptt-pkt-decoder.o perf-util-$(CONFIG_AUXTRACE) += hisi-ptt-pkt-decoder.o
perf-$(CONFIG_AUXTRACE) += intel-pt-pkt-decoder.o intel-pt-insn-decoder.o intel-pt-log.o intel-pt-decoder.o perf-util-$(CONFIG_AUXTRACE) += intel-pt-pkt-decoder.o intel-pt-insn-decoder.o intel-pt-log.o intel-pt-decoder.o
inat_tables_script = $(srctree)/tools/arch/x86/tools/gen-insn-attr-x86.awk inat_tables_script = $(srctree)/tools/arch/x86/tools/gen-insn-attr-x86.awk
inat_tables_maps = $(srctree)/tools/arch/x86/lib/x86-opcode-map.txt inat_tables_maps = $(srctree)/tools/arch/x86/lib/x86-opcode-map.txt
......
perf-y += perf_regs_aarch64.o perf-util-y += perf_regs_aarch64.o
perf-y += perf_regs_arm.o perf-util-y += perf_regs_arm.o
perf-y += perf_regs_csky.o perf-util-y += perf_regs_csky.o
perf-y += perf_regs_loongarch.o perf-util-y += perf_regs_loongarch.o
perf-y += perf_regs_mips.o perf-util-y += perf_regs_mips.o
perf-y += perf_regs_powerpc.o perf-util-y += perf_regs_powerpc.o
perf-y += perf_regs_riscv.o perf-util-y += perf_regs_riscv.o
perf-y += perf_regs_s390.o perf-util-y += perf_regs_s390.o
perf-y += perf_regs_x86.o perf-util-y += perf_regs_x86.o
ifeq ($(CONFIG_LIBTRACEEVENT),y) ifeq ($(CONFIG_LIBTRACEEVENT),y)
perf-$(CONFIG_LIBPERL) += trace-event-perl.o perf-util-$(CONFIG_LIBPERL) += trace-event-perl.o
endif endif
perf-$(CONFIG_LIBPYTHON) += trace-event-python.o perf-util-$(CONFIG_LIBPYTHON) += trace-event-python.o
CFLAGS_trace-event-perl.o += $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow -Wno-nested-externs -Wno-undef -Wno-switch-default -Wno-bad-function-cast -Wno-declaration-after-statement -Wno-switch-enum CFLAGS_trace-event-perl.o += $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow -Wno-nested-externs -Wno-undef -Wno-switch-default -Wno-bad-function-cast -Wno-declaration-after-statement -Wno-switch-enum
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment