From: Alex Elder <elder@linaro.org>
To: Arnd Bergmann <arnd@kernel.org>, linux-kbuild@vger.kernel.org
Cc: Arnd Bergmann <arnd@arndb.de>,
Linus Torvalds <torvalds@linux-foundation.org>,
Masahiro Yamada <masahiroy@kernel.org>,
llvm@lists.linux.dev, Jonathan Corbet <corbet@lwn.net>,
Federico Vaga <federico.vaga@vaga.pv.it>,
Alex Shi <alexs@kernel.org>, Hu Haowen <src.res@email.cn>,
Michal Marek <michal.lkml@markovi.net>,
Nick Desaulniers <ndesaulniers@google.com>,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-doc-tw-discuss@lists.sourceforge.net,
linux-arm-kernel@lists.infradead.org,
intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
greybus-dev@lists.linaro.org, linux-staging@lists.linux.dev,
linux-btrfs@vger.kernel.org
Subject: Re: [greybus-dev] [PATCH] Kbuild: remove -std=gnu89 from compiler arguments
Date: Sun, 27 Feb 2022 17:04:50 -0600 [thread overview]
Message-ID: <dd41c574-05b0-23bc-646c-0bd341e6e50b@linaro.org> (raw)
In-Reply-To: <20220227215408.3180023-1-arnd@kernel.org>
On 2/27/22 3:52 PM, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> During a patch discussion, Linus brought up the option of changing
> the C standard version from gnu89 to gnu99, which allows using variable
> declaration inside of a for() loop. While the C99, C11 and later standards
> introduce many other features, most of these are already available in
> gnu89 as GNU extensions as well.
>
> An earlier attempt to do this when gcc-5 started defaulting to
> -std=gnu11 failed because at the time that caused warnings about
> designated initializers with older compilers. Now that gcc-5.1 is the
> minimum compiler version used for building kernels, that is no longer a
> concern. Similarly, the behavior of 'inline' functions changes between
> gnu89 and gnu89, but this was taken care of by defining 'inline' to
> include __attribute__((gnu_inline)) in order to allow building with
> clang a while ago.
>
> One minor issue that remains is an added gcc warning for shifts of
> negative integers when building with -Werror, which happens with the
> 'make W=1' option, as well as for three drivers in the kernel that always
> enable -Werror, but it was only observed with the i915 driver so far.
>
> Nathan Chancellor reported an additional -Wdeclaration-after-statement
> warning that appears in a system header on arm, this still needs a
> workaround.
>
> Since the differences between gnu99, gnu11 and gnu17 are fairly minimal
> and mainly impact warnings at the -Wpedantic level that the kernel
> never enables, the easiest way is to just leave out the -std=gnu89
> argument entirely, and rely on the compiler default language setting,
> which is gnu11 for gcc-5, and gnu1x/gnu17 for all other supported
> versions of gcc or clang.
>
> Link: https://lore.kernel.org/lkml/CAHk-=wiyCH7xeHcmiFJ-YgXUy2Jaj7pnkdKpcovt8fYbVFW3TA@mail.gmail.com/
> Link: https://github.com/ClangBuiltLinux/linux/issues/1603
> Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
> Cc: Masahiro Yamada <masahiroy@kernel.org>
> Cc: linux-kbuild@vger.kernel.org
> Cc: llvm@lists.linux.dev
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> I put the suggestion into patch form, based on what we discussed
> in the thread. I only gave it minimal testing, but it would
> be good to have it in linux-next if we want to do this in the
> merge window.
Did you determine what needed the new compiler flag based on
compilation results?
Glancing at the Greybus code, I don't believe there's any
reason it needs to shift a negative value. Such warnings
could be fixed by making certain variables unsigned, for
example.
I have no objection, I'll just make a note of it.
-Alex
> ---
> Documentation/process/programming-language.rst | 4 ++--
> .../translations/it_IT/process/programming-language.rst | 4 ++--
> .../translations/zh_CN/process/programming-language.rst | 4 ++--
> .../translations/zh_TW/process/programming-language.rst | 4 ++--
> 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 +
> 10 files changed, 17 insertions(+), 15 deletions(-)
>
. . .
> 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
>
. . .
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-02-27 23:06 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-27 21:52 [PATCH] Kbuild: remove -std=gnu89 from compiler arguments Arnd Bergmann
2022-02-27 22:36 ` Linus Torvalds
2022-02-28 8:07 ` Arnd Bergmann
2022-02-27 23:04 ` Alex Elder [this message]
2022-02-27 23:11 ` [greybus-dev] " Linus Torvalds
2022-02-27 23:57 ` Alex Elder
2022-02-28 8:11 ` Arnd Bergmann
2022-02-28 0:14 ` John Stoffel
2022-02-28 8:11 ` Arnd Bergmann
2022-02-28 12:02 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dd41c574-05b0-23bc-646c-0bd341e6e50b@linaro.org \
--to=elder@linaro.org \
--cc=alexs@kernel.org \
--cc=arnd@arndb.de \
--cc=arnd@kernel.org \
--cc=corbet@lwn.net \
--cc=dri-devel@lists.freedesktop.org \
--cc=federico.vaga@vaga.pv.it \
--cc=greybus-dev@lists.linaro.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-doc-tw-discuss@lists.sourceforge.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=llvm@lists.linux.dev \
--cc=masahiroy@kernel.org \
--cc=michal.lkml@markovi.net \
--cc=ndesaulniers@google.com \
--cc=src.res@email.cn \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox