[U-Boot] [PATCH v2] Makefile: adopt --std=gnu11 for HOSTCFLAGS on Linux

Tom Rini trini at konsulko.com
Mon May 14 21:48:07 UTC 2018


On Mon, May 14, 2018 at 10:58:49PM +0200, Mark Kettenis wrote:
> > Date: Mon, 14 May 2018 10:57:12 -0400
> > From: Tom Rini <trini at konsulko.com>
> > 
> > On Mon, May 14, 2018 at 04:53:49PM +0200, Mark Kettenis wrote:
> > > > From: Philipp Tomsich <philipp.tomsich at theobroma-systems.com>
> > > > Date: Mon, 14 May 2018 15:22:06 +0200
> > > > 
> > > > Following the conversion of the SPDX license tags, a number of files
> > > > compiled with -pedantic now generate warnings similar to the following
> > > > for using C99-style '//' comments in ISO C90 code:
> > > > 
> > > >   tools/gen_eth_addr.c:1:1: warning: C++ style comments are not allowed in ISO C90
> > > >    // SPDX-License-Identifier: GPL-2.0+
> > > >    ^
> > > > 
> > > > The SPDX comment-style change means that these files have adopted C99,
> > > > so need to change the language-standard to --std=gnu99 or --std=gnu11
> > > > to let the compiler know this.
> > > > 
> > > > As we now require GCC 6 or newer for the cross-compiler, the project has
> > > > implicitly moved the project to GNU11: let older GCC versions on various
> > > > Linux distros know to treat our host tools as GNU11 as well.
> > > 
> > > Note that the requirement is on the cross-compiler, not the host
> > > compiler.  On our "primary" architectures OpenBSD 6.3 ships with Clang
> > > 5.0.1 and the current development version uses Clang 6.0.0, which
> > > default to --std=gnu11.  I do hope those will continue to be supported
> > > as the host compiler...
> > 
> > Does Clang 5.0.1 support gnu11 ?  Note that at this point we're not even
> > talking about moving to GNU11 features being used anywhere, just
> > enforcing consistency between modern (post gcc-5) and old (gcc-4.x)
> > compilers all in order to not have // style comments be a warning (which
> > in turn is a C99/gnu99 thing).  Thanks!
> 
> Yes.  Both Clang 5.0.1 and Clang 6.0.0 support gnu11 and even default to it.
> 
> If tere is no intention to use C11 features (and frankly I don't think
> C11 offers any significant benefits over C99), it'd make more sense to
> add --std=gnu99 instead of --std=gnu11 wouldn't it?  That would
> actually catch accidental use of C11 features.

Mostly because as I read more about the differences, I'm not sure
there's a good reason to artificially limit ourselves.  As a matter of
style, https://www.denx.de/wiki/U-Boot/CodingStyle is mostly correct and
just needs to be clarified when we deviate from "Linux kernel style".

And outside of comment style, being able to do:
for (int i = 0; i ... )
and declaring variables when used (within reason) are the only things
were are hard NO during the gnu89 days and we sometimes do now and could
maybe do more of now.   We need to tell older compilers we're doing
something newer, but I don't think we need to limit ourselves.

But I'm quite open to further discussion on this point.  Thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180514/92dcafa8/attachment.sig>


More information about the U-Boot mailing list