Skip to content

perf build: Support building BPF skeletons with bpf-gcc

Ian Rogers bpf linux-perf-users lkml 4 versions – Applied

Status from this message: Applied to perf-tools-next, thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest5 patches 1 replyApplied
  2. v32 patches 3 repliesSuperseded
  3. v22 patches 0 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v12 patches0 repliesSuperseded

Changes in v4 from the cover letter

- Rebase onto perf-tools-next and drop Assisted-by tags per commit

Patches in v4 Applied

#Subject and filesSizeRepliesApplied
1/5tools build: Fix version-ge3 and version-lt3 for <3-part versionstools/scripts/utilities.mak+2 -20 replies
2/5perf build: Sync bpf_skel.mak get_sys_includes with selftests/bpftools/perf/bpf_skel.mak+3 -10 replies
3/5perf build: Support building BPF skeletons with bpf-gcctools/perf/Makefile.config tools/perf/Makefile.perf tools/perf/bpf_skel.mak +1 more+96 -280 replies
4/5perf test make: Reuse Makefile.feature for libbfd and llvm probestools/perf/tests/make+24 -120 replies
5/5perf test make: Add BPF skeleton build tests for clang and bpf-gcctools/perf/tests/make+40 -20 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v4 yet.

Read the v4 thread

Cover letter [PATCH v4 0/5] perf build: Support building BPF skeletons with bpf-gcc

Currently the perf build requires clang (>= 12.0.1) to compile BPF skeleton programs (.bpf.c -> .bpf.o). bpf-gcc (>= 14.0.0) also supports BPF CO-RE and BTF generation and is already supported in tools/testing/selftests/bpf/Makefile.

This series updates the perf build to support both clang and bpf-gcc, broken into small bisectable commits:
- Patch 1 fixes version-ge3 and version-lt3 in tools/scripts/utilities.mak so empty or fewer-than-3-component version strings do not shift awk fields across arguments.
- Patch 2 syncs bpf_skel.mak's get_sys_includes with tools/testing/selftests/bpf/Makefile for LoongArch and MIPS.
- Patch 3 updates Makefile.config, Makefile.perf, and bpf_skel.mak to prefer bpf-gcc when building perf with GCC (CC_NO_CLANG=1) and clang when building with Clang/LLVM (CC_NO_CLANG=0), while respecting explicit BPF_GCC=... or CLANG=... command-line overrides and falling back to whichever compiler is available.
- Patch 4 introduces tools/build/Makefile.feature in tools/perf/tests/make and switches the existing libbfd and llvm probes to reuse libbfd-threadsafe and llvm-perf.
- Patch 5 adds make_bpf_skel_clang and make_bpf_skel_bpf_gcc build-test targets to tools/perf/tests/make and verifies with
'perf check -q feature bpf_skeletons' that BPF skeleton support is enabled (or disabled with exit code 1 for make_no_bpf_skel) as expected.

This series was developed and reviewed with assistance from an AI coding agent (Gemini 3.1 Pro) and reviewed with Sashiko.

v4:
- Rebase onto perf-tools-next and drop Assisted-by tags per commit

    1e035297ffda ("docs: remove Assisted-by references").

- Split the series into 5 smaller patches for bisection, separating the utilities.mak version-ge3/version-lt3 fix (requested by Namhyung Kim), the get_sys_includes sync, and the Makefile.feature refactoring in tools/perf/tests/make.
v3:
- Reuse tools/build/Makefile.feature and tools/scripts/utilities.mak in tools/perf/tests/make rather than open-coding compiler feature probes, and explicitly check for exit code 1 from 'perf check' in make_no_bpf_skel so crashes are not masked by shell negation.
v2:
- Pass only -dumpfullversion when querying BPF_GCC_VERSION, guard against an empty version string, and fix version-ge3 / version-lt3 in tools/scripts/utilities.mak so empty or <3-component version strings do not shift awk fields and evaluate as false in version-lt3.

Ian Rogers (5):
tools build: Fix version-ge3 and version-lt3 for <3-part versions perf build: Sync bpf_skel.mak get_sys_includes with selftests/bpf perf build: Support building BPF skeletons with bpf-gcc perf test make: Reuse Makefile.feature for libbfd and llvm probes perf test make: Add BPF skeleton build tests for clang and bpf-gcc

 tools/perf/Makefile.config     | 83 +++++++++++++++++++++++++++-------
 tools/perf/Makefile.perf       |  8 +++-
 tools/perf/bpf_skel.mak        | 36 ++++++++++-----
 tools/perf/tests/make          | 76 +++++++++++++++++++++++++------
 tools/scripts/Makefile.include |  1 +
 tools/scripts/utilities.mak    |  4 +-
 6 files changed, 164 insertions(+), 44 deletions(-)
Signature · 1 line
2.56.0.567.gdb80ae8cd5-goog