2024-06-12 18:49:34

by Ian Rogers

[permalink] [raw]
Subject: [PATCH v1 0/7] Refactor perf python module build

Refactor the perf python module build to instead of building C files
it links libraries. To support this make static libraries for tests,
ui, util and pmu-events. Doing this allows fewer functions to be
stubbed out, importantly parse_events is no longer stubbed out which
will improve the ability to work with heterogeneous cores.

Patches 1 to 5 add static libraries for existing parts of the perf
build.

Patch 6 adds the python build using libraries rather than C source
files.

Patch 7 cleans up the python dependencies and removes the no longer
needed python-ext-sources.

Ian Rogers (7):
perf ui: Make ui its own library
perf pmu-events: Make pmu-events a library
perf test: Make tests its own library
perf bench: Make bench its own library
perf util: Make util its own library
perf python: Switch module to linking libraries from building source
perf python: Clean up build dependencies

tools/perf/Build | 14 +-
tools/perf/Makefile.config | 5 +
tools/perf/Makefile.perf | 66 ++-
tools/perf/arch/Build | 4 +-
tools/perf/arch/arm/Build | 4 +-
tools/perf/arch/arm/tests/Build | 8 +-
tools/perf/arch/arm/util/Build | 10 +-
tools/perf/arch/arm64/Build | 4 +-
tools/perf/arch/arm64/tests/Build | 8 +-
tools/perf/arch/arm64/util/Build | 20 +-
tools/perf/arch/csky/Build | 2 +-
tools/perf/arch/csky/util/Build | 6 +-
tools/perf/arch/loongarch/Build | 2 +-
tools/perf/arch/loongarch/util/Build | 8 +-
tools/perf/arch/mips/Build | 2 +-
tools/perf/arch/mips/util/Build | 6 +-
tools/perf/arch/powerpc/Build | 4 +-
tools/perf/arch/powerpc/tests/Build | 6 +-
tools/perf/arch/powerpc/util/Build | 24 +-
tools/perf/arch/riscv/Build | 2 +-
tools/perf/arch/riscv/util/Build | 8 +-
tools/perf/arch/s390/Build | 2 +-
tools/perf/arch/s390/util/Build | 16 +-
tools/perf/arch/sh/Build | 2 +-
tools/perf/arch/sh/util/Build | 2 +-
tools/perf/arch/sparc/Build | 2 +-
tools/perf/arch/sparc/util/Build | 2 +-
tools/perf/arch/x86/Build | 6 +-
tools/perf/arch/x86/tests/Build | 20 +-
tools/perf/arch/x86/util/Build | 42 +-
tools/perf/bench/Build | 46 +-
tools/perf/scripts/Build | 4 +-
tools/perf/scripts/perl/Perf-Trace-Util/Build | 2 +-
.../perf/scripts/python/Perf-Trace-Util/Build | 2 +-
tools/perf/tests/Build | 140 +++----
tools/perf/tests/workloads/Build | 12 +-
tools/perf/ui/Build | 18 +-
tools/perf/ui/browsers/Build | 14 +-
tools/perf/ui/tui/Build | 8 +-
tools/perf/util/Build | 394 +++++++++---------
tools/perf/util/arm-spe-decoder/Build | 2 +-
tools/perf/util/cs-etm-decoder/Build | 2 +-
tools/perf/util/hisi-ptt-decoder/Build | 2 +-
tools/perf/util/intel-pt-decoder/Build | 2 +-
tools/perf/util/perf-regs-arch/Build | 18 +-
tools/perf/util/python-ext-sources | 53 ---
tools/perf/util/python.c | 271 +++++-------
tools/perf/util/scripting-engines/Build | 4 +-
tools/perf/util/setup.py | 33 +-
49 files changed, 612 insertions(+), 722 deletions(-)
delete mode 100644 tools/perf/util/python-ext-sources

--
2.45.2.505.gda0bf45e8d-goog



2024-06-12 18:49:57

by Ian Rogers

[permalink] [raw]
Subject: [PATCH v1 1/7] perf ui: Make ui its own library

Make the ui code its own library. This is done to avoid compiling code
twice, once for the perf tool and once for the perf python module.

Signed-off-by: Ian Rogers <[email protected]>
---
tools/perf/Build | 2 +-
tools/perf/Makefile.perf | 10 ++++++++++
tools/perf/ui/Build | 18 +++++++++---------
tools/perf/ui/browsers/Build | 14 +++++++-------
tools/perf/ui/tui/Build | 8 ++++----
5 files changed, 31 insertions(+), 21 deletions(-)

diff --git a/tools/perf/Build b/tools/perf/Build
index b0cb7ad8e6ac..16ed1357202b 100644
--- a/tools/perf/Build
+++ b/tools/perf/Build
@@ -55,7 +55,7 @@ CFLAGS_builtin-report.o += -DDOCDIR="BUILD_STR($(srcdir_SQ)/Documentation)"

perf-y += util/
perf-y += arch/
-perf-y += ui/
+perf-ui-y += ui/
perf-y += scripts/

gtk-y += ui/gtk/
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 5c35c0d89306..350b65088fc1 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -425,10 +425,14 @@ endif

export PERL_PATH

+LIBPERF_UI_IN := $(OUTPUT)perf-ui-in.o
+LIBPERF_UI := $(OUTPUT)libperf-ui.a
+
PERFLIBS = $(LIBAPI) $(LIBPERF) $(LIBSUBCMD) $(LIBSYMBOL)
ifdef LIBBPF_STATIC
PERFLIBS += $(LIBBPF)
endif
+PERFLIBS += $(LIBPERF_UI)

# We choose to avoid "if .. else if .. else .. endif endif"
# because maintaining the nesting to match is a pain. If
@@ -729,6 +733,12 @@ $(PERF_IN): prepare FORCE
$(PMU_EVENTS_IN): FORCE prepare
$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=pmu-events obj=pmu-events

+$(LIBPERF_UI_IN): FORCE prepare
+ $(Q)$(MAKE) $(build)=perf-ui
+
+$(LIBPERF_UI): $(LIBPERF_UI_IN)
+ $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $<
+
$(OUTPUT)perf: $(PERFLIBS) $(PERF_IN) $(PMU_EVENTS_IN)
$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) \
$(PERF_IN) $(PMU_EVENTS_IN) $(LIBS) -o $@
diff --git a/tools/perf/ui/Build b/tools/perf/ui/Build
index 6b6d7143a37b..d2ecd9290600 100644
--- a/tools/perf/ui/Build
+++ b/tools/perf/ui/Build
@@ -1,12 +1,12 @@
-perf-y += setup.o
-perf-y += helpline.o
-perf-y += progress.o
-perf-y += util.o
-perf-y += hist.o
-perf-y += stdio/hist.o
+perf-ui-y += setup.o
+perf-ui-y += helpline.o
+perf-ui-y += progress.o
+perf-ui-y += util.o
+perf-ui-y += hist.o
+perf-ui-y += stdio/hist.o

CFLAGS_setup.o += -DLIBDIR="BUILD_STR($(LIBDIR))"

-perf-$(CONFIG_SLANG) += browser.o
-perf-$(CONFIG_SLANG) += browsers/
-perf-$(CONFIG_SLANG) += tui/
+perf-ui-$(CONFIG_SLANG) += browser.o
+perf-ui-$(CONFIG_SLANG) += browsers/
+perf-ui-$(CONFIG_SLANG) += tui/
diff --git a/tools/perf/ui/browsers/Build b/tools/perf/ui/browsers/Build
index 2608b5da3167..a07489e44765 100644
--- a/tools/perf/ui/browsers/Build
+++ b/tools/perf/ui/browsers/Build
@@ -1,7 +1,7 @@
-perf-y += annotate.o
-perf-y += annotate-data.o
-perf-y += hists.o
-perf-y += map.o
-perf-y += scripts.o
-perf-y += header.o
-perf-y += res_sample.o
+perf-ui-y += annotate.o
+perf-ui-y += annotate-data.o
+perf-ui-y += hists.o
+perf-ui-y += map.o
+perf-ui-y += scripts.o
+perf-ui-y += header.o
+perf-ui-y += res_sample.o
diff --git a/tools/perf/ui/tui/Build b/tools/perf/ui/tui/Build
index f916df33a1a7..2ac058ad1a61 100644
--- a/tools/perf/ui/tui/Build
+++ b/tools/perf/ui/tui/Build
@@ -1,4 +1,4 @@
-perf-y += setup.o
-perf-y += util.o
-perf-y += helpline.o
-perf-y += progress.o
+perf-ui-y += setup.o
+perf-ui-y += util.o
+perf-ui-y += helpline.o
+perf-ui-y += progress.o
--
2.45.2.505.gda0bf45e8d-goog


2024-06-12 19:05:07

by Ian Rogers

[permalink] [raw]
Subject: [PATCH v1 7/7] perf python: Clean up build dependencies

The python build now depends on libraries and doesn't use
python-ext-sources except for the util/python.c dependency. Switch to
just directly depending on that file and util/setup.py. This allows
the removal of python-ext-sources.

Signed-off-by: Ian Rogers <[email protected]>
---
tools/perf/Makefile.perf | 10 +-----
tools/perf/util/python-ext-sources | 53 ------------------------------
2 files changed, 1 insertion(+), 62 deletions(-)
delete mode 100644 tools/perf/util/python-ext-sources

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 6f66d3a7ffb2..918b851b2e0d 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -380,14 +380,6 @@ python-clean := $(call QUIET_CLEAN, python) $(RM) -r $(PYTHON_EXTBUILD) $(OUTPUT
# Use the detected configuration
-include $(OUTPUT).config-detected

-ifeq ($(CONFIG_LIBTRACEEVENT),y)
- PYTHON_EXT_SRCS := $(shell grep -v ^\# util/python-ext-sources)
-else
- PYTHON_EXT_SRCS := $(shell grep -v ^\#\\\|util/trace-event.c\\\|util/trace-event-parse.c util/python-ext-sources)
-endif
-
-PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py $(LIBAPI)
-
SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH))

PROGRAMS += $(OUTPUT)perf
@@ -715,7 +707,7 @@ all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS)
# Create python binding output directory if not already present
$(shell [ -d '$(OUTPUT)python' ] || mkdir -p '$(OUTPUT)python')

-$(OUTPUT)python/perf$(PYTHON_EXTENSION_SUFFIX): $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) $(PERFLIBS)
+$(OUTPUT)python/perf$(PYTHON_EXTENSION_SUFFIX): util/python.c util/setup.py $(PERFLIBS)
$(QUIET_GEN)LDSHARED="$(CC) -pthread -shared" \
CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS) $(LIBS)' \
$(PYTHON_WORD) util/setup.py \
diff --git a/tools/perf/util/python-ext-sources b/tools/perf/util/python-ext-sources
deleted file mode 100644
index 1bec945f4838..000000000000
--- a/tools/perf/util/python-ext-sources
+++ /dev/null
@@ -1,53 +0,0 @@
-#
-# List of files needed by perf python extension
-#
-# Each source file must be placed on its own line so that it can be
-# processed by Makefile and util/setup.py accordingly.
-#
-
-util/python.c
-../lib/ctype.c
-util/cap.c
-util/evlist.c
-util/evsel.c
-util/evsel_fprintf.c
-util/perf_event_attr_fprintf.c
-util/cpumap.c
-util/memswap.c
-util/mmap.c
-util/namespaces.c
-../lib/bitmap.c
-../lib/find_bit.c
-../lib/list_sort.c
-../lib/hweight.c
-../lib/string.c
-../lib/vsprintf.c
-util/thread_map.c
-util/util.c
-util/cgroup.c
-util/parse-branch-options.c
-util/rblist.c
-util/counts.c
-util/print_binary.c
-util/strlist.c
-util/trace-event.c
-util/trace-event-parse.c
-../lib/rbtree.c
-util/string.c
-util/symbol_fprintf.c
-util/units.c
-util/affinity.c
-util/rwsem.c
-util/hashmap.c
-util/perf_regs.c
-util/fncache.c
-util/rlimit.c
-util/perf-regs-arch/perf_regs_aarch64.c
-util/perf-regs-arch/perf_regs_arm.c
-util/perf-regs-arch/perf_regs_csky.c
-util/perf-regs-arch/perf_regs_loongarch.c
-util/perf-regs-arch/perf_regs_mips.c
-util/perf-regs-arch/perf_regs_powerpc.c
-util/perf-regs-arch/perf_regs_riscv.c
-util/perf-regs-arch/perf_regs_s390.c
-util/perf-regs-arch/perf_regs_x86.c
--
2.45.2.505.gda0bf45e8d-goog


2024-06-12 19:11:46

by Ian Rogers

[permalink] [raw]
Subject: [PATCH v1 2/7] perf pmu-events: Make pmu-events a library

Make pmu-events into a library so it may be linked against things like
the python module and not built from source.

Signed-off-by: Ian Rogers <[email protected]>
---
tools/perf/Makefile.perf | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 350b65088fc1..ff1ff1e739b7 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -428,11 +428,14 @@ export PERL_PATH
LIBPERF_UI_IN := $(OUTPUT)perf-ui-in.o
LIBPERF_UI := $(OUTPUT)libperf-ui.a

+LIBPMU_EVENTS_IN := $(OUTPUT)pmu-events/pmu-events-in.o
+LIBPMU_EVENTS := $(OUTPUT)libpmu-events.a
+
PERFLIBS = $(LIBAPI) $(LIBPERF) $(LIBSUBCMD) $(LIBSYMBOL)
ifdef LIBBPF_STATIC
PERFLIBS += $(LIBBPF)
endif
-PERFLIBS += $(LIBPERF_UI)
+PERFLIBS += $(LIBPERF_UI) $(LIBPMU_EVENTS)

# We choose to avoid "if .. else if .. else .. endif endif"
# because maintaining the nesting to match is a pain. If
@@ -721,8 +724,6 @@ strip: $(PROGRAMS) $(OUTPUT)perf
$(STRIP) $(STRIP_OPTS) $(PROGRAMS) $(OUTPUT)perf

PERF_IN := $(OUTPUT)perf-in.o
-
-PMU_EVENTS_IN := $(OUTPUT)pmu-events/pmu-events-in.o
export NO_JEVENTS

build := -f $(srctree)/tools/build/Makefile.build dir=. obj
@@ -730,18 +731,21 @@ build := -f $(srctree)/tools/build/Makefile.build dir=. obj
$(PERF_IN): prepare FORCE
$(Q)$(MAKE) $(build)=perf

-$(PMU_EVENTS_IN): FORCE prepare
+$(LIBPMU_EVENTS_IN): FORCE prepare
$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=pmu-events obj=pmu-events

+$(LIBPMU_EVENTS): $(LIBPMU_EVENTS_IN)
+ $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $<
+
$(LIBPERF_UI_IN): FORCE prepare
$(Q)$(MAKE) $(build)=perf-ui

$(LIBPERF_UI): $(LIBPERF_UI_IN)
$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $<

-$(OUTPUT)perf: $(PERFLIBS) $(PERF_IN) $(PMU_EVENTS_IN)
+$(OUTPUT)perf: $(PERFLIBS) $(PERF_IN)
$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) \
- $(PERF_IN) $(PMU_EVENTS_IN) $(LIBS) -o $@
+ $(PERF_IN) $(LIBS) -o $@

$(GTK_IN): FORCE prepare
$(Q)$(MAKE) $(build)=gtk
--
2.45.2.505.gda0bf45e8d-goog


2024-06-13 09:27:41

by James Clark

[permalink] [raw]
Subject: Re: [PATCH v1 0/7] Refactor perf python module build



On 12/06/2024 19:31, Ian Rogers wrote:
> Refactor the perf python module build to instead of building C files
> it links libraries. To support this make static libraries for tests,
> ui, util and pmu-events. Doing this allows fewer functions to be
> stubbed out, importantly parse_events is no longer stubbed out which
> will improve the ability to work with heterogeneous cores.
>
> Patches 1 to 5 add static libraries for existing parts of the perf
> build.
>
> Patch 6 adds the python build using libraries rather than C source
> files.
>
> Patch 7 cleans up the python dependencies and removes the no longer
> needed python-ext-sources.
>

Reviewed-by: James Clark <[email protected]>

It does require a clean build to avoid some -fPIC errors presumably
because not everything that requires it gets rebuilt, for anyone who
gets stuck on that.

> Ian Rogers (7):
> perf ui: Make ui its own library
> perf pmu-events: Make pmu-events a library
> perf test: Make tests its own library
> perf bench: Make bench its own library
> perf util: Make util its own library
> perf python: Switch module to linking libraries from building source
> perf python: Clean up build dependencies
>
> tools/perf/Build | 14 +-
> tools/perf/Makefile.config | 5 +
> tools/perf/Makefile.perf | 66 ++-
> tools/perf/arch/Build | 4 +-
> tools/perf/arch/arm/Build | 4 +-
> tools/perf/arch/arm/tests/Build | 8 +-
> tools/perf/arch/arm/util/Build | 10 +-
> tools/perf/arch/arm64/Build | 4 +-
> tools/perf/arch/arm64/tests/Build | 8 +-
> tools/perf/arch/arm64/util/Build | 20 +-
> tools/perf/arch/csky/Build | 2 +-
> tools/perf/arch/csky/util/Build | 6 +-
> tools/perf/arch/loongarch/Build | 2 +-
> tools/perf/arch/loongarch/util/Build | 8 +-
> tools/perf/arch/mips/Build | 2 +-
> tools/perf/arch/mips/util/Build | 6 +-
> tools/perf/arch/powerpc/Build | 4 +-
> tools/perf/arch/powerpc/tests/Build | 6 +-
> tools/perf/arch/powerpc/util/Build | 24 +-
> tools/perf/arch/riscv/Build | 2 +-
> tools/perf/arch/riscv/util/Build | 8 +-
> tools/perf/arch/s390/Build | 2 +-
> tools/perf/arch/s390/util/Build | 16 +-
> tools/perf/arch/sh/Build | 2 +-
> tools/perf/arch/sh/util/Build | 2 +-
> tools/perf/arch/sparc/Build | 2 +-
> tools/perf/arch/sparc/util/Build | 2 +-
> tools/perf/arch/x86/Build | 6 +-
> tools/perf/arch/x86/tests/Build | 20 +-
> tools/perf/arch/x86/util/Build | 42 +-
> tools/perf/bench/Build | 46 +-
> tools/perf/scripts/Build | 4 +-
> tools/perf/scripts/perl/Perf-Trace-Util/Build | 2 +-
> .../perf/scripts/python/Perf-Trace-Util/Build | 2 +-
> tools/perf/tests/Build | 140 +++----
> tools/perf/tests/workloads/Build | 12 +-
> tools/perf/ui/Build | 18 +-
> tools/perf/ui/browsers/Build | 14 +-
> tools/perf/ui/tui/Build | 8 +-
> tools/perf/util/Build | 394 +++++++++---------
> tools/perf/util/arm-spe-decoder/Build | 2 +-
> tools/perf/util/cs-etm-decoder/Build | 2 +-
> tools/perf/util/hisi-ptt-decoder/Build | 2 +-
> tools/perf/util/intel-pt-decoder/Build | 2 +-
> tools/perf/util/perf-regs-arch/Build | 18 +-
> tools/perf/util/python-ext-sources | 53 ---
> tools/perf/util/python.c | 271 +++++-------
> tools/perf/util/scripting-engines/Build | 4 +-
> tools/perf/util/setup.py | 33 +-
> 49 files changed, 612 insertions(+), 722 deletions(-)
> delete mode 100644 tools/perf/util/python-ext-sources
>

2024-06-13 14:15:56

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH v1 0/7] Refactor perf python module build

On Thu, Jun 13, 2024 at 10:27:15AM +0100, James Clark wrote:
> On 12/06/2024 19:31, Ian Rogers wrote:
> > Refactor the perf python module build to instead of building C files
> > it links libraries. To support this make static libraries for tests,
> > ui, util and pmu-events. Doing this allows fewer functions to be
> > stubbed out, importantly parse_events is no longer stubbed out which
> > will improve the ability to work with heterogeneous cores.
> >
> > Patches 1 to 5 add static libraries for existing parts of the perf
> > build.
> >
> > Patch 6 adds the python build using libraries rather than C source
> > files.
> >
> > Patch 7 cleans up the python dependencies and removes the no longer
> > needed python-ext-sources.
> >
>
> Reviewed-by: James Clark <[email protected]>
>
> It does require a clean build to avoid some -fPIC errors presumably
> because not everything that requires it gets rebuilt, for anyone who
> gets stuck on that.

We need to find a way to avoid requiring the 'make clean' :-/

- Arnaldo

> > Ian Rogers (7):
> > perf ui: Make ui its own library
> > perf pmu-events: Make pmu-events a library
> > perf test: Make tests its own library
> > perf bench: Make bench its own library
> > perf util: Make util its own library
> > perf python: Switch module to linking libraries from building source
> > perf python: Clean up build dependencies
> >
> > tools/perf/Build | 14 +-
> > tools/perf/Makefile.config | 5 +
> > tools/perf/Makefile.perf | 66 ++-
> > tools/perf/arch/Build | 4 +-
> > tools/perf/arch/arm/Build | 4 +-
> > tools/perf/arch/arm/tests/Build | 8 +-
> > tools/perf/arch/arm/util/Build | 10 +-
> > tools/perf/arch/arm64/Build | 4 +-
> > tools/perf/arch/arm64/tests/Build | 8 +-
> > tools/perf/arch/arm64/util/Build | 20 +-
> > tools/perf/arch/csky/Build | 2 +-
> > tools/perf/arch/csky/util/Build | 6 +-
> > tools/perf/arch/loongarch/Build | 2 +-
> > tools/perf/arch/loongarch/util/Build | 8 +-
> > tools/perf/arch/mips/Build | 2 +-
> > tools/perf/arch/mips/util/Build | 6 +-
> > tools/perf/arch/powerpc/Build | 4 +-
> > tools/perf/arch/powerpc/tests/Build | 6 +-
> > tools/perf/arch/powerpc/util/Build | 24 +-
> > tools/perf/arch/riscv/Build | 2 +-
> > tools/perf/arch/riscv/util/Build | 8 +-
> > tools/perf/arch/s390/Build | 2 +-
> > tools/perf/arch/s390/util/Build | 16 +-
> > tools/perf/arch/sh/Build | 2 +-
> > tools/perf/arch/sh/util/Build | 2 +-
> > tools/perf/arch/sparc/Build | 2 +-
> > tools/perf/arch/sparc/util/Build | 2 +-
> > tools/perf/arch/x86/Build | 6 +-
> > tools/perf/arch/x86/tests/Build | 20 +-
> > tools/perf/arch/x86/util/Build | 42 +-
> > tools/perf/bench/Build | 46 +-
> > tools/perf/scripts/Build | 4 +-
> > tools/perf/scripts/perl/Perf-Trace-Util/Build | 2 +-
> > .../perf/scripts/python/Perf-Trace-Util/Build | 2 +-
> > tools/perf/tests/Build | 140 +++----
> > tools/perf/tests/workloads/Build | 12 +-
> > tools/perf/ui/Build | 18 +-
> > tools/perf/ui/browsers/Build | 14 +-
> > tools/perf/ui/tui/Build | 8 +-
> > tools/perf/util/Build | 394 +++++++++---------
> > tools/perf/util/arm-spe-decoder/Build | 2 +-
> > tools/perf/util/cs-etm-decoder/Build | 2 +-
> > tools/perf/util/hisi-ptt-decoder/Build | 2 +-
> > tools/perf/util/intel-pt-decoder/Build | 2 +-
> > tools/perf/util/perf-regs-arch/Build | 18 +-
> > tools/perf/util/python-ext-sources | 53 ---
> > tools/perf/util/python.c | 271 +++++-------
> > tools/perf/util/scripting-engines/Build | 4 +-
> > tools/perf/util/setup.py | 33 +-
> > 49 files changed, 612 insertions(+), 722 deletions(-)
> > delete mode 100644 tools/perf/util/python-ext-sources
> >

2024-06-13 15:11:09

by James Clark

[permalink] [raw]
Subject: Re: [PATCH v1 0/7] Refactor perf python module build



On 13/06/2024 15:15, Arnaldo Carvalho de Melo wrote:
> On Thu, Jun 13, 2024 at 10:27:15AM +0100, James Clark wrote:
>> On 12/06/2024 19:31, Ian Rogers wrote:
>>> Refactor the perf python module build to instead of building C files
>>> it links libraries. To support this make static libraries for tests,
>>> ui, util and pmu-events. Doing this allows fewer functions to be
>>> stubbed out, importantly parse_events is no longer stubbed out which
>>> will improve the ability to work with heterogeneous cores.
>>>
>>> Patches 1 to 5 add static libraries for existing parts of the perf
>>> build.
>>>
>>> Patch 6 adds the python build using libraries rather than C source
>>> files.
>>>
>>> Patch 7 cleans up the python dependencies and removes the no longer
>>> needed python-ext-sources.
>>>
>>
>> Reviewed-by: James Clark <[email protected]>
>>
>> It does require a clean build to avoid some -fPIC errors presumably
>> because not everything that requires it gets rebuilt, for anyone who
>> gets stuck on that.
>
> We need to find a way to avoid requiring the 'make clean' :-/
>
> - Arnaldo
>

Do we need to make it so that if any of the Makefiles are touched it
does a clean? I'm assuming that was the cause of the issue I experienced
here and that the Makefile and/or Build files aren't mentioned as
dependencies of any target.

>>> Ian Rogers (7):
>>> perf ui: Make ui its own library
>>> perf pmu-events: Make pmu-events a library
>>> perf test: Make tests its own library
>>> perf bench: Make bench its own library
>>> perf util: Make util its own library
>>> perf python: Switch module to linking libraries from building source
>>> perf python: Clean up build dependencies
>>>
>>> tools/perf/Build | 14 +-
>>> tools/perf/Makefile.config | 5 +
>>> tools/perf/Makefile.perf | 66 ++-
>>> tools/perf/arch/Build | 4 +-
>>> tools/perf/arch/arm/Build | 4 +-
>>> tools/perf/arch/arm/tests/Build | 8 +-
>>> tools/perf/arch/arm/util/Build | 10 +-
>>> tools/perf/arch/arm64/Build | 4 +-
>>> tools/perf/arch/arm64/tests/Build | 8 +-
>>> tools/perf/arch/arm64/util/Build | 20 +-
>>> tools/perf/arch/csky/Build | 2 +-
>>> tools/perf/arch/csky/util/Build | 6 +-
>>> tools/perf/arch/loongarch/Build | 2 +-
>>> tools/perf/arch/loongarch/util/Build | 8 +-
>>> tools/perf/arch/mips/Build | 2 +-
>>> tools/perf/arch/mips/util/Build | 6 +-
>>> tools/perf/arch/powerpc/Build | 4 +-
>>> tools/perf/arch/powerpc/tests/Build | 6 +-
>>> tools/perf/arch/powerpc/util/Build | 24 +-
>>> tools/perf/arch/riscv/Build | 2 +-
>>> tools/perf/arch/riscv/util/Build | 8 +-
>>> tools/perf/arch/s390/Build | 2 +-
>>> tools/perf/arch/s390/util/Build | 16 +-
>>> tools/perf/arch/sh/Build | 2 +-
>>> tools/perf/arch/sh/util/Build | 2 +-
>>> tools/perf/arch/sparc/Build | 2 +-
>>> tools/perf/arch/sparc/util/Build | 2 +-
>>> tools/perf/arch/x86/Build | 6 +-
>>> tools/perf/arch/x86/tests/Build | 20 +-
>>> tools/perf/arch/x86/util/Build | 42 +-
>>> tools/perf/bench/Build | 46 +-
>>> tools/perf/scripts/Build | 4 +-
>>> tools/perf/scripts/perl/Perf-Trace-Util/Build | 2 +-
>>> .../perf/scripts/python/Perf-Trace-Util/Build | 2 +-
>>> tools/perf/tests/Build | 140 +++----
>>> tools/perf/tests/workloads/Build | 12 +-
>>> tools/perf/ui/Build | 18 +-
>>> tools/perf/ui/browsers/Build | 14 +-
>>> tools/perf/ui/tui/Build | 8 +-
>>> tools/perf/util/Build | 394 +++++++++---------
>>> tools/perf/util/arm-spe-decoder/Build | 2 +-
>>> tools/perf/util/cs-etm-decoder/Build | 2 +-
>>> tools/perf/util/hisi-ptt-decoder/Build | 2 +-
>>> tools/perf/util/intel-pt-decoder/Build | 2 +-
>>> tools/perf/util/perf-regs-arch/Build | 18 +-
>>> tools/perf/util/python-ext-sources | 53 ---
>>> tools/perf/util/python.c | 271 +++++-------
>>> tools/perf/util/scripting-engines/Build | 4 +-
>>> tools/perf/util/setup.py | 33 +-
>>> 49 files changed, 612 insertions(+), 722 deletions(-)
>>> delete mode 100644 tools/perf/util/python-ext-sources
>>>

2024-06-13 16:55:42

by Ian Rogers

[permalink] [raw]
Subject: Re: [PATCH v1 0/7] Refactor perf python module build

On Thu, Jun 13, 2024 at 8:10 AM James Clark <[email protected]> wrote:
[...]
> >> Reviewed-by: James Clark <[email protected]>
> >>
> >> It does require a clean build to avoid some -fPIC errors presumably
> >> because not everything that requires it gets rebuilt, for anyone who
> >> gets stuck on that.
> >
> > We need to find a way to avoid requiring the 'make clean' :-/
> >
> > - Arnaldo
> >
>
> Do we need to make it so that if any of the Makefiles are touched it
> does a clean? I'm assuming that was the cause of the issue I experienced
> here and that the Makefile and/or Build files aren't mentioned as
> dependencies of any target.

Perhaps we can do something with the FEATURE_DUMP. It'd be nice to
detect build argument changes and rebuild when that occurs. I'm used
to doing lots of `make clean` due to sanitizer builds, something we
should probably capture through features and/or `perf version
--build-options`. Anyway, out-of-scope for these patches.

I need to cut a v2 due to failing to add the new `.a` files to the clean target.

Thanks for the review,
Ian