From: Ihor Solodrai <ihor.solodrai@linux.dev>
To: James Clark <james.clark@linaro.org>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>,
Bill Wendling <morbo@google.com>,
Justin Stitt <justinstitt@google.com>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Eduard Zingerman <eddyz87@gmail.com>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>,
Martin KaFai Lau <martin.lau@linux.dev>,
Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
Jiri Olsa <jolsa@kernel.org>,
Emil Tsalapatis <emil@etsalapatis.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Shuah Khan <shuah@kernel.org>,
linux-kernel@vger.kernel.org, llvm@lists.linux.dev,
bpf@vger.kernel.org, linux-perf-users@vger.kernel.org,
linux-kselftest@vger.kernel.org
Subject: Re: [PATCH v4 3/4] tools/build: Allow versioning LLVM readelf
Date: Wed, 15 Jul 2026 13:00:58 -0700 [thread overview]
Message-ID: <1a3378d8-2148-488f-a385-a20335553a9c@linux.dev> (raw)
In-Reply-To: <20260715-james-perf-llvm-version-v4-3-6dfdf984b435@linaro.org>
On 7/15/26 7:53 AM, James Clark wrote:
> Documentation/kbuild/llvm.rst mentions that readelf is included in the
> LLVM toolchain, but it's not currently included in this block.
>
> Add it so that LLVM=... options also apply to readelf. Users in tools/
> were Perf which was hardcoding it, and another was the BPF makefile.
> Both already include Makefile.include so convert them to use the new
> variables.
>
> Where readelf wasn't doing anything arch specific, use HOSTREADELF
> because it's more likely to be installed.
>
> Reviewed-by: Ian Rogers <irogers@google.com>
> Signed-off-by: James Clark <james.clark@linaro.org>
> ---
> tools/lib/bpf/Makefile | 8 ++++----
> tools/perf/Makefile.perf | 1 -
> tools/scripts/Makefile.include | 4 ++++
> 3 files changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile
> index eca584fb061e16013e76827e4203f6be0477a73e..269fe21fc8da73083367b3c122bdd2b718e12bc5 100644
> --- a/tools/lib/bpf/Makefile
> +++ b/tools/lib/bpf/Makefile
> @@ -115,12 +115,12 @@ PC_FILE := $(addprefix $(OUTPUT),$(PC_FILE))
>
> TAGS_PROG := $(if $(shell which etags 2>/dev/null),etags,ctags)
>
> -GLOBAL_SYM_COUNT = $(shell readelf -s --wide $(BPF_IN_SHARED) | \
> +GLOBAL_SYM_COUNT = $(shell $(HOSTREADELF) -s --wide $(BPF_IN_SHARED) | \
> cut -d "@" -f1 | sed 's/_v[0-9]_[0-9]_[0-9].*//' | \
> sed 's/\[.*\]//' | \
> awk '/GLOBAL/ && /DEFAULT/ && !/UND|ABS/ {print $$NF}' | \
> sort -u | wc -l)
> -VERSIONED_SYM_COUNT = $(shell readelf --dyn-syms --wide $(OUTPUT)libbpf.so | \
> +VERSIONED_SYM_COUNT = $(shell $(HOSTREADELF) --dyn-syms --wide $(OUTPUT)libbpf.so | \
> sed 's/\[.*\]//' | \
> awk '/GLOBAL/ && /DEFAULT/ && !/UND|ABS/ {print $$NF}' | \
> grep -Eo '[^ ]+@LIBBPF_' | cut -d@ -f1 | sort -u | wc -l)
> @@ -183,12 +183,12 @@ check_abi: $(OUTPUT)libbpf.so $(VERSION_SCRIPT)
> "versioned symbols in $^ ($(VERSIONED_SYM_COUNT))." \
> "Please make sure all LIBBPF_API symbols are" \
> "versioned in $(VERSION_SCRIPT)." >&2; \
> - readelf -s --wide $(BPF_IN_SHARED) | \
> + $(HOSTREADELF) -s --wide $(BPF_IN_SHARED) | \
> cut -d "@" -f1 | sed 's/_v[0-9]_[0-9]_[0-9].*//' | \
> sed 's/\[.*\]//' | \
> awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print $$NF}'| \
> sort -u > $(OUTPUT)libbpf_global_syms.tmp; \
> - readelf --dyn-syms --wide $(OUTPUT)libbpf.so | \
> + $(HOSTREADELF) --dyn-syms --wide $(OUTPUT)libbpf.so | \
Acked-by: Ihor Solodrai <ihor.solodrai@linux.dev>
Thanks!
> sed 's/\[.*\]//' | \
> awk '/GLOBAL/ && /DEFAULT/ && !/UND|ABS/ {print $$NF}'| \
> grep -Eo '[^ ]+@LIBBPF_' | cut -d@ -f1 | \
> diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf> index 476b8dcaef58cb1f3fa75f46a647c2cfe2352767..4d0d7ae02e06b117487a17691c4e62a138428ac5 100644
> --- a/tools/perf/Makefile.perf
> +++ b/tools/perf/Makefile.perf
> @@ -215,7 +215,6 @@ FLEX ?= flex
> BISON ?= bison
> STRIP = strip
> AWK = awk
> -READELF ?= readelf
>
> # include Makefile.config by default and rule out
> # non-config cases
> diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include
> index e81e5b479c563321e458b2a7ad8fca2b4607a254..46a3872b87624a7bf475d9b42a3e471f36789dfd 100644
> --- a/tools/scripts/Makefile.include
> +++ b/tools/scripts/Makefile.include
> @@ -73,6 +73,8 @@ ifneq ($(LLVM),)
> $(call allow-override,LLC,$(LLVM_PREFIX)llc$(LLVM_SUFFIX))
> $(call allow-override,LLVM_CONFIG,$(LLVM_PREFIX)llvm-config$(LLVM_SUFFIX))
> $(call allow-override,LLVM_OBJCOPY,$(LLVM_PREFIX)llvm-objcopy$(LLVM_SUFFIX))
> + $(call allow-override,READELF,$(LLVM_PREFIX)llvm-readelf$(LLVM_SUFFIX))
> + $(call allow-override,HOSTREADELF,$(LLVM_PREFIX)llvm-readelf$(LLVM_SUFFIX))
> else
> # Allow setting various cross-compile vars or setting CROSS_COMPILE as a prefix.
> $(call allow-override,CC,$(CROSS_COMPILE)gcc)
> @@ -80,11 +82,13 @@ else
> $(call allow-override,LD,$(CROSS_COMPILE)ld)
> $(call allow-override,CXX,$(CROSS_COMPILE)g++)
> $(call allow-override,STRIP,$(CROSS_COMPILE)strip)
> + $(call allow-override,READELF,$(CROSS_COMPILE)readelf)
>
> # Host versions aren't prefixed
> $(call allow-override,HOSTAR,ar)
> $(call allow-override,HOSTCC,gcc)
> $(call allow-override,HOSTLD,ld)
> + $(call allow-override,HOSTREADELF,readelf)
>
> # Some tools still require Clang, LLC and/or LLVM utils
> $(call allow-override,CLANG,clang)
>
next prev parent reply other threads:[~2026-07-15 20:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-15 14:53 [PATCH v4 0/4] tools/build: Allow versioning of all LLVM tools James Clark
2026-07-15 14:53 ` [PATCH v4 1/4] tools/build: Allow versioning of all LLVM tools defined in Makefile.include James Clark
2026-07-15 14:53 ` [PATCH v4 2/4] tools/build: Indent if else blocks James Clark
2026-07-15 14:53 ` [PATCH v4 3/4] tools/build: Allow versioning LLVM readelf James Clark
2026-07-15 20:00 ` Ihor Solodrai [this message]
2026-07-15 14:53 ` [PATCH v4 4/4] tools/build: selftests: Remove some duplicate toolchain definitions James Clark
2026-07-15 20:02 ` Ihor Solodrai
2026-07-15 17:24 ` [PATCH v4 0/4] tools/build: Allow versioning of all LLVM tools Ian Rogers
2026-07-15 23:46 ` Namhyung Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1a3378d8-2148-488f-a385-a20335553a9c@linux.dev \
--to=ihor.solodrai@linux.dev \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=justinstitt@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=mark.rutland@arm.com \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=mingo@redhat.com \
--cc=morbo@google.com \
--cc=namhyung@kernel.org \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=peterz@infradead.org \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.