Re: [PATCH v4 27/30] selftests/bpf: Append extra cflags

From: Leo Yan

Date: Fri Mar 13 2026 - 12:14:47 EST


On Thu, Mar 12, 2026 at 10:24:48AM -0700, Ian Rogers wrote:
> On Wed, Mar 11, 2026 at 1:33 AM Leo Yan <leo.yan@xxxxxxx> wrote:
> >
> > Append EXTRA_CFLAGS to CFLAGS so that additional flags can be applied to
> > the compiler.
> >
> > urandom_read is built with clang. Introduce URANDOM_READ_CFLAGS to copy
> > the compiler flags without appending EXTRA_CFLAGS, which may contain
> > incompatible options with clang.
> >
> > Signed-off-by: Leo Yan <leo.yan@xxxxxxx>
> > ---
> > tools/testing/selftests/bpf/Makefile | 10 ++++++++--
> > 1 file changed, 8 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> > index 72a9ba41f95ebb825d25799c07ba3f0311243e45..27112f08c9a5b6cabc41902207d00897070b41b4 100644
> > --- a/tools/testing/selftests/bpf/Makefile
> > +++ b/tools/testing/selftests/bpf/Makefile
> > @@ -71,6 +71,12 @@ ifneq ($(LLVM),)
> > CFLAGS += -Wno-unused-command-line-argument
> > endif
> >
> > +# urandom_read is built with clang. Copy $(CFLAGS) before EXTRA_CFLAGS are
> > +# appended so that it does not inherit potentially incompatible options.
> > +URANDOM_READ_CFLAGS := $(CFLAGS)
>
> Later in the Makefile, include ../lib.mk is executed and it appends
> CFLAGS like -D_GNU_SOURCE= which will be missing from
> URANDOM_READ_CFLAGS here. Perhaps move these assignments below the
> include?

Will do, thanks!