From: Viktor Malik <vmalik@redhat.com>
To: Ziyang Men <ziyang.meme@gmail.com>
Cc: "Shuah Khan" <shuah@kernel.org>, "Tejun Heo" <tj@kernel.org>,
"Johannes Weiner" <hannes@cmpxchg.org>,
"Michal Koutný" <mkoutny@suse.com>,
"Jiri Kosina" <jikos@kernel.org>,
"Benjamin Tissoires" <bentiss@kernel.org>,
"David Vernet" <void@manifault.com>,
"Eduard Zingerman" <eddyz87@gmail.com>,
"Andrea Righi" <arighi@nvidia.com>,
"Changwoo Min" <changwoo@igalia.com>,
"Michal Hocko" <mhocko@kernel.org>,
"Roman Gushchin" <roman.gushchin@linux.dev>,
"Shakeel Butt" <shakeel.butt@linux.dev>,
"Muchun Song" <muchun.song@linux.dev>,
"Andrew Morton" <akpm@linux-foundation.org>,
"JP Kobryn" <inwardvessel@gmail.com>,
"Mykola Lysenko" <mykolal@meta.com>,
"Nathan Chancellor" <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
Subject: Re: [PATCH v2 1/4] selftests: add shared lib.bpf.mk to build BPF progs and skeletons
Date: Wed, 12 Aug 2026 09:03:47 +0200 [thread overview]
Message-ID: <02ce6b65-7670-4dac-ac9c-8875867d6ad3@redhat.com> (raw)
In-Reply-To: <anTlFSsr5FqQt+o8@devvm16600.scu0.facebook.com>
On 8/6/26 21:48, Ziyang Men wrote:
> On Wed, Jul 22, 2026 at 08:50:06AM +0200, Viktor Malik wrote:
[...]
> Hi Viktor,
>
> Thanks for your suggestions!
>>
>> Looking at the same line in tools/testing/selftests/bpf/Makefile:
>>
>> EXTRA_CFLAGS='-g $(OPT_FLAGS) $(SAN_CFLAGS) $(EXTRA_CFLAGS)' \
>>
>> is there a reason why this is not respected and -O0 and -fPIC are
>> hard-coded?
> Yes it is true that there is no good reason. I will fix it in the next version.
>
>> What if someone wants to build selftests (including libbpf)
>> with -O2 and some additional flags?
> I will add a flag such as OPT_FLAGS ?= $(if $(RELEASE),-O2,O0), which follows
> the pattern in the bpf/Makefile:37. So if we run
> $ make -> -g -O0 -fPIC (taget libbpf) and -g -O0 (host bpftool)
> $ make RELEASE=1 -> -g -O2 -fPIC (taget libbpf) and -g -O2 (host bpftool)
>
>> Is that possible with the new
>> lib.bpf.mk? It would be nice if it used at least EXTRA_CFLAGS or
>> USERCFLAGS defined in lib.mk.
> Good idea. I will add the EXTRA_CFLAGS for target libbpf, host libbpf and host
> bpgtool. Such that:
> $ make OPT_FLAGS=-O2 EXTRA_CFLAGS=-DFOO -> -g -O2 -fPIC -DFOO (for target
> libbpf) and -g -O2 -DFOO (for host bpftool)
I'm wondering if we could use USERCFLAGS (and USERLDFLAGS) instead.
These seem to be the preferred way for all selftests, per
tools/testing/selftests/lib.mk:
# Enables to extend CFLAGS and LDFLAGS from command line, e.g.
# make USERCFLAGS=-Werror USERLDFLAGS=-static
CFLAGS += $(USERCFLAGS)
LDFLAGS += $(USERLDFLAGS)
At the time I was adding the extra flags to libbpf/bpftool sub-makes, I
wasn't aware of USER*FLAGS so I used EXTRA_*FLAGS instead. But now, when
someone wants to build multiple selftest collections with extra flags,
they need to define both. For instance, building with PIE requires:
make -C tools/testing/selftests TARGETS="bpf ..." \
USERCFLAGS=-fpie EXTRA_CFLAGS=-fpie \
USERLDFLAGS=-pie EXTRA_LDFLAGS=-pie \
Switching to USER*FLAGS for bpf selftests would simplify things a bit.
Viktor
>
>>
>> Same questions would apply to other rules for libbpf and bpftool below.
> I would check it them as as well in next version.
>
>> Thanks!
>> Viktor
>>
>>
> Thanks for your time and reviewing. Please let me know your concerns. Thanks!
>
> Best,
> Ziyang
next prev parent reply other threads:[~2026-08-12 7:03 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 BPF progs and skeletons 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 [this message]
2026-07-22 9:56 ` bot+bpf-ci
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=02ce6b65-7670-4dac-ac9c-8875867d6ad3@redhat.com \
--to=vmalik@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=arighi@nvidia.com \
--cc=bentiss@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=cgroups@vger.kernel.org \
--cc=changwoo@igalia.com \
--cc=eddyz87@gmail.com \
--cc=hannes@cmpxchg.org \
--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=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=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