From: bot+bpf-ci@kernel.org
To: ziyang.meme@gmail.com,shuah@kernel.org,tj@kernel.org,hannes@cmpxchg.org,mkoutny@suse.com,jikos@kernel.org,bentiss@kernel.org,void@manifault.com,eddyz87@gmail.com
Cc: arighi@nvidia.com,changwoo@igalia.com,mhocko@kernel.org,roman.gushchin@linux.dev,shakeel.butt@linux.dev,muchun.song@linux.dev,akpm@linux-foundation.org,inwardvessel@gmail.com,mykolal@meta.com,nathan@kernel.org,linux-kselftest@vger.kernel.org,cgroups@vger.kernel.org,linux-input@vger.kernel.org,sched-ext@lists.linux.dev,linux-mm@kvack.org,kernel-team@meta.com,bpf@vger.kernel.org,llvm@lists.linux.dev,linux-kernel@vger.kernel.org,ziyang.meme@gmail.com,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yonghong.song@linux.dev,clm@meta.com,ihor.solodrai@linux.dev
Subject: Re: [PATCH v2 1/4] selftests: add shared lib.bpf.mk to build BPF progs and skeletons
Date: Wed, 22 Jul 2026 09:56:37 +0000 (UTC) [thread overview]
Message-ID: <1358b841fb4669aa04fcb84247b91c74dfc8f4749f665f5c2a058d6c2bb17640@mail.kernel.org> (raw)
In-Reply-To: <20260721174833.1232771-2-ziyang.meme@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3210 bytes --]
> diff --git a/tools/testing/selftests/lib.bpf.mk b/tools/testing/selftests/lib.bpf.mk
> new file mode 100644
> index 000000000000..6f175c6568e9
> --- /dev/null
> +++ b/tools/testing/selftests/lib.bpf.mk
[ ... ]
> +# ---- libbpf (target) ------------------------------------------------------
> +# Pass ARCH/CROSS_COMPILE/CC through: lib.mk's CC is file-origin and is not
> +# exported, so without this the libbpf sub-make would rebuild for the host under
> +# a pure-LLVM cross build (make LLVM=1 ARCH=<arch>). -fPIC keeps the static
> +# libbpf linkable into position-independent (PIE) test binaries.
> +$(BPFOBJ): $(wildcard $(BPFDIR)/*.[ch] $(BPFDIR)/Makefile) \
> + $(APIDIR)/linux/bpf.h | $(BUILD_DIR)/libbpf
> + $(Q)$(MAKE) $(submake_extras) -C $(BPFDIR) OUTPUT=$(BUILD_DIR)/libbpf/ \
> + ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) CC="$(CC)" \
> + EXTRA_CFLAGS='-g -O0 -fPIC' \
> + DESTDIR=$(SCRATCH_DIR) prefix= all install_headers
This rule hardcodes EXTRA_CFLAGS='-g -O0 -fPIC' for the libbpf sub-make.
tools/testing/selftests/bpf/Makefile instead passes
EXTRA_CFLAGS='-g $(OPT_FLAGS) $(SAN_CFLAGS) $(EXTRA_CFLAGS)'.
With -O0 pinned here, is there a way for someone to build the selftests
(including libbpf) with -O2, or with sanitizer flags? Could this at least
honor the EXTRA_CFLAGS or USERCFLAGS that lib.mk already defines?
The same hardcoding shows up in the host libbpf and host bpftool rules
below, so the same question applies to them:
> +# ---- libbpf (host) -- a distinct rule only when cross-compiling -----------
> +ifneq ($(BPFOBJ),$(HOST_BPFOBJ))
> +$(HOST_BPFOBJ): $(wildcard $(BPFDIR)/*.[ch] $(BPFDIR)/Makefile) \
> + | $(HOST_BUILD_DIR)/libbpf
> + $(Q)$(MAKE) $(submake_extras) -C $(BPFDIR) ARCH= CROSS_COMPILE= \
> + OUTPUT=$(HOST_BUILD_DIR)/libbpf/ CC=$(HOSTCC) LD=$(HOSTLD) \
> + EXTRA_CFLAGS='-g -O0' \
> + DESTDIR=$(HOST_SCRATCH_DIR) prefix= all install_headers
> +endif
> +
> +# ---- bpftool (host) -------------------------------------------------------
> +$(DEFAULT_BPFTOOL): $(wildcard $(BPFTOOLDIR)/*.[ch] $(BPFTOOLDIR)/Makefile) \
> + $(HOST_BPFOBJ) | $(HOST_BUILD_DIR)/bpftool
> + $(Q)$(MAKE) $(submake_extras) -C $(BPFTOOLDIR) \
> + ARCH= CROSS_COMPILE= CC=$(HOSTCC) LD=$(HOSTLD) \
> + EXTRA_CFLAGS='-g -O0' \
> + OUTPUT=$(HOST_BUILD_DIR)/bpftool/ \
> + LIBBPF_OUTPUT=$(HOST_BUILD_DIR)/libbpf/ \
> + LIBBPF_DESTDIR=$(HOST_SCRATCH_DIR)/ \
> + prefix= DESTDIR=$(HOST_SCRATCH_DIR)/ install-bin
[ ... ]
On the commit message:
> This saves much work for configuring selftests in other folder, such the cgroup.
This isn't a bug, but could this sentence be tightened? "in other
folder" and "such the cgroup" read a little awkwardly, and the preceding
text already explains the deduplication rationale. Perhaps something like
"This eases adding BPF-based selftests in other directories, such as
cgroup."
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/29908293077
next prev parent reply other threads:[~2026-07-22 9:56 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-21 17:48 [PATCH v2 0/4] selftests: shared lib.bpf.mk for building " Ziyang Men
2026-07-21 17:48 ` [PATCH v2 1/4] selftests: add shared lib.bpf.mk to build " Ziyang Men
2026-07-22 6:50 ` Viktor Malik
2026-08-06 19:48 ` Ziyang Men
2026-08-12 7:03 ` Viktor Malik
2026-07-22 9:56 ` bot+bpf-ci [this message]
2026-07-21 17:48 ` [PATCH v2 2/4] selftests/cgroup: add memcg_stat_cross_cpu correctness test for flush Ziyang Men
2026-07-22 9:43 ` Michal Koutný
2026-08-06 22:18 ` Ziyang Men
2026-07-22 18:42 ` JP Kobryn
2026-08-06 18:25 ` Ziyang Men
2026-07-21 17:48 ` [PATCH v2 3/4] selftests/hid: build the BPF program via the shared lib.bpf.mk Ziyang Men
2026-07-21 17:48 ` [PATCH v2 4/4] selftests/sched_ext: build BPF schedulers " Ziyang Men
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=1358b841fb4669aa04fcb84247b91c74dfc8f4749f665f5c2a058d6c2bb17640@mail.kernel.org \
--to=bot+bpf-ci@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=andrii@kernel.org \
--cc=arighi@nvidia.com \
--cc=ast@kernel.org \
--cc=bentiss@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=cgroups@vger.kernel.org \
--cc=changwoo@igalia.com \
--cc=clm@meta.com \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=hannes@cmpxchg.org \
--cc=ihor.solodrai@linux.dev \
--cc=inwardvessel@gmail.com \
--cc=jikos@kernel.org \
--cc=kernel-team@meta.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=llvm@lists.linux.dev \
--cc=martin.lau@kernel.org \
--cc=mhocko@kernel.org \
--cc=mkoutny@suse.com \
--cc=muchun.song@linux.dev \
--cc=mykolal@meta.com \
--cc=nathan@kernel.org \
--cc=roman.gushchin@linux.dev \
--cc=sched-ext@lists.linux.dev \
--cc=shakeel.butt@linux.dev \
--cc=shuah@kernel.org \
--cc=tj@kernel.org \
--cc=void@manifault.com \
--cc=yonghong.song@linux.dev \
--cc=ziyang.meme@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®