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

Leo Yan posted 30 patches 1 month ago
There is a newer version of this series
[PATCH v3 27/30] selftests/bpf: Append extra cflags
Posted by Leo Yan 1 month ago
Append EXTRA_CFLAGS to CFLAGS so that additional flags can be applied to
the compiler.

Signed-off-by: Leo Yan <leo.yan@arm.com>
---
 tools/testing/selftests/bpf/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 72a9ba41f95ebb825d25799c07ba3f0311243e45..29dfcdbe98c781b53f1e87dcebecf2027bafcd5d 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -49,6 +49,7 @@ srctree := $(patsubst %/,%,$(dir $(srctree)))
 srctree := $(patsubst %/,%,$(dir $(srctree)))
 endif
 
+CFLAGS += $(EXTRA_CFLAGS)
 CFLAGS += -g $(OPT_FLAGS) -rdynamic -std=gnu11				\
 	  -Wall -Werror -fno-omit-frame-pointer				\
 	  -Wno-unused-but-set-variable					\

-- 
2.34.1
Re: [PATCH v3 27/30] selftests/bpf: Append extra cflags
Posted by Leo Yan 4 weeks, 1 day ago
On Sun, Mar 08, 2026 at 04:46:32PM +0000, Leo Yan wrote:
> Append EXTRA_CFLAGS to CFLAGS so that additional flags can be applied to
> the compiler.
> 
> Signed-off-by: Leo Yan <leo.yan@arm.com>

FWIW, this patch causes bpf selftest build failure and was reported in:

  https://github.com/kernel-patches/bpf/actions/runs/22825654003

The Makefile reuses CFLAGS for clang to build urandom_read, which may
cause GCC specific flags to feed to clang and causes errors.

The updated patch will introduce a new variable URANDOM_READ_CFLAGS,
without appending EXTRA_CFLAGS, this can effectively avoid incompatible
options.

Thanks,
Leo

> ---
>  tools/testing/selftests/bpf/Makefile | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> index 72a9ba41f95ebb825d25799c07ba3f0311243e45..29dfcdbe98c781b53f1e87dcebecf2027bafcd5d 100644
> --- a/tools/testing/selftests/bpf/Makefile
> +++ b/tools/testing/selftests/bpf/Makefile
> @@ -49,6 +49,7 @@ srctree := $(patsubst %/,%,$(dir $(srctree)))
>  srctree := $(patsubst %/,%,$(dir $(srctree)))
>  endif
>  
> +CFLAGS += $(EXTRA_CFLAGS)
>  CFLAGS += -g $(OPT_FLAGS) -rdynamic -std=gnu11				\
>  	  -Wall -Werror -fno-omit-frame-pointer				\
>  	  -Wno-unused-but-set-variable					\
> 
> -- 
> 2.34.1
>
Re: [PATCH v3 27/30] selftests/bpf: Append extra cflags
Posted by Ian Rogers 1 month ago
On Sun, Mar 8, 2026 at 9:50 AM Leo Yan <leo.yan@arm.com> wrote:
>
> Append EXTRA_CFLAGS to CFLAGS so that additional flags can be applied to
> the compiler.
>
> Signed-off-by: Leo Yan <leo.yan@arm.com>
> ---
>  tools/testing/selftests/bpf/Makefile | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> index 72a9ba41f95ebb825d25799c07ba3f0311243e45..29dfcdbe98c781b53f1e87dcebecf2027bafcd5d 100644
> --- a/tools/testing/selftests/bpf/Makefile
> +++ b/tools/testing/selftests/bpf/Makefile
> @@ -49,6 +49,7 @@ srctree := $(patsubst %/,%,$(dir $(srctree)))
>  srctree := $(patsubst %/,%,$(dir $(srctree)))
>  endif
>
> +CFLAGS += $(EXTRA_CFLAGS)
>  CFLAGS += -g $(OPT_FLAGS) -rdynamic -std=gnu11                         \
>           -Wall -Werror -fno-omit-frame-pointer                         \
>           -Wno-unused-but-set-variable                                  \

The append should probably happen last to allow the default values to
be overridden.

Thanks,
Ian

> --
> 2.34.1
>