On Thu, May 21, 2026 at 10:50 AM Ian Rogers <[email protected]> wrote:
>
> On Thu, May 21, 2026 at 7:57 AM Ben Hutchings <[email protected]> wrote:
> >
> > perf and rtla currently don't fully support out-of-tree builds, as
> > they may still create files in their source directory.  This series
> > fixes all the instances of this problem that I have found.
> >
> > Ben.
>
> Thanks for the cleanup! I ran Sashiko locally and it noted that we
> should also fix the clean steps to remove these files (I'll copy the
> full text below).
> Reviewed-by: Ian Rogers <[email protected]>

Hi Ben,

Did you make any progress on this? Checking upstream I don't see the
patches as landed and they look useful.

Thanks,
Ian


> ```
> commit cf212be834ce6b0df5cccdbc4ad977a917ff8e48
>    Author: Ben Hutchings <[email protected]>
>
>    perf tools: Put Python egg info in output directory
>
>    Installing the Python extension currently creates an egg-info
>    directory in the source tree, preventing a fully out-of-tree build.
>
>    Add the necessary runes to the setup.py comamnd line to relocate the
>    egg-info directory in an out-of-tree build.
>
>    > diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
>    > index fc92d6ceac5b..b9a9bdddb89a 100644
>    > --- a/tools/perf/Makefile.perf
>    > +++ b/tools/perf/Makefile.perf
>    > @@ -905,7 +910,9 @@ install-bin: install-tools install-tests
>    >  install: install-bin try-install-man
>    >
>    >  install-python_ext:
>    > -       $(PYTHON_WORD) util/setup.py --quiet install
> --root='/$(DESTDIR_SQ)'
>    > +       $(PYTHON_WORD) util/setup.py --quiet \
>    > +               $(if $(OUTPUT),egg_info --egg-base $(OUTPUT)) \
>    > +               install --root='/$(DESTDIR_SQ)'
>
>    This relocates the egg-info directory to the output directory, which
>    helps keep the source tree clean. However, does the `python-clean`
>    target need to be updated to clean up this directory?
>
>    Currently, `python-clean` is defined as:
>
>    python-clean := $(call QUIET_CLEAN, python) $(RM) -r
> $(PYTHON_EXTBUILD) $(OUTPUT)python/perf*.so
>
>    Should we also clean `$(OUTPUT)/perf.egg-info` (or `perf.egg-info` for
>    in-tree builds) to ensure `make clean` removes all generated python
>    metadata? For example:
>
>    python-clean := $(call QUIET_CLEAN, python) \
>                    $(RM) -r $(PYTHON_EXTBUILD) $(OUTPUT)python/perf*.so \
>                    $(OUTPUT)perf.egg-info perf.egg-info
>
>    commit dd754ea75966ec7ade41500afeb32d944f20a8f9
>    Author: Ben Hutchings <[email protected]>
>
>    perf tools: Put Python bytecode in output directory
>
>    The PMU events are processed into C sources by Python scripts,
> which
>    normally results in writing bytecode for each module into the
> source
>    tree.  This prevents a fully out-of-tree build.
>
>    To fix this, set $PYTHONPYCACHEPREFIX to relocate the bytecode cache
>    directory in an out-of-tree build.
>
>    > diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
>    > index fc92d6ceac5b..b9a9bdddb89a 100644
>    > --- a/tools/perf/Makefile.perf
>    > +++ b/tools/perf/Makefile.perf
>    > @@ -400,6 +400,11 @@ PYTHON_EXTBUILD_LIB :=
> $(PYTHON_EXTBUILD)lib/
>    >  PYTHON_EXTBUILD_TMP := $(PYTHON_EXTBUILD)tmp/
>    >  export PYTHON_EXTBUILD_LIB PYTHON_EXTBUILD_TMP
>    >
>    > +# Put Python bytecode in output directory
>    > +ifdef OUTPUT
>    > +export PYTHONPYCACHEPREFIX := $(OUTPUT)/__pycache__
>    > +endif
>    > +
>    >  python-clean := $(call QUIET_CLEAN, python) $(RM) -r
> $(PYTHON_EXTBUILD) $(OUTPUT)python/perf*.so
>
>    Similar to the egg-info relocation, does `python-clean` need to
> clean up
>    the relocated `__pycache__` directory under `$(OUTPUT)`?
>
>    If `PYTHONPYCACHEPREFIX` is exported to `$(OUTPUT)/__pycache__`, running
>    `make clean` currently leaves this directory behind. Should we add it to
>    the `RM` list in `python-clean`? For example:
>
>    python-clean := $(call QUIET_CLEAN, python) \
>                    $(RM) -r $(PYTHON_EXTBUILD)
> $(OUTPUT)python/perf*.so \
>                    $(if $(OUTPUT),$(OUTPUT)/__pycache__)
> ```
>
> Thanks,
> Ian
>
> > Ben Hutchings (3):
> >   rtla: Fix output files in source tree
> >   perf tools: Put Python egg info in output directory
> >   perf tools: Put Python bytecode in output directory
> >
> >  tools/perf/Makefile.perf            |  9 ++++++++-
> >  tools/tracing/rtla/Makefile         | 31 ++++++++++++++++++-----------
> >  tools/tracing/rtla/tests/timerlat.t |  4 ++--
> >  3 files changed, 29 insertions(+), 15 deletions(-)
> >

Reply via email to