public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kbuild: flatten KBUILD_CFLAGS
@ 2023-07-13 18:52 Alexey Dobriyan
  2023-07-14 10:42 ` Nicolas Schier
  0 siblings, 1 reply; 6+ messages in thread
From: Alexey Dobriyan @ 2023-07-13 18:52 UTC (permalink / raw)
  To: akpm, masahiroy, nathan, ndesaulniers, nicolas; +Cc: linux-kernel, linux-kbuild

Make it slightly easier to see which compiler options are added and
removed (and not worry about column limit too!).

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 Makefile |   22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

--- a/Makefile
+++ b/Makefile
@@ -555,11 +555,23 @@ LINUXINCLUDE    := \
 		$(USERINCLUDE)
 
 KBUILD_AFLAGS   := -D__ASSEMBLY__ -fno-PIE
-KBUILD_CFLAGS   := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
-		   -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \
-		   -Werror=implicit-function-declaration -Werror=implicit-int \
-		   -Werror=return-type -Wno-format-security -funsigned-char \
-		   -std=gnu11
+
+KBUILD_CFLAGS :=
+KBUILD_CFLAGS += -std=gnu11
+KBUILD_CFLAGS += -fshort-wchar
+KBUILD_CFLAGS += -funsigned-char
+KBUILD_CFLAGS += -fno-common
+KBUILD_CFLAGS += -fno-PIE
+KBUILD_CFLAGS += -fno-strict-aliasing
+KBUILD_CFLAGS += -Wall
+KBUILD_CFLAGS += -Wundef
+KBUILD_CFLAGS += -Werror=implicit-function-declaration
+KBUILD_CFLAGS += -Werror=implicit-int
+KBUILD_CFLAGS += -Werror=return-type
+KBUILD_CFLAGS += -Werror=strict-prototypes
+KBUILD_CFLAGS += -Wno-format-security
+KBUILD_CFLAGS += -Wno-trigraphs
+
 KBUILD_CPPFLAGS := -D__KERNEL__
 KBUILD_RUSTFLAGS := $(rust_common_flags) \
 		    --target=$(objtree)/scripts/target.json \

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] kbuild: flatten KBUILD_CFLAGS
  2023-07-13 18:52 [PATCH] kbuild: flatten KBUILD_CFLAGS Alexey Dobriyan
@ 2023-07-14 10:42 ` Nicolas Schier
  2023-07-14 17:45   ` Alexey Dobriyan
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Schier @ 2023-07-14 10:42 UTC (permalink / raw)
  To: Alexey Dobriyan
  Cc: akpm, masahiroy, nathan, ndesaulniers, linux-kernel, linux-kbuild

[-- Attachment #1: Type: text/plain, Size: 1894 bytes --]

On Thu, Jul 13, 2023 at 09:52:28PM +0300, Alexey Dobriyan wrote:
> Make it slightly easier to see which compiler options are added and
> removed (and not worry about column limit too!).
> 
> Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
> ---
> 
>  Makefile |   22 +++++++++++++++++-----
>  1 file changed, 17 insertions(+), 5 deletions(-)
> 
> --- a/Makefile
> +++ b/Makefile
> @@ -555,11 +555,23 @@ LINUXINCLUDE    := \
>  		$(USERINCLUDE)
>  
>  KBUILD_AFLAGS   := -D__ASSEMBLY__ -fno-PIE
> -KBUILD_CFLAGS   := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
> -		   -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \
> -		   -Werror=implicit-function-declaration -Werror=implicit-int \
> -		   -Werror=return-type -Wno-format-security -funsigned-char \
> -		   -std=gnu11
> +
> +KBUILD_CFLAGS :=
> +KBUILD_CFLAGS += -std=gnu11

If you want to put -std at top, on contrast to the sorted options below,
you could also merge the two lines above.

> +KBUILD_CFLAGS += -fshort-wchar
> +KBUILD_CFLAGS += -funsigned-char
> +KBUILD_CFLAGS += -fno-common
> +KBUILD_CFLAGS += -fno-PIE
> +KBUILD_CFLAGS += -fno-strict-aliasing
> +KBUILD_CFLAGS += -Wall
> +KBUILD_CFLAGS += -Wundef
> +KBUILD_CFLAGS += -Werror=implicit-function-declaration
> +KBUILD_CFLAGS += -Werror=implicit-int
> +KBUILD_CFLAGS += -Werror=return-type
> +KBUILD_CFLAGS += -Werror=strict-prototypes
> +KBUILD_CFLAGS += -Wno-format-security
> +KBUILD_CFLAGS += -Wno-trigraphs
> +
>  KBUILD_CPPFLAGS := -D__KERNEL__
>  KBUILD_RUSTFLAGS := $(rust_common_flags) \
>  		    --target=$(objtree)/scripts/target.json \

Thanks for the patch.

Reviewed-by: Nicolas Schier <n.schier@avm.de>

-- 
epost|xmpp: nicolas@fjasle.eu          irc://oftc.net/nsc
↳ gpg: 18ed 52db e34f 860e e9fb  c82b 7d97 0932 55a0 ce7f
     -- frykten for herren er opphav til kunnskap --

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] kbuild: flatten KBUILD_CFLAGS
  2023-07-14 10:42 ` Nicolas Schier
@ 2023-07-14 17:45   ` Alexey Dobriyan
  2023-07-14 19:30     ` Nicolas Schier
  2023-07-21 14:27     ` Masahiro Yamada
  0 siblings, 2 replies; 6+ messages in thread
From: Alexey Dobriyan @ 2023-07-14 17:45 UTC (permalink / raw)
  To: Nicolas Schier
  Cc: akpm, masahiroy, nathan, ndesaulniers, linux-kernel, linux-kbuild

On Fri, Jul 14, 2023 at 12:42:11PM +0200, Nicolas Schier wrote:
> On Thu, Jul 13, 2023 at 09:52:28PM +0300, Alexey Dobriyan wrote:
> > Make it slightly easier to see which compiler options are added and
> > removed (and not worry about column limit too!).
> > 
> > Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
> > ---
> > 
> >  Makefile |   22 +++++++++++++++++-----
> >  1 file changed, 17 insertions(+), 5 deletions(-)
> > 
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -555,11 +555,23 @@ LINUXINCLUDE    := \
> >  		$(USERINCLUDE)
> >  
> >  KBUILD_AFLAGS   := -D__ASSEMBLY__ -fno-PIE
> > -KBUILD_CFLAGS   := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
> > -		   -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \
> > -		   -Werror=implicit-function-declaration -Werror=implicit-int \
> > -		   -Werror=return-type -Wno-format-security -funsigned-char \
> > -		   -std=gnu11
> > +
> > +KBUILD_CFLAGS :=
> > +KBUILD_CFLAGS += -std=gnu11
> 
> If you want to put -std at top, on contrast to the sorted options below,
> you could also merge the two lines above.

I don't know. Standard choice is arguably the most important option
so I put it first.

> > +KBUILD_CFLAGS += -fshort-wchar
> > +KBUILD_CFLAGS += -funsigned-char
> > +KBUILD_CFLAGS += -fno-common
> > +KBUILD_CFLAGS += -fno-PIE
> > +KBUILD_CFLAGS += -fno-strict-aliasing
> > +KBUILD_CFLAGS += -Wall
> > +KBUILD_CFLAGS += -Wundef
> > +KBUILD_CFLAGS += -Werror=implicit-function-declaration
> > +KBUILD_CFLAGS += -Werror=implicit-int
> > +KBUILD_CFLAGS += -Werror=return-type
> > +KBUILD_CFLAGS += -Werror=strict-prototypes
> > +KBUILD_CFLAGS += -Wno-format-security
> > +KBUILD_CFLAGS += -Wno-trigraphs

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] kbuild: flatten KBUILD_CFLAGS
  2023-07-14 17:45   ` Alexey Dobriyan
@ 2023-07-14 19:30     ` Nicolas Schier
  2023-07-15  6:36       ` Masahiro Yamada
  2023-07-21 14:27     ` Masahiro Yamada
  1 sibling, 1 reply; 6+ messages in thread
From: Nicolas Schier @ 2023-07-14 19:30 UTC (permalink / raw)
  To: Alexey Dobriyan
  Cc: akpm, masahiroy, nathan, ndesaulniers, linux-kernel, linux-kbuild

On Fri, Jul 14, 2023 at 08:45:00PM +0300 Alexey Dobriyan wrote:
> On Fri, Jul 14, 2023 at 12:42:11PM +0200, Nicolas Schier wrote:
> > On Thu, Jul 13, 2023 at 09:52:28PM +0300, Alexey Dobriyan wrote:
> > > Make it slightly easier to see which compiler options are added and
> > > removed (and not worry about column limit too!).
> > > 
> > > Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
> > > ---
> > > 
> > >  Makefile |   22 +++++++++++++++++-----
> > >  1 file changed, 17 insertions(+), 5 deletions(-)
> > > 
> > > --- a/Makefile
> > > +++ b/Makefile
> > > @@ -555,11 +555,23 @@ LINUXINCLUDE    := \
> > >  		$(USERINCLUDE)
> > >  
> > >  KBUILD_AFLAGS   := -D__ASSEMBLY__ -fno-PIE
> > > -KBUILD_CFLAGS   := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
> > > -		   -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \
> > > -		   -Werror=implicit-function-declaration -Werror=implicit-int \
> > > -		   -Werror=return-type -Wno-format-security -funsigned-char \
> > > -		   -std=gnu11
> > > +
> > > +KBUILD_CFLAGS :=
> > > +KBUILD_CFLAGS += -std=gnu11
> > 
> > If you want to put -std at top, on contrast to the sorted options below,
> > you could also merge the two lines above.
> 
> I don't know. Standard choice is arguably the most important option
> so I put it first.

yes, I think I would have put it on top, too.  I just would write it this way:

    KBUILD_CFLAGS := -std=gnu11

    KBUILD_CFLAGS += ...

But it is bike-shedding, ignore it if you're not convinced.

Kind regards,
Nicolas


> > > +KBUILD_CFLAGS += -fshort-wchar
> > > +KBUILD_CFLAGS += -funsigned-char
> > > +KBUILD_CFLAGS += -fno-common
> > > +KBUILD_CFLAGS += -fno-PIE
> > > +KBUILD_CFLAGS += -fno-strict-aliasing
> > > +KBUILD_CFLAGS += -Wall
> > > +KBUILD_CFLAGS += -Wundef
> > > +KBUILD_CFLAGS += -Werror=implicit-function-declaration
> > > +KBUILD_CFLAGS += -Werror=implicit-int
> > > +KBUILD_CFLAGS += -Werror=return-type
> > > +KBUILD_CFLAGS += -Werror=strict-prototypes
> > > +KBUILD_CFLAGS += -Wno-format-security
> > > +KBUILD_CFLAGS += -Wno-trigraphs

-- 
epost|xmpp: nicolas@fjasle.eu          irc://oftc.net/nsc
↳ gpg: 18ed 52db e34f 860e e9fb  c82b 7d97 0932 55a0 ce7f
     -- frykten for herren er opphav til kunnskap --

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] kbuild: flatten KBUILD_CFLAGS
  2023-07-14 19:30     ` Nicolas Schier
@ 2023-07-15  6:36       ` Masahiro Yamada
  0 siblings, 0 replies; 6+ messages in thread
From: Masahiro Yamada @ 2023-07-15  6:36 UTC (permalink / raw)
  To: Nicolas Schier
  Cc: Alexey Dobriyan, akpm, nathan, ndesaulniers, linux-kernel,
	linux-kbuild

On Sat, Jul 15, 2023 at 4:30 AM Nicolas Schier <nicolas@fjasle.eu> wrote:
>
> On Fri, Jul 14, 2023 at 08:45:00PM +0300 Alexey Dobriyan wrote:
> > On Fri, Jul 14, 2023 at 12:42:11PM +0200, Nicolas Schier wrote:
> > > On Thu, Jul 13, 2023 at 09:52:28PM +0300, Alexey Dobriyan wrote:
> > > > Make it slightly easier to see which compiler options are added and
> > > > removed (and not worry about column limit too!).
> > > >
> > > > Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
> > > > ---
> > > >
> > > >  Makefile |   22 +++++++++++++++++-----
> > > >  1 file changed, 17 insertions(+), 5 deletions(-)
> > > >
> > > > --- a/Makefile
> > > > +++ b/Makefile
> > > > @@ -555,11 +555,23 @@ LINUXINCLUDE    := \
> > > >           $(USERINCLUDE)
> > > >
> > > >  KBUILD_AFLAGS   := -D__ASSEMBLY__ -fno-PIE
> > > > -KBUILD_CFLAGS   := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
> > > > -            -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \
> > > > -            -Werror=implicit-function-declaration -Werror=implicit-int \
> > > > -            -Werror=return-type -Wno-format-security -funsigned-char \
> > > > -            -std=gnu11
> > > > +
> > > > +KBUILD_CFLAGS :=
> > > > +KBUILD_CFLAGS += -std=gnu11
> > >
> > > If you want to put -std at top, on contrast to the sorted options below,
> > > you could also merge the two lines above.
> >
> > I don't know. Standard choice is arguably the most important option
> > so I put it first.
>
> yes, I think I would have put it on top, too.  I just would write it this way:
>
>     KBUILD_CFLAGS := -std=gnu11
>
>     KBUILD_CFLAGS += ...
>
> But it is bike-shedding, ignore it if you're not convinced.
>
> Kind regards,
> Nicolas





Starting line 813, we have more and more
"KBUILD_CFLAGS +=" lines.


I thought we perhaps could merge them in a single place.
(but "KBUILD_CFLAGS := " still must come before "export KBUILD_CFLAGS")


[move everything to line 813]

KBUILD_CFLAGS += -std=gnu11
KBUILD_CFLAGS += -fshort-wchar
KBUILD_CFLAGS += -funsigned-char
KBUILD_CFLAGS += -fno-common
KBUILD_CFLAGS += -fno-PIE
KBUILD_CFLAGS += -fno-strict-aliasing
KBUILD_CFLAGS += -Wall
KBUILD_CFLAGS += -Wundef
KBUILD_CFLAGS += -Werror=implicit-function-declaration
KBUILD_CFLAGS += -Werror=implicit-int
KBUILD_CFLAGS += -Werror=return-type
KBUILD_CFLAGS += -Werror=strict-prototypes
KBUILD_CFLAGS += -Wno-format-security
KBUILD_CFLAGS += -Wno-trigraphs
KBUILD_CFLAGS += -fno-delete-null-pointer-checks
KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,)
KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation)
KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
 ...




That will change the order of compiler options
because they cross line 760

  include $(srctree)/arch/$(SRCARCH)/Makefile


So, I think the patch is fine if we try to be safe.



-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] kbuild: flatten KBUILD_CFLAGS
  2023-07-14 17:45   ` Alexey Dobriyan
  2023-07-14 19:30     ` Nicolas Schier
@ 2023-07-21 14:27     ` Masahiro Yamada
  1 sibling, 0 replies; 6+ messages in thread
From: Masahiro Yamada @ 2023-07-21 14:27 UTC (permalink / raw)
  To: Alexey Dobriyan
  Cc: Nicolas Schier, akpm, nathan, ndesaulniers, linux-kernel,
	linux-kbuild

On Sat, Jul 15, 2023 at 2:45 AM Alexey Dobriyan <adobriyan@gmail.com> wrote:
>
> On Fri, Jul 14, 2023 at 12:42:11PM +0200, Nicolas Schier wrote:
> > On Thu, Jul 13, 2023 at 09:52:28PM +0300, Alexey Dobriyan wrote:
> > > Make it slightly easier to see which compiler options are added and
> > > removed (and not worry about column limit too!).
> > >
> > > Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
> > > ---
> > >
> > >  Makefile |   22 +++++++++++++++++-----
> > >  1 file changed, 17 insertions(+), 5 deletions(-)
> > >
> > > --- a/Makefile
> > > +++ b/Makefile
> > > @@ -555,11 +555,23 @@ LINUXINCLUDE    := \
> > >             $(USERINCLUDE)
> > >
> > >  KBUILD_AFLAGS   := -D__ASSEMBLY__ -fno-PIE
> > > -KBUILD_CFLAGS   := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
> > > -              -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \
> > > -              -Werror=implicit-function-declaration -Werror=implicit-int \
> > > -              -Werror=return-type -Wno-format-security -funsigned-char \
> > > -              -std=gnu11
> > > +
> > > +KBUILD_CFLAGS :=
> > > +KBUILD_CFLAGS += -std=gnu11
> >
> > If you want to put -std at top, on contrast to the sorted options below,
> > you could also merge the two lines above.
>
> I don't know. Standard choice is arguably the most important option
> so I put it first.
>
> > > +KBUILD_CFLAGS += -fshort-wchar
> > > +KBUILD_CFLAGS += -funsigned-char
> > > +KBUILD_CFLAGS += -fno-common
> > > +KBUILD_CFLAGS += -fno-PIE
> > > +KBUILD_CFLAGS += -fno-strict-aliasing
> > > +KBUILD_CFLAGS += -Wall
> > > +KBUILD_CFLAGS += -Wundef
> > > +KBUILD_CFLAGS += -Werror=implicit-function-declaration
> > > +KBUILD_CFLAGS += -Werror=implicit-int
> > > +KBUILD_CFLAGS += -Werror=return-type
> > > +KBUILD_CFLAGS += -Werror=strict-prototypes
> > > +KBUILD_CFLAGS += -Wno-format-security
> > > +KBUILD_CFLAGS += -Wno-trigraphs


Applied to linux-kbuild.
Thanks.


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-07-21 14:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-13 18:52 [PATCH] kbuild: flatten KBUILD_CFLAGS Alexey Dobriyan
2023-07-14 10:42 ` Nicolas Schier
2023-07-14 17:45   ` Alexey Dobriyan
2023-07-14 19:30     ` Nicolas Schier
2023-07-15  6:36       ` Masahiro Yamada
2023-07-21 14:27     ` Masahiro Yamada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox