diff mbox series

[09/12] selftests/nolibc: add support for LLVM= parameter

Message ID 20240728-nolibc-llvm-v1-9-bc384269bc35@weissschuh.net (mailing list archive)
State New
Headers show
Series tools/nolibc: improve LLVM/clang support | expand

Commit Message

Thomas Weißschuh July 28, 2024, 10:10 a.m. UTC
Makefile.include can modify CC and CFLAGS for usage with clang.
Make use of it.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 tools/testing/selftests/nolibc/Makefile | 3 +++
 1 file changed, 3 insertions(+)

Comments

Willy Tarreau Aug. 3, 2024, 9:45 a.m. UTC | #1
On Sun, Jul 28, 2024 at 12:10:03PM +0200, Thomas Weißschuh wrote:
> Makefile.include can modify CC and CFLAGS for usage with clang.
> Make use of it.
> 
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> ---
>  tools/testing/selftests/nolibc/Makefile | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile
> index 8000bc3c408b..cdff317c35f2 100644
> --- a/tools/testing/selftests/nolibc/Makefile
> +++ b/tools/testing/selftests/nolibc/Makefile
> @@ -155,6 +155,9 @@ CFLAGS  ?= -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 -W -Wall -Wex
>  		$(CFLAGS_$(XARCH)) $(CFLAGS_STACKPROTECTOR) $(CFLAGS_EXTRA)
>  LDFLAGS :=
>  
> +# Modify CFLAGS based on LLVM=
> +include $(srctree)/tools/scripts/Makefile.include

I'm confused, doesn't it precisely undo the previous patch, which
said that we ought not to include Makefile.include as it makes it
harder for LLVM ?

If so, I suspect that both commits should be squashed with a better
explanation for both operations at once (e.g. maybe "move makefile
inclusion later to benefit from LLVM=..." etc).

Thanks,
Willy
Thomas Weißschuh Aug. 4, 2024, 3:59 p.m. UTC | #2
On 2024-08-03 11:45:30+0000, Willy Tarreau wrote:
> On Sun, Jul 28, 2024 at 12:10:03PM +0200, Thomas Weißschuh wrote:
> > Makefile.include can modify CC and CFLAGS for usage with clang.
> > Make use of it.
> > 
> > Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> > ---
> >  tools/testing/selftests/nolibc/Makefile | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile
> > index 8000bc3c408b..cdff317c35f2 100644
> > --- a/tools/testing/selftests/nolibc/Makefile
> > +++ b/tools/testing/selftests/nolibc/Makefile
> > @@ -155,6 +155,9 @@ CFLAGS  ?= -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 -W -Wall -Wex
> >  		$(CFLAGS_$(XARCH)) $(CFLAGS_STACKPROTECTOR) $(CFLAGS_EXTRA)
> >  LDFLAGS :=
> >  
> > +# Modify CFLAGS based on LLVM=
> > +include $(srctree)/tools/scripts/Makefile.include
> 
> I'm confused, doesn't it precisely undo the previous patch, which
> said that we ought not to include Makefile.include as it makes it
> harder for LLVM ?

The previous inclusion doesn't make it harder.
The problem is that Makefile.include does two things
1) objtree setup and 2) LLVM handling.

For 1) we want to include it as early as possible, necessarily before
using $(objtree).
For 2) we need to include it after "CFLAGS ?=".
Reshuffling the Makefile to satisfy both requirements will look bad.
So the first commit removed the usage of Makefile.include for 1) because
that is easy to do and the second commit includes it later to satisfy
2).

> If so, I suspect that both commits should be squashed with a better
> explanation for both operations at once (e.g. maybe "move makefile
> inclusion later to benefit from LLVM=..." etc).

Ack.
diff mbox series

Patch

diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile
index 8000bc3c408b..cdff317c35f2 100644
--- a/tools/testing/selftests/nolibc/Makefile
+++ b/tools/testing/selftests/nolibc/Makefile
@@ -155,6 +155,9 @@  CFLAGS  ?= -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 -W -Wall -Wex
 		$(CFLAGS_$(XARCH)) $(CFLAGS_STACKPROTECTOR) $(CFLAGS_EXTRA)
 LDFLAGS :=
 
+# Modify CFLAGS based on LLVM=
+include $(srctree)/tools/scripts/Makefile.include
+
 REPORT  ?= awk '/\[OK\][\r]*$$/{p++} /\[FAIL\][\r]*$$/{if (!f) printf("\n"); f++; print;} /\[SKIPPED\][\r]*$$/{s++} \
 		END{ printf("\n%3d test(s): %3d passed, %3d skipped, %3d failed => status: ", p+s+f, p, s, f); \
 		if (f || !p) printf("failure\n"); else if (s) printf("warning\n"); else printf("success\n");; \