[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHk-=whWbENRz-vLY6vpESDLj6kGUTKO3khGtVfipHqwewh2HQ@mail.gmail.com>
Date: Sun, 27 Feb 2022 14:36:02 -0800
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Arnd Bergmann <arnd@...nel.org>
Cc: Linux Kbuild mailing list <linux-kbuild@...r.kernel.org>,
Arnd Bergmann <arnd@...db.de>,
Masahiro Yamada <masahiroy@...nel.org>, llvm@...ts.linux.dev,
Jonathan Corbet <corbet@....net>,
Federico Vaga <federico.vaga@...a.pv.it>,
Alex Shi <alexs@...nel.org>, Hu Haowen <src.res@...il.cn>,
Michal Marek <michal.lkml@...kovi.net>,
Nick Desaulniers <ndesaulniers@...gle.com>,
"open list:DOCUMENTATION" <linux-doc@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
linux-doc-tw-discuss@...ts.sourceforge.net,
Linux ARM <linux-arm-kernel@...ts.infradead.org>,
intel-gfx <intel-gfx@...ts.freedesktop.org>,
dri-devel <dri-devel@...ts.freedesktop.org>,
greybus-dev@...ts.linaro.org, linux-staging@...ts.linux.dev,
linux-btrfs <linux-btrfs@...r.kernel.org>
Subject: Re: [PATCH] Kbuild: remove -std=gnu89 from compiler arguments
On Sun, Feb 27, 2022 at 1:54 PM Arnd Bergmann <arnd@...nel.org> wrote:
>
> 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.
Honestly, I'd rather keep the C version we support as some explicit
thing, instead of "whatever the installed compiler is".
Not only do I suspect that you can set it in gcc spec files (so the
standard version might actually be site-specific, not compiler version
specific), but particularly with clang, I'd like that "GNU extensions
enabled" to be explicit. Yes, maybe it's the default, but let's make
sure.
The C version level has traditionally had a lot of odd semantic
meaning details - you mention "inline", others have existed. So it's
not just the actual new features that some C version implements, it's
those kind of "same syntax, different meaning" issues. I really don't
think that's something we want in the kernel any more.
Been there, done that, and we did the explicit standards level for a reason.
It may be true that c99/c11/c17 are all very similar, and don't have
those issues. Or maybe they do.
And I don't want somebody with a newer compiler version to not notice
that he or she ended up using a c17 feature, just because _that_
compiler supported it, and then other people get build errors because
their compilers use gnu11 instead by default.
Put another way: I see absolutely no upside to allowing different
users using higher/lower versions of the standard. There are only
downsides.
If gnu11 is supported by gcc-5.1 and up, and all the relevant clang
versions, then let's just pick that.
And if there are any possible future advantages to gnu17 (or eventual
gnu2x versions), let's document those, so that we can say "once our
compiler version requirements go up sufficiently, we'll move to gnuXX
because we want to take advantage of YY".
Please?
Linus
Linus
Powered by blists - more mailing lists