BPF List
 help / color / mirror / Atom feed
* [RFC PATCH bpf-next 0/3] selftests/bpf: restructure the Makefile as a layered build
@ 2026-07-21 17:49 Mykola Lysenko
  2026-07-21 17:49 ` [RFC PATCH bpf-next 1/3] selftests/bpf: extract BPF skeleton generation into a helper script Mykola Lysenko
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Mykola Lysenko @ 2026-07-21 17:49 UTC (permalink / raw)
  To: bpf
  Cc: ast, daniel, andrii, eddyz87, martin.lau, song, yonghong.song,
	jolsa, memxor, Mykola Lysenko

The BPF selftests Makefile has grown to ~1,100 lines, with much of the
complexity concentrated in the DEFINE_TEST_RUNNER double-expansion
machinery: the per-runner rules are written in $$-escaped make and
eval'd once per flavor, so the rules that actually run never appear in
the source, are invisible to make's own debugging facilities, and are
easy to break for one flavor while testing another.

This series restructures the build in three steps, each independently
buildable and each producing byte-identical artifacts:

  1) the four near-identical skeleton generation recipes move into a
     parameterized helper script (gen_bpf_skel.sh);
  2) shared (non-rule) definitions move into Makefile.buildvars;
  3) each test runner instance (test_progs, test_progs-<flavor>,
     test_maps) becomes its own plain-make sub-make (Makefile.runner),
     replacing the eval/escaping layer.

After the series the top Makefile owns everything that exists once
(toolchain setup, the libbpf/bpftool/resolve_btfids sub-builds,
vmlinux.h, shared helper objects, standalone binaries, and the lib.mk
run/install contract), while every runner instance is an ordinary
single-flavor makefile with no escaping. Total line count is roughly a
wash; the point is the structure, not the size.

Sent as RFC to gather feedback on the overall direction.

Validation (each patch, x86_64, identical toolchains, clean builds):
2,948/2,948 BPF objects, 5,352/5,352 skeleton headers and 1,413/1,413
userspace objects byte-identical to the current Makefile's output. For
the end state additionally: 20/22 binaries byte-identical, and the two
exceptions (bench, test_maps) differ only in object link order, proven
by relinking the current Makefile's objects in the new order and
comparing bytes; emit_tests output and the installed tree identical;
BPF CI green on a manual pre-submission run across x86_64 gcc/llvm,
aarch64 and s390x (including GCC-BPF, ASAN and veristat jobs); and all
76 benchmarks produce
identical outcomes on old- and new-built bench binaries.

Mykola Lysenko (3):
  selftests/bpf: extract BPF skeleton generation into a helper script
  selftests/bpf: move shared build definitions into Makefile.buildvars
  selftests/bpf: build each test runner instance in its own sub-make

 tools/testing/selftests/bpf/Makefile          | 942 +++++-------------
 .../testing/selftests/bpf/Makefile.buildvars  | 204 ++++
 tools/testing/selftests/bpf/Makefile.runner   | 313 ++++++
 tools/testing/selftests/bpf/gen_bpf_skel.sh   |  97 ++
 4 files changed, 874 insertions(+), 682 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/Makefile.buildvars
 create mode 100644 tools/testing/selftests/bpf/Makefile.runner
 create mode 100755 tools/testing/selftests/bpf/gen_bpf_skel.sh


base-commit: 0bcca2a42cc50b7d64a95c08dffc6b93661a7ea2
-- 
2.43.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-07-21 19:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-21 17:49 [RFC PATCH bpf-next 0/3] selftests/bpf: restructure the Makefile as a layered build Mykola Lysenko
2026-07-21 17:49 ` [RFC PATCH bpf-next 1/3] selftests/bpf: extract BPF skeleton generation into a helper script Mykola Lysenko
2026-07-21 17:57   ` sashiko-bot
2026-07-21 19:43     ` Mykola Lysenko
2026-07-21 17:49 ` [RFC PATCH bpf-next 2/3] selftests/bpf: move shared build definitions into Makefile.buildvars Mykola Lysenko
2026-07-21 17:49 ` [RFC PATCH bpf-next 3/3] selftests/bpf: build each test runner instance in its own sub-make Mykola Lysenko
2026-07-21 17:58   ` sashiko-bot
2026-07-21 19:43     ` Mykola Lysenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox