Re: [PATCH v4 29/30] selftests/nolibc: Append extra cflags
From: Thomas Weißschuh
Date: Mon Mar 16 2026 - 18:27:58 EST
On 2026-03-11 08:29:54+0000, Leo Yan wrote:
> Include tools/scripts/Makefile.include, which may provide additional
> flags in EXTRA_CFLAGS, and append to CFLAGS.
>
> Since Makefile.include already defines cc-option, remove the redundant
> definition and include.
>
> Signed-off-by: Leo Yan <leo.yan@xxxxxxx>
> ---
> tools/testing/selftests/nolibc/Makefile | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile
> index 0370489d938b540721a4fb814ebb68c463760e73..d1a9c1d5988bdc6a8778ef418aaa4c5ac1d26a10 100644
> --- a/tools/testing/selftests/nolibc/Makefile
> +++ b/tools/testing/selftests/nolibc/Makefile
> @@ -3,15 +3,13 @@
> TEST_GEN_PROGS := nolibc-test libc-test
>
> include ../lib.mk
> -include $(top_srcdir)/scripts/Makefile.compiler
> -
> -cc-option = $(call __cc-option, $(CC),,$(1),$(2))
> +include $(top_srcdir)/tools/scripts/Makefile.include
>
> include Makefile.include
>
> $(OUTPUT)/nolibc-test: CFLAGS = -nostdlib -nostdinc -static \
> -isystem $(top_srcdir)/tools/include/nolibc -isystem $(top_srcdir)/usr/include \
> - $(CFLAGS_NOLIBC_TEST)
> + $(CFLAGS_NOLIBC_TEST) $(EXTRA_CFLAGS)
> $(OUTPUT)/nolibc-test: LDLIBS = $(if $(LLVM),,-lgcc)
> $(OUTPUT)/nolibc-test: nolibc-test.c nolibc-test-linkage.c | headers
The rule for "libc-test", which uses the standard $(LINK.c) to invoke
the compiler, does not respect $(EXTRA_CFLAGS) automatically.
Is this intentional? It also affects all other users of lib.mk which
don't have any custom cflags handling.
If so, there should be an override for the "libc-test" target, too.
But if I am supposed to pick up this patch, I can fix it up when applying.
Thomas