Re: [PATCH 1/2] perf build: Autodetect minimum required llvm-dev version

From: Arnaldo Carvalho de Melo
Date: Tue Sep 10 2024 - 15:07:03 EST


On Tue, Sep 10, 2024 at 05:53:16PM +0100, Quentin Monnet wrote:
> 2024-09-10 16:11 UTC+0100 ~ James Clark <james.clark@xxxxxxxxxx>
> >
> >
> > On 9/10/24 15:27, Quentin Monnet wrote:
> > > 2024-09-10 15:04 UTC+0100 ~ James Clark <james.clark@xxxxxxxxxx>
> > > > The new LLVM addr2line feature requires a minimum version of 13 to
> > > > compile. Add a feature check for the version so that NO_LLVM=1 doesn't
> > > > need to be explicitly added. Leave the existing llvm feature check
> > > > intact because it's used by tools other than Perf.
> > > >
> > > > This fixes the following compilation error when the llvm-dev version
> > > > doesn't match:
> > > >
> > > >    util/llvm-c-helpers.cpp: In function 'char*
> > > > llvm_name_for_code(dso*, const char*, u64)':
> > > >    util/llvm-c-helpers.cpp:178:21: error:
> > > > 'std::remove_reference_t<llvm::DILineInfo>' {aka 'struct
> > > > llvm::DILineInfo'} has no member named 'StartAddress'
> > > >      178 |   addr, res_or_err->StartAddress ? *res_or_err-
> > > > >StartAddress : 0);
> > > >
> > > > Fixes: c3f8644c21df ("perf report: Support LLVM for addr2line()")
> > > > Signed-off-by: James Clark <james.clark@xxxxxxxxxx>
> > > > ---
> > > >   tools/build/Makefile.feature           |  2 +-
> > > >   tools/build/feature/Makefile           |  9 +++++++++
> > > >   tools/build/feature/test-llvm-perf.cpp | 14 ++++++++++++++
> > > >   tools/perf/Makefile.config             |  6 +++---
> > > >   4 files changed, 27 insertions(+), 4 deletions(-)
> > > >   create mode 100644 tools/build/feature/test-llvm-perf.cpp
> > > >
> > > > diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
> > > > index 0717e96d6a0e..427a9389e26c 100644
> > > > --- a/tools/build/Makefile.feature
> > > > +++ b/tools/build/Makefile.feature
> > > > @@ -136,7 +136,7 @@ FEATURE_DISPLAY ?=              \
> > > >            libunwind              \
> > > >            libdw-dwarf-unwind     \
> > > >            libcapstone            \
> > > > -         llvm                   \
> > > > +         llvm-perf              \
> > >
> > > Hi! Just a quick question, why remove "llvm" from the list, here?
> > >
> > > Quentin
> >
> > Just because with respect to the linked fixes: commit, it wasn't
> > actually there before. It was added just for addr2line so it should
> > probably be llvm-perf rather than the generic one.
> >
> > But yes we can add llvm output if it's useful, but could probably be a
> > separate commit.

> It wasn't there before, but you're not removing the rest of the "llvm"
> feature, so I'd expect that part to stay as well? But I don't mind much. We
> use the "llvm" feature in bpftool, but beyond that, I don't personally need
> it to be displayed in tools/build/Makefile.feature, so no need to respin for
> that :)

My worry was that something were being removed because it wasn't being
used in tools/perf/ only to realize later that that was being used
somewhere else in tools/.

That is not the case as you reported, so going back to what we had
before the addr2line llvm code being introduced, i.e.:

commit c3f8644c21df9b7db97eb70e08e2826368aaafa0
Author: Steinar H. Gunderson <sesse@xxxxxxxxxx>
Date: Sat Aug 3 17:20:06 2024 +0200

perf report: Support LLVM for addr2line()

Just did:

+++ b/tools/build/Makefile.feature
@@ -136,6 +136,7 @@ FEATURE_DISPLAY ?= \
libunwind \
libdw-dwarf-unwind \
libcapstone \
+ llvm \
zlib \
lzma \
get_cpuid \

So just displaying whatever was detected, and now we display the new
llvm-perf, so that should be ok, probably even for bpftool, its just
requires a newer version of llvm-dev, right?

- Arnaldo