2022-03-09 01:38:06

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 0/4] [v4] Kbuild: std=gnu11 changes

From: Arnd Bergmann <[email protected]>

I've incorporated the feedback from Masahiro Yamada in this
version, splitting out one more patch, rebasing on top of
the kbuild tree, and changing the order of the patches.

Please apply to the kbuild tree.

Arnd

Cc: [email protected]
Cc: [email protected]

Arnd Bergmann (3):
[v4] Kbuild: add -Wno-shift-negative-value where -Wextra is used
[v4] Kbuild: move to -std=gnu11
Kbuild: use -std=gnu11 for KBUILD_USERCFLAGS

Mark Rutland (1):
[v4] Kbuild: use -Wdeclaration-after-statement

Documentation/process/programming-language.rst | 6 +++---
.../translations/it_IT/process/programming-language.rst | 4 ++--
.../translations/zh_CN/process/programming-language.rst | 3 +--
.../translations/zh_TW/process/programming-language.rst | 3 +--
Makefile | 7 ++++---
arch/arm64/kernel/vdso32/Makefile | 3 ++-
drivers/gpu/drm/i915/Makefile | 1 +
drivers/staging/greybus/tools/Makefile | 3 ++-
fs/btrfs/Makefile | 1 +
scripts/Makefile.extrawarn | 1 +
scripts/mod/modpost.c | 4 +++-
11 files changed, 21 insertions(+), 15 deletions(-)

--
2.29.2


2022-03-09 01:46:13

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 4/4] Kbuild: use -std=gnu11 for KBUILD_USERCFLAGS

From: Arnd Bergmann <[email protected]>

As we change the C language standard for the kernel from gnu89 to
gnu11, it makes sense to also update the version for user space
compilation.

Some users have older native compilers than what they use for
kernel builds, so I considered using gnu99 as the default version
for wider compatibility with gcc-4.6 and earlier.

However, testing with older compilers showed that we already require
HOSTCC version 5.1 as well because a lot of host tools include
linux/compiler.h that uses __has_attribute():

CC tools/objtool/exec-cmd.o
In file included from tools/include/linux/compiler_types.h:36:0,
from tools/include/linux/compiler.h:5,
from exec-cmd.c:2:
tools/include/linux/compiler-gcc.h:19:5: error: "__has_attribute" is not defined [-Werror=undef]

Signed-off-by: Arnd Bergmann <[email protected]>
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 1ba8dc523952..e0b11ddd0760 100644
--- a/Makefile
+++ b/Makefile
@@ -432,7 +432,7 @@ HOSTCXX = g++
endif

KBUILD_USERHOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \
- -O2 -fomit-frame-pointer -std=gnu89 \
+ -O2 -fomit-frame-pointer -std=gnu11 \
-Wdeclaration-after-statement
KBUILD_USERCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(USERCFLAGS)
KBUILD_USERLDFLAGS := $(USERLDFLAGS)
--
2.29.2

2022-03-09 01:59:09

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 1/4] [v4] Kbuild: add -Wno-shift-negative-value where -Wextra is used

From: Arnd Bergmann <[email protected]>

As a preparation for moving to -std=gnu11, turn off the
-Wshift-negative-value option. This warning is enabled by gcc when
building with -Wextra for c99 or higher, but not for c89. Since
the kernel already relies on well-defined overflow behavior,
the warning is not helpful and can simply be disabled in
all locations that use -Wextra.

Signed-off-by: Arnd Bergmann <[email protected]>
---
[v4]
split into a separate patch
---
drivers/gpu/drm/i915/Makefile | 1 +
drivers/staging/greybus/tools/Makefile | 3 ++-
fs/btrfs/Makefile | 1 +
scripts/Makefile.extrawarn | 1 +
4 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index 1b62b9f65196..1618a6e0af4e 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -17,6 +17,7 @@ subdir-ccflags-y += -Wno-unused-parameter
subdir-ccflags-y += -Wno-type-limits
subdir-ccflags-y += -Wno-missing-field-initializers
subdir-ccflags-y += -Wno-sign-compare
+subdir-ccflags-y += -Wno-shift-negative-value
subdir-ccflags-y += $(call cc-disable-warning, unused-but-set-variable)
subdir-ccflags-y += $(call cc-disable-warning, frame-address)
subdir-ccflags-$(CONFIG_DRM_I915_WERROR) += -Werror
diff --git a/drivers/staging/greybus/tools/Makefile b/drivers/staging/greybus/tools/Makefile
index ad0ae8053b79..a3bbd73171f2 100644
--- a/drivers/staging/greybus/tools/Makefile
+++ b/drivers/staging/greybus/tools/Makefile
@@ -12,7 +12,8 @@ CFLAGS += -std=gnu99 -Wall -Wextra -g \
-Wredundant-decls \
-Wcast-align \
-Wsign-compare \
- -Wno-missing-field-initializers
+ -Wno-missing-field-initializers \
+ -Wno-shift-negative-value

CC := $(CROSS_COMPILE)gcc

diff --git a/fs/btrfs/Makefile b/fs/btrfs/Makefile
index 4188ba3fd8c3..99f9995670ea 100644
--- a/fs/btrfs/Makefile
+++ b/fs/btrfs/Makefile
@@ -17,6 +17,7 @@ subdir-ccflags-y += $(condflags)
subdir-ccflags-y += -Wno-missing-field-initializers
subdir-ccflags-y += -Wno-sign-compare
subdir-ccflags-y += -Wno-type-limits
+subdir-ccflags-y += -Wno-shift-negative-value

obj-$(CONFIG_BTRFS_FS) := btrfs.o

diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index 8be892887d71..650d0b8ceec3 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -36,6 +36,7 @@ KBUILD_CFLAGS += $(call cc-option, -Wstringop-truncation)
KBUILD_CFLAGS += -Wno-missing-field-initializers
KBUILD_CFLAGS += -Wno-sign-compare
KBUILD_CFLAGS += -Wno-type-limits
+KBUILD_CFLAGS += -Wno-shift-negative-value

KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN1

--
2.29.2

2022-03-09 02:13:08

by Linus Torvalds

[permalink] [raw]
Subject: Re: [PATCH 0/4] [v4] Kbuild: std=gnu11 changes

On Tue, Mar 8, 2022 at 1:56 PM Arnd Bergmann <[email protected]> wrote:
>
> From: Arnd Bergmann <[email protected]>
>
> I've incorporated the feedback from Masahiro Yamada in this
> version, splitting out one more patch, rebasing on top of
> the kbuild tree, and changing the order of the patches.
>
> Please apply to the kbuild tree.

I'd actually like to see this as a separate branch, so that I can
merge it early - or other peoples git branches end up depending on it.

Yeah, it shouldn't change anything on its own, but since it allows for
new syntax, we might have other things depending on it (I'm obviously
thinking of the list_for_each_entry() series that keeps getting
posted).

Linus

2022-03-09 02:50:22

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH 0/4] [v4] Kbuild: std=gnu11 changes

On Wed, Mar 9, 2022 at 9:09 AM Linus Torvalds
<[email protected]> wrote:
>
> On Tue, Mar 8, 2022 at 1:56 PM Arnd Bergmann <[email protected]> wrote:
> >
> > From: Arnd Bergmann <[email protected]>
> >
> > I've incorporated the feedback from Masahiro Yamada in this
> > version, splitting out one more patch, rebasing on top of
> > the kbuild tree, and changing the order of the patches.
> >
> > Please apply to the kbuild tree.
>
> I'd actually like to see this as a separate branch, so that I can
> merge it early - or other peoples git branches end up depending on it.


OK, I can apply this to a separate branch, kbuild-gnu11.
(and I will queue this up shortly because it is already -rc7)

Then, I will send two pull reqs in the next MW,
but please note they will conflict with each other,
between this gnu11 patch set and the following
one in my usual kbuild branch:

https://patchwork.kernel.org/project/linux-kbuild/patch/[email protected]/


I hope this is not a complex conflict, but please let me know
if you have any requests to me.





> Yeah, it shouldn't change anything on its own, but since it allows for
> new syntax, we might have other things depending on it (I'm obviously
> thinking of the list_for_each_entry() series that keeps getting
> posted).
>
> Linus



--
Best Regards
Masahiro Yamada

2022-03-09 08:29:38

by Jani Nikula

[permalink] [raw]
Subject: Re: [PATCH 1/4] [v4] Kbuild: add -Wno-shift-negative-value where -Wextra is used

On Tue, 08 Mar 2022, Arnd Bergmann <[email protected]> wrote:
> From: Arnd Bergmann <[email protected]>
>
> As a preparation for moving to -std=gnu11, turn off the
> -Wshift-negative-value option. This warning is enabled by gcc when
> building with -Wextra for c99 or higher, but not for c89. Since
> the kernel already relies on well-defined overflow behavior,
> the warning is not helpful and can simply be disabled in
> all locations that use -Wextra.
>
> Signed-off-by: Arnd Bergmann <[email protected]>

Acked-by: Jani Nikula <[email protected]>

> ---
> [v4]
> split into a separate patch
> ---
> drivers/gpu/drm/i915/Makefile | 1 +
> drivers/staging/greybus/tools/Makefile | 3 ++-
> fs/btrfs/Makefile | 1 +
> scripts/Makefile.extrawarn | 1 +
> 4 files changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
> index 1b62b9f65196..1618a6e0af4e 100644
> --- a/drivers/gpu/drm/i915/Makefile
> +++ b/drivers/gpu/drm/i915/Makefile
> @@ -17,6 +17,7 @@ subdir-ccflags-y += -Wno-unused-parameter
> subdir-ccflags-y += -Wno-type-limits
> subdir-ccflags-y += -Wno-missing-field-initializers
> subdir-ccflags-y += -Wno-sign-compare
> +subdir-ccflags-y += -Wno-shift-negative-value
> subdir-ccflags-y += $(call cc-disable-warning, unused-but-set-variable)
> subdir-ccflags-y += $(call cc-disable-warning, frame-address)
> subdir-ccflags-$(CONFIG_DRM_I915_WERROR) += -Werror
> diff --git a/drivers/staging/greybus/tools/Makefile b/drivers/staging/greybus/tools/Makefile
> index ad0ae8053b79..a3bbd73171f2 100644
> --- a/drivers/staging/greybus/tools/Makefile
> +++ b/drivers/staging/greybus/tools/Makefile
> @@ -12,7 +12,8 @@ CFLAGS += -std=gnu99 -Wall -Wextra -g \
> -Wredundant-decls \
> -Wcast-align \
> -Wsign-compare \
> - -Wno-missing-field-initializers
> + -Wno-missing-field-initializers \
> + -Wno-shift-negative-value
>
> CC := $(CROSS_COMPILE)gcc
>
> diff --git a/fs/btrfs/Makefile b/fs/btrfs/Makefile
> index 4188ba3fd8c3..99f9995670ea 100644
> --- a/fs/btrfs/Makefile
> +++ b/fs/btrfs/Makefile
> @@ -17,6 +17,7 @@ subdir-ccflags-y += $(condflags)
> subdir-ccflags-y += -Wno-missing-field-initializers
> subdir-ccflags-y += -Wno-sign-compare
> subdir-ccflags-y += -Wno-type-limits
> +subdir-ccflags-y += -Wno-shift-negative-value
>
> obj-$(CONFIG_BTRFS_FS) := btrfs.o
>
> diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
> index 8be892887d71..650d0b8ceec3 100644
> --- a/scripts/Makefile.extrawarn
> +++ b/scripts/Makefile.extrawarn
> @@ -36,6 +36,7 @@ KBUILD_CFLAGS += $(call cc-option, -Wstringop-truncation)
> KBUILD_CFLAGS += -Wno-missing-field-initializers
> KBUILD_CFLAGS += -Wno-sign-compare
> KBUILD_CFLAGS += -Wno-type-limits
> +KBUILD_CFLAGS += -Wno-shift-negative-value
>
> KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN1

--
Jani Nikula, Intel Open Source Graphics Center

2022-03-09 11:47:52

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH 0/4] [v4] Kbuild: std=gnu11 changes

On Wed, Mar 9, 2022 at 11:16 AM Masahiro Yamada <[email protected]> wrote:
>
> On Wed, Mar 9, 2022 at 9:09 AM Linus Torvalds
> <[email protected]> wrote:
> >
> > On Tue, Mar 8, 2022 at 1:56 PM Arnd Bergmann <[email protected]> wrote:
> > >
> > > From: Arnd Bergmann <[email protected]>
> > >
> > > I've incorporated the feedback from Masahiro Yamada in this
> > > version, splitting out one more patch, rebasing on top of
> > > the kbuild tree, and changing the order of the patches.
> > >
> > > Please apply to the kbuild tree.
> >
> > I'd actually like to see this as a separate branch, so that I can
> > merge it early - or other peoples git branches end up depending on it.
>
>
> OK, I can apply this to a separate branch, kbuild-gnu11.
> (and I will queue this up shortly because it is already -rc7)
>
> Then, I will send two pull reqs in the next MW,
> but please note they will conflict with each other,
> between this gnu11 patch set and the following
> one in my usual kbuild branch:
>
> https://patchwork.kernel.org/project/linux-kbuild/patch/[email protected]/
>
>
> I hope this is not a complex conflict, but please let me know
> if you have any requests to me.
>
>
>
>
>


All, applied to linux-kbuild/kbuild-gnu11.

If somebody wants to give Reviewed-by, Acked-by, Tested-by, please.

I will append them later.








--
Best Regards
Masahiro Yamada

2022-03-09 19:03:28

by David Sterba

[permalink] [raw]
Subject: Re: [PATCH 1/4] [v4] Kbuild: add -Wno-shift-negative-value where -Wextra is used

On Tue, Mar 08, 2022 at 10:56:12PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <[email protected]>
>
> As a preparation for moving to -std=gnu11, turn off the
> -Wshift-negative-value option. This warning is enabled by gcc when
> building with -Wextra for c99 or higher, but not for c89. Since
> the kernel already relies on well-defined overflow behavior,
> the warning is not helpful and can simply be disabled in
> all locations that use -Wextra.
>
> Signed-off-by: Arnd Bergmann <[email protected]>
> ---
> [v4]
> split into a separate patch
> ---
> drivers/gpu/drm/i915/Makefile | 1 +
> drivers/staging/greybus/tools/Makefile | 3 ++-

For

> fs/btrfs/Makefile | 1 +

Acked-by: David Sterba <[email protected]>

2022-03-10 10:07:44

by Nathan Chancellor

[permalink] [raw]
Subject: Re: [PATCH 0/4] [v4] Kbuild: std=gnu11 changes

On Wed, Mar 09, 2022 at 06:18:18PM +0900, Masahiro Yamada wrote:
> On Wed, Mar 9, 2022 at 11:16 AM Masahiro Yamada <[email protected]> wrote:
> >
> > On Wed, Mar 9, 2022 at 9:09 AM Linus Torvalds
> > <[email protected]> wrote:
> > >
> > > On Tue, Mar 8, 2022 at 1:56 PM Arnd Bergmann <[email protected]> wrote:
> > > >
> > > > From: Arnd Bergmann <[email protected]>
> > > >
> > > > I've incorporated the feedback from Masahiro Yamada in this
> > > > version, splitting out one more patch, rebasing on top of
> > > > the kbuild tree, and changing the order of the patches.
> > > >
> > > > Please apply to the kbuild tree.
> > >
> > > I'd actually like to see this as a separate branch, so that I can
> > > merge it early - or other peoples git branches end up depending on it.
> >
> >
> > OK, I can apply this to a separate branch, kbuild-gnu11.
> > (and I will queue this up shortly because it is already -rc7)
> >
> > Then, I will send two pull reqs in the next MW,
> > but please note they will conflict with each other,
> > between this gnu11 patch set and the following
> > one in my usual kbuild branch:
> >
> > https://patchwork.kernel.org/project/linux-kbuild/patch/[email protected]/
> >
> >
> > I hope this is not a complex conflict, but please let me know
> > if you have any requests to me.
> >
> >
> >
> >
> >
>
>
> All, applied to linux-kbuild/kbuild-gnu11.
>
> If somebody wants to give Reviewed-by, Acked-by, Tested-by, please.
>
> I will append them later.

For the series:

Reviewed-by: Nathan Chancellor <[email protected]>

Cheers,
Nathan

2022-03-11 23:07:56

by Sedat Dilek

[permalink] [raw]
Subject: Re: [PATCH 0/4] [v4] Kbuild: std=gnu11 changes

On Thu, Mar 10, 2022 at 5:01 AM Nathan Chancellor <[email protected]> wrote:
>
> On Wed, Mar 09, 2022 at 06:18:18PM +0900, Masahiro Yamada wrote:
> > On Wed, Mar 9, 2022 at 11:16 AM Masahiro Yamada <[email protected]> wrote:
> > >
> > > On Wed, Mar 9, 2022 at 9:09 AM Linus Torvalds
> > > <[email protected]> wrote:
> > > >
> > > > On Tue, Mar 8, 2022 at 1:56 PM Arnd Bergmann <[email protected]> wrote:
> > > > >
> > > > > From: Arnd Bergmann <[email protected]>
> > > > >
> > > > > I've incorporated the feedback from Masahiro Yamada in this
> > > > > version, splitting out one more patch, rebasing on top of
> > > > > the kbuild tree, and changing the order of the patches.
> > > > >
> > > > > Please apply to the kbuild tree.
> > > >
> > > > I'd actually like to see this as a separate branch, so that I can
> > > > merge it early - or other peoples git branches end up depending on it.
> > >
> > >
> > > OK, I can apply this to a separate branch, kbuild-gnu11.
> > > (and I will queue this up shortly because it is already -rc7)
> > >
> > > Then, I will send two pull reqs in the next MW,
> > > but please note they will conflict with each other,
> > > between this gnu11 patch set and the following
> > > one in my usual kbuild branch:
> > >
> > > https://patchwork.kernel.org/project/linux-kbuild/patch/[email protected]/
> > >
> > >
> > > I hope this is not a complex conflict, but please let me know
> > > if you have any requests to me.
> > >
> > >
> > >
> > >
> > >
> >
> >
> > All, applied to linux-kbuild/kbuild-gnu11.
> >
> > If somebody wants to give Reviewed-by, Acked-by, Tested-by, please.
> >
> > I will append them later.
>
> For the series:
>
> Reviewed-by: Nathan Chancellor <[email protected]>
>

For the series:

Tested-by: Sedat Dilek <[email protected]> # LLVM/Clang v13.0.0 (x86-64)

- Sedat -