From: sashiko-bot@kernel.org
To: "Bochao Cao" <bochaolucky@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net-next v6 4/5] selftests/net: Add a shared BPF skeleton rule
Date: Mon, 19 Oct 2026 14:08:29 +0000 [thread overview]
Message-ID: <sashiko-outbox-177301@kernel.org> (raw)
In-Reply-To: <20261018-xdp-v5-send-20261008-v6-4-7336e1282ca3@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] selftests/net: bpf.mk ignores LLVM when setting HOSTCC and HOSTLD for bpftool
--
commit 710ef769e16adaffb164124378ccc9076be7c9c1
Author: Bochao Cao <bochaolucky@gmail.com>
selftests/net: Add a shared BPF skeleton rule
This commit adds a shared rule to tools/testing/selftests/net/bpf.mk for
generating BPF skeletons, builds a host bootstrap bpftool when BPFTOOL is
not supplied, and adjusts header includes and submake variables.
> diff --git a/tools/testing/selftests/net/bpf.mk b/tools/testing/selftests/net/bpf.mk
> index a4f6755dd8941..016e32960280a 100644
> --- a/tools/testing/selftests/net/bpf.mk
> +++ b/tools/testing/selftests/net/bpf.mk
[ ... ]
> @@ -46,8 +46,37 @@ $(BPFOBJ): $(wildcard $(BPFDIR)/*.[ch] $(BPFDIR)/Makefile) \
> $(APIDIR)/linux/bpf.h \
> | $(BUILD_DIR)/libbpf
> $(call msg,MAKE,,$@)
> - $(Q)$(MAKE) $(submake_extras) -C $(BPFDIR) OUTPUT=$(BUILD_DIR)/libbpf/ \
> + $(Q)$(MAKE) $(submake_extras) -C $(BPFDIR) srctree=$(abspath $(top_srcdir)) \
> + OUTPUT=$(BUILD_DIR)/libbpf/ \
> EXTRA_CFLAGS='-g -O0' \
> DESTDIR=$(SCRATCH_DIR) prefix= all install_headers
>
> EXTRA_CLEAN += $(SCRATCH_DIR)
> +
> +# Build a host bpftool only when a test needs a generated skeleton.
> +HOSTCC ?= gcc
> +HOSTLD ?= ld
> +BPFTOOL_BUILD := $(BUILD_DIR)/bpftool
> +ifeq ($(origin BPFTOOL),undefined)
> +BPFTOOL := $(BPFTOOL_BUILD)/bootstrap/bpftool
> +BPFTOOL_DEP := $(BPFTOOL)
> +else
> +BPFTOOL_DEP := $(shell command -v $(BPFTOOL))
> +endif
> +
> +$(BPFTOOL_BUILD)/bootstrap/bpftool: \
> + $(wildcard $(top_srcdir)/tools/bpf/bpftool/*.[ch]) \
> + $(top_srcdir)/tools/bpf/bpftool/Makefile \
> + $(wildcard $(BPFDIR)/*.[ch] $(BPFDIR)/Makefile)
> + $(call msg,MAKE,,$@)
> + $(Q)mkdir -p $(BPFTOOL_BUILD)
> + $(Q)$(MAKE) $(submake_extras) -C $(top_srcdir)/tools/bpf/bpftool \
> + OUTPUT=$(BPFTOOL_BUILD)/ srctree=$(abspath $(top_srcdir)) \
> + ARCH= CROSS_COMPILE= CC="$(HOSTCC)" LD="$(HOSTLD)" bootstrap
[Severity: Medium]
When building with LLVM=1, will defaulting HOSTCC to gcc and HOSTLD to ld
and passing them as CC and LD to the bpftool submake cause a toolchain
mismatch or fail on LLVM-only hosts?
Makefiles that include tools/testing/selftests/net/bpf.mk include
tools/testing/selftests/lib.mk first, which handles LLVM= by setting
LLVM_PREFIX, LLVM_SUFFIX, CLANG, and CC, but does not define HOSTCC or
HOSTLD. Because tools/testing/selftests/net/bpf.mk defaults HOSTCC ?= gcc
and HOSTLD ?= ld without checking LLVM, the $(BPFTOOL_BUILD)/bootstrap/bpftool
recipe passes CC="gcc" and LD="ld" on the submake command line without
passing HOSTCC or HOSTLD.
Inside tools/bpf/bpftool/Makefile, tools/scripts/Makefile.include processes
LLVM= from MAKEFLAGS:
$(call allow-override,CC,$(LLVM_PREFIX)clang$(LLVM_SUFFIX))
$(call allow-override,CLANG,$(LLVM_PREFIX)clang$(LLVM_SUFFIX))
$(call allow-override,HOSTCC,$(LLVM_PREFIX)clang$(LLVM_SUFFIX))
$(call allow-override,AR,$(LLVM_PREFIX)llvm-ar$(LLVM_SUFFIX))
$(call allow-override,HOSTAR,$(LLVM_PREFIX)llvm-ar$(LLVM_SUFFIX))
$(call allow-override,LD,$(LLVM_PREFIX)ld.lld$(LLVM_SUFFIX))
$(call allow-override,HOSTLD,$(LLVM_PREFIX)ld.lld$(LLVM_SUFFIX))
Because CC and LD have command-line origin, allow-override leaves them as
gcc and ld, while HOSTCC and HOSTLD resolve to clang and ld.lld. As a
result, tools/bpf/bpftool/Makefile compiles bootstrap/bpftool with
HOSTCC=clang, while CC_NO_CLANG in tools/scripts/Makefile.include and
feature-libelf-zstd in tools/build/Makefile.feature probe CC=gcc (enabling
GCC-only warning flags in EXTRA_WARNINGS and HOST_CFLAGS, or failing when
gcc is not installed).
Should HOSTCC and HOSTLD account for LLVM (or be passed through to the
submake as HOSTCC and HOSTLD after honoring LLVM)?
[ ... ]
>
>--
>2.51.0
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261018-xdp-v5-send-20261008-v6-0-7336e1282ca3@gmail.com?part=4
next prev parent reply other threads:[~2026-10-19 14:08 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-18 14:05 [PATCH net-next v6 0/5] selftests: Fix and migrate the XDP feature test Bochao Cao via B4 Relay
2026-10-18 14:05 ` Bochao Cao
2026-10-18 14:05 ` [PATCH net-next v6 1/5] selftests/bpf: Fix XDP feature test setup and teardown Bochao Cao via B4 Relay
2026-10-18 14:05 ` Bochao Cao
2026-10-19 14:55 ` netdev-bot+sashiko
2026-10-18 14:05 ` [PATCH net-next v6 2/5] selftests/bpf: Track XDP test processes and isolate namespaces Bochao Cao via B4 Relay
2026-10-18 14:05 ` Bochao Cao
2026-10-19 14:55 ` netdev-bot+sashiko
2026-10-18 14:05 ` [PATCH net-next v6 3/5] selftests/bpf: Send XDP feature probes with AF_PACKET Bochao Cao via B4 Relay
2026-10-18 14:05 ` Bochao Cao
2026-10-19 14:55 ` netdev-bot+sashiko
2026-10-18 14:05 ` [PATCH net-next v6 4/5] selftests/net: Add a shared BPF skeleton rule Bochao Cao via B4 Relay
2026-10-18 14:05 ` Bochao Cao
2026-10-19 14:08 ` sashiko-bot [this message]
2026-10-19 14:55 ` netdev-bot+sashiko
2026-10-18 14:05 ` [PATCH net-next v6 5/5] selftests/net: Move the XDP feature test to drivers/net/hw Bochao Cao via B4 Relay
2026-10-18 14:05 ` Bochao Cao
2026-10-19 14:55 ` netdev-bot+sashiko
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=sashiko-outbox-177301@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bochaolucky@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=sashiko-reviews@lists.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.