linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] kbuild: add -fno-PIE flag unconditionally
@ 2018-12-14  8:05 Masahiro Yamada
  2018-12-14  8:05 ` [PATCH 2/3] kbuild: add -Werror=strict-prototype " Masahiro Yamada
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Masahiro Yamada @ 2018-12-14  8:05 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Nick Desaulniers, Masahiro Yamada, Michal Marek, linux-kernel

This flag is documented in the GCC 4.6 manual, and recognized by
Clang as well. Let's rip off the cc-option switch.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 Makefile | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index f2c3423..3bbc16a 100644
--- a/Makefile
+++ b/Makefile
@@ -422,9 +422,9 @@ LINUXINCLUDE    := \
 		-I$(objtree)/include \
 		$(USERINCLUDE)
 
-KBUILD_AFLAGS   := -D__ASSEMBLY__
+KBUILD_AFLAGS   := -D__ASSEMBLY__ -fno-PIE
 KBUILD_CFLAGS   := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
-		   -fno-strict-aliasing -fno-common -fshort-wchar \
+		   -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \
 		   -Werror-implicit-function-declaration \
 		   -Wno-format-security \
 		   -std=gnu89
@@ -510,9 +510,6 @@ RETPOLINE_VDSO_CFLAGS := $(call cc-option,$(RETPOLINE_VDSO_CFLAGS_GCC),$(call cc
 export RETPOLINE_CFLAGS
 export RETPOLINE_VDSO_CFLAGS
 
-KBUILD_CFLAGS	+= $(call cc-option,-fno-PIE)
-KBUILD_AFLAGS	+= $(call cc-option,-fno-PIE)
-
 # check for 'asm goto'
 ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) $(KBUILD_CFLAGS)), y)
   CC_HAVE_ASM_GOTO := 1
-- 
2.7.4


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

* [PATCH 2/3] kbuild: add -Werror=strict-prototype flag unconditionally
  2018-12-14  8:05 [PATCH 1/3] kbuild: add -fno-PIE flag unconditionally Masahiro Yamada
@ 2018-12-14  8:05 ` Masahiro Yamada
  2018-12-14 18:33   ` Nick Desaulniers
  2018-12-14  8:05 ` [PATCH 3/3] kbuild: add -Werror=implicit-int " Masahiro Yamada
  2018-12-14 18:29 ` [PATCH 1/3] kbuild: add -fno-PIE " Nick Desaulniers
  2 siblings, 1 reply; 7+ messages in thread
From: Masahiro Yamada @ 2018-12-14  8:05 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Nick Desaulniers, Masahiro Yamada, Michal Marek, linux-kernel

-Wstrict-prototype is added to KBUILD_CFLAGS first, then overridden
by -Werror=strict-prototype later.

Let's add -Werror=strict-prototypes unconditionally because it is
supported by GCC 4.6, and also by Clang.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 Makefile | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 3bbc16a..bcb943e 100644
--- a/Makefile
+++ b/Makefile
@@ -423,7 +423,7 @@ LINUXINCLUDE    := \
 		$(USERINCLUDE)
 
 KBUILD_AFLAGS   := -D__ASSEMBLY__ -fno-PIE
-KBUILD_CFLAGS   := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
+KBUILD_CFLAGS   := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
 		   -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \
 		   -Werror-implicit-function-declaration \
 		   -Wno-format-security \
@@ -828,9 +828,6 @@ KBUILD_CFLAGS   += $(call cc-option,-fconserve-stack)
 # disallow errors like 'EXPORT_GPL(foo);' with missing header
 KBUILD_CFLAGS   += $(call cc-option,-Werror=implicit-int)
 
-# require functions to have arguments in prototypes, not empty 'int foo()'
-KBUILD_CFLAGS   += $(call cc-option,-Werror=strict-prototypes)
-
 # Prohibit date/time macros, which would make the build non-deterministic
 KBUILD_CFLAGS   += $(call cc-option,-Werror=date-time)
 
-- 
2.7.4


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

* [PATCH 3/3] kbuild: add -Werror=implicit-int flag unconditionally
  2018-12-14  8:05 [PATCH 1/3] kbuild: add -fno-PIE flag unconditionally Masahiro Yamada
  2018-12-14  8:05 ` [PATCH 2/3] kbuild: add -Werror=strict-prototype " Masahiro Yamada
@ 2018-12-14  8:05 ` Masahiro Yamada
  2018-12-14 18:26   ` Nick Desaulniers
  2018-12-14 18:29 ` [PATCH 1/3] kbuild: add -fno-PIE " Nick Desaulniers
  2 siblings, 1 reply; 7+ messages in thread
From: Masahiro Yamada @ 2018-12-14  8:05 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Nick Desaulniers, Masahiro Yamada, Michal Marek, linux-kernel

This flag is documented in the GCC 4.6 manual, and recognized by
Clang as well. Let's rip off the cc-option switch.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 Makefile | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index bcb943e..b63699b 100644
--- a/Makefile
+++ b/Makefile
@@ -425,7 +425,7 @@ LINUXINCLUDE    := \
 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-function-declaration -Werror=implicit-int \
 		   -Wno-format-security \
 		   -std=gnu89
 KBUILD_CPPFLAGS := -D__KERNEL__
@@ -825,9 +825,6 @@ KBUILD_CFLAGS  += $(call cc-option,-fno-stack-check,)
 # conserve stack if available
 KBUILD_CFLAGS   += $(call cc-option,-fconserve-stack)
 
-# disallow errors like 'EXPORT_GPL(foo);' with missing header
-KBUILD_CFLAGS   += $(call cc-option,-Werror=implicit-int)
-
 # Prohibit date/time macros, which would make the build non-deterministic
 KBUILD_CFLAGS   += $(call cc-option,-Werror=date-time)
 
-- 
2.7.4


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

* Re: [PATCH 3/3] kbuild: add -Werror=implicit-int flag unconditionally
  2018-12-14  8:05 ` [PATCH 3/3] kbuild: add -Werror=implicit-int " Masahiro Yamada
@ 2018-12-14 18:26   ` Nick Desaulniers
  0 siblings, 0 replies; 7+ messages in thread
From: Nick Desaulniers @ 2018-12-14 18:26 UTC (permalink / raw)
  To: Masahiro Yamada; +Cc: Linux Kbuild mailing list, Michal Marek, LKML

On Fri, Dec 14, 2018 at 12:06 AM Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
>
> This flag is documented in the GCC 4.6 manual, and recognized by
> Clang as well. Let's rip off the cc-option switch.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

LGTM: https://godbolt.org/z/1Z3aG2
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

> ---
>
>  Makefile | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index bcb943e..b63699b 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -425,7 +425,7 @@ LINUXINCLUDE    := \
>  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-function-declaration -Werror=implicit-int \
>                    -Wno-format-security \
>                    -std=gnu89
>  KBUILD_CPPFLAGS := -D__KERNEL__
> @@ -825,9 +825,6 @@ KBUILD_CFLAGS  += $(call cc-option,-fno-stack-check,)
>  # conserve stack if available
>  KBUILD_CFLAGS   += $(call cc-option,-fconserve-stack)
>
> -# disallow errors like 'EXPORT_GPL(foo);' with missing header
> -KBUILD_CFLAGS   += $(call cc-option,-Werror=implicit-int)
> -
>  # Prohibit date/time macros, which would make the build non-deterministic
>  KBUILD_CFLAGS   += $(call cc-option,-Werror=date-time)
>
> --
> 2.7.4
>


-- 
Thanks,
~Nick Desaulniers

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

* Re: [PATCH 1/3] kbuild: add -fno-PIE flag unconditionally
  2018-12-14  8:05 [PATCH 1/3] kbuild: add -fno-PIE flag unconditionally Masahiro Yamada
  2018-12-14  8:05 ` [PATCH 2/3] kbuild: add -Werror=strict-prototype " Masahiro Yamada
  2018-12-14  8:05 ` [PATCH 3/3] kbuild: add -Werror=implicit-int " Masahiro Yamada
@ 2018-12-14 18:29 ` Nick Desaulniers
  2 siblings, 0 replies; 7+ messages in thread
From: Nick Desaulniers @ 2018-12-14 18:29 UTC (permalink / raw)
  To: Masahiro Yamada; +Cc: Linux Kbuild mailing list, Michal Marek, LKML

On Fri, Dec 14, 2018 at 12:06 AM Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
>
> This flag is documented in the GCC 4.6 manual, and recognized by
> Clang as well. Let's rip off the cc-option switch.

The oldest GCC build that godbolt has (4.1) even recognizes it.
https://godbolt.org/z/buDBUr
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
>
>  Makefile | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index f2c3423..3bbc16a 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -422,9 +422,9 @@ LINUXINCLUDE    := \
>                 -I$(objtree)/include \
>                 $(USERINCLUDE)
>
> -KBUILD_AFLAGS   := -D__ASSEMBLY__
> +KBUILD_AFLAGS   := -D__ASSEMBLY__ -fno-PIE
>  KBUILD_CFLAGS   := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
> -                  -fno-strict-aliasing -fno-common -fshort-wchar \
> +                  -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \
>                    -Werror-implicit-function-declaration \
>                    -Wno-format-security \
>                    -std=gnu89
> @@ -510,9 +510,6 @@ RETPOLINE_VDSO_CFLAGS := $(call cc-option,$(RETPOLINE_VDSO_CFLAGS_GCC),$(call cc
>  export RETPOLINE_CFLAGS
>  export RETPOLINE_VDSO_CFLAGS
>
> -KBUILD_CFLAGS  += $(call cc-option,-fno-PIE)
> -KBUILD_AFLAGS  += $(call cc-option,-fno-PIE)
> -
>  # check for 'asm goto'
>  ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) $(KBUILD_CFLAGS)), y)
>    CC_HAVE_ASM_GOTO := 1
> --
> 2.7.4
>


-- 
Thanks,
~Nick Desaulniers

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

* Re: [PATCH 2/3] kbuild: add -Werror=strict-prototype flag unconditionally
  2018-12-14  8:05 ` [PATCH 2/3] kbuild: add -Werror=strict-prototype " Masahiro Yamada
@ 2018-12-14 18:33   ` Nick Desaulniers
  2018-12-16 15:31     ` Masahiro Yamada
  0 siblings, 1 reply; 7+ messages in thread
From: Nick Desaulniers @ 2018-12-14 18:33 UTC (permalink / raw)
  To: Masahiro Yamada; +Cc: Linux Kbuild mailing list, Michal Marek, LKML

On Fri, Dec 14, 2018 at 12:06 AM Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
>
> -Wstrict-prototype is added to KBUILD_CFLAGS first, then overridden

-Wstrict-prototypes (plural)

> by -Werror=strict-prototype later.

-Werror=strict-prototypes (plural)

LGTM: https://godbolt.org/z/DyEpmU

If you would mind updating the commit message (and subject), then:
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

>
> Let's add -Werror=strict-prototypes unconditionally because it is
> supported by GCC 4.6, and also by Clang.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
>
>  Makefile | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 3bbc16a..bcb943e 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -423,7 +423,7 @@ LINUXINCLUDE    := \
>                 $(USERINCLUDE)
>
>  KBUILD_AFLAGS   := -D__ASSEMBLY__ -fno-PIE
> -KBUILD_CFLAGS   := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
> +KBUILD_CFLAGS   := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
>                    -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \
>                    -Werror-implicit-function-declaration \
>                    -Wno-format-security \
> @@ -828,9 +828,6 @@ KBUILD_CFLAGS   += $(call cc-option,-fconserve-stack)
>  # disallow errors like 'EXPORT_GPL(foo);' with missing header
>  KBUILD_CFLAGS   += $(call cc-option,-Werror=implicit-int)
>
> -# require functions to have arguments in prototypes, not empty 'int foo()'
> -KBUILD_CFLAGS   += $(call cc-option,-Werror=strict-prototypes)
> -
>  # Prohibit date/time macros, which would make the build non-deterministic
>  KBUILD_CFLAGS   += $(call cc-option,-Werror=date-time)
>
> --
> 2.7.4
>


-- 
Thanks,
~Nick Desaulniers

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

* Re: [PATCH 2/3] kbuild: add -Werror=strict-prototype flag unconditionally
  2018-12-14 18:33   ` Nick Desaulniers
@ 2018-12-16 15:31     ` Masahiro Yamada
  0 siblings, 0 replies; 7+ messages in thread
From: Masahiro Yamada @ 2018-12-16 15:31 UTC (permalink / raw)
  To: Nick Desaulniers; +Cc: Linux Kbuild mailing list, Michal Marek, LKML

On Sat, Dec 15, 2018 at 3:34 AM Nick Desaulniers
<ndesaulniers@google.com> wrote:
>
> On Fri, Dec 14, 2018 at 12:06 AM Masahiro Yamada
> <yamada.masahiro@socionext.com> wrote:
> >
> > -Wstrict-prototype is added to KBUILD_CFLAGS first, then overridden
>
> -Wstrict-prototypes (plural)
>
> > by -Werror=strict-prototype later.
>
> -Werror=strict-prototypes (plural)
>
> LGTM: https://godbolt.org/z/DyEpmU
>
> If you would mind updating the commit message (and subject), then:
> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>


Thanks for checking this.

I will locally fix those typos (including the one in the subject).



-- 
Best Regards
Masahiro Yamada

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

end of thread, other threads:[~2018-12-16 15:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-14  8:05 [PATCH 1/3] kbuild: add -fno-PIE flag unconditionally Masahiro Yamada
2018-12-14  8:05 ` [PATCH 2/3] kbuild: add -Werror=strict-prototype " Masahiro Yamada
2018-12-14 18:33   ` Nick Desaulniers
2018-12-16 15:31     ` Masahiro Yamada
2018-12-14  8:05 ` [PATCH 3/3] kbuild: add -Werror=implicit-int " Masahiro Yamada
2018-12-14 18:26   ` Nick Desaulniers
2018-12-14 18:29 ` [PATCH 1/3] kbuild: add -fno-PIE " Nick Desaulniers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).