Makefile: adopt --std=gnu11 for HOSTCFLAGS on Linux
PATCH v2 1/1 Makefile: adopt --std=gnu11 for HOSTCFLAGS on Linux
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.
References: commit 83d290c56fab ("SPDX: Convert all of our single license tags to Linux Kernel style")
---
Changes in v2:
- Set '--std=gnu11' during compilation of host tools on Linux.
Makefile | 9 +++++++++ 1 file changed, 9 insertions(+)
Makefile +9 -0
@@ -258,6 +258,15 @@ HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer \ $(if $(CONFIG_TOOLS_DEBUG),-g) HOSTCXXFLAGS = -O2 +# With the move to GCC 6, we have implicitly upgraded our language +# standard to GNU11 (see https://gcc.gnu.org/gcc-5/porting_to.html). +# Some Linux distributions (including RHEL7, SLES13, Debian 8) still +# have older compilers as their default, so we make it explicit for +# these that our host tools are GNU11 (i.e. C11 w/ GNU extensions). +ifeq ($(HOSTOS),linux) +HOSTCFLAGS += --std=gnu11 +endif + ifeq ($(HOSTOS),cygwin) HOSTCFLAGS += -ansi endif
Signature · 1 line
2.1.4
PATCH v2 1/1 Makefile: adopt --std=gnu11 for HOSTCFLAGS on Linux
Quoted 12 lines · Philipp Tomsich
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.
Quoted 6 lines
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.
References: commit
83d290c56fab("SPDX: Convert all of our single license tags to Linux Kernel style")Signed-off-by Philipp Tomsich <[email protected]>
Signature · 8 lines
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/16f4a0a9/attachment.sig>
PATCH v2 1/1 Makefile: adopt --std=gnu11 for HOSTCFLAGS on Linux
In reply to Philipp TomsichQuoted 11 lines
From: Philipp Tomsich <[email protected]>
Date: Mon, 14 May 2018 15:22:06 +0200Following 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+
^
Quoted 7 lines
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...
Quoted 38 lines
References: commit
83d290c56fab("SPDX: Convert all of our single license tags to Linux Kernel style")Signed-off-by Philipp Tomsich <[email protected]>---
Changes in v2:
- Set '--std=gnu11' during compilation of host tools on Linux.Makefile | 9 +++++++++ 1 file changed, 9 insertions(+)Makefile +9
-0@@ -258,6 +258,15 @@ HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer \ $(if $(CONFIG_TOOLS_DEBUG),-g) HOSTCXXFLAGS = -O2 +# With the move to GCC 6, we have implicitly upgraded our language +# standard to GNU11 (see https://gcc.gnu.org/gcc-5/porting_to.html). +# Some Linux distributions (including RHEL7, SLES13, Debian 8) still +# have older compilers as their default, so we make it explicit for +# these that our host tools are GNU11 (i.e. C11 w/ GNU extensions). +ifeq ($(HOSTOS),linux) +HOSTCFLAGS += --std=gnu11 +endif + ifeq ($(HOSTOS),cygwin) HOSTCFLAGS += -ansi endifSignature · 6 lines
2.1.4 _______________________________________________ U-Boot mailing list U-Boot at lists.denx.de https://lists.denx.de/listinfo/u-boot
PATCH v2 1/1 Makefile: adopt --std=gnu11 for HOSTCFLAGS on Linux
Quoted 19 lines · Mark Kettenis
Quoted 11 lines
From: Philipp Tomsich <[email protected]>
Date: Mon, 14 May 2018 15:22:06 +0200Following 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+
^Quoted 7 lines
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.
Quoted 5 lines
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!
Signature · 8 lines
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/3962f624/attachment.sig>
PATCH v2 1/1 Makefile: adopt --std=gnu11 for HOSTCFLAGS on Linux
Quoted 29 lines
Date: Mon, 14 May 2018 10:57:12 -0400
From: Tom Rini <[email protected]>Quoted 19 lines · Mark Kettenis
Quoted 11 lines
From: Philipp Tomsich <[email protected]>
Date: Mon, 14 May 2018 15:22:06 +0200Following 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+
^Quoted 7 lines
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.
Quoted 5 lines
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...
Quoted 5 lines
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.
PATCH v2 1/1 Makefile: adopt --std=gnu11 for HOSTCFLAGS on Linux
Quoted 35 lines · Mark Kettenis
Quoted 29 lines
Date: Mon, 14 May 2018 10:57:12 -0400
From: Tom Rini <[email protected]>Quoted 19 lines · Mark Kettenis
Quoted 11 lines
From: Philipp Tomsich <[email protected]>
Date: Mon, 14 May 2018 15:22:06 +0200Following 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+
^Quoted 7 lines
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.
Quoted 5 lines
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...
Quoted 5 lines
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!
Quoted 6 lines
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!
Signature · 8 lines
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>
PATCH v2 1/1 Makefile: adopt --std=gnu11 for HOSTCFLAGS on Linux
In reply to Mark KettenisQuoted 22 lines · Mark Kettenis
Quoted 12 lines
From: Philipp Tomsich <[email protected]>
Date: Mon, 14 May 2018 15:22:06 +0200Following 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+
^Quoted 7 lines
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.
Quoted 5 lines
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…
Many of the files in question (e.g. lib/sha{1,256}.c) are shared between the target and the host tools.
Quoted 37 lines
Quoted 37 lines
References: commit
83d290c56fab("SPDX: Convert all of our single license tags to Linux Kernel style")Signed-off-by Philipp Tomsich <[email protected]>---
Changes in v2:
- Set '--std=gnu11' during compilation of host tools on Linux.
Makefile| 9 +++++++++1 file changed, 9 insertions(+)Makefile +0
-0@@ -258,6 +258,15 @@ HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer \ $(if $(CONFIG_TOOLS_DEBUG),-g)HOSTCXXFLAGS = -O2
Makefile +9
-0+# With the move to GCC 6, we have implicitly upgraded our language +# standard to GNU11 (see https://gcc.gnu.org/gcc-5/porting_to.html). +# Some Linux distributions (including RHEL7, SLES13, Debian 8) still +# have older compilers as their default, so we make it explicit for +# these that our host tools are GNU11 (i.e. C11 w/ GNU extensions). +ifeq ($(HOSTOS),linux) +HOSTCFLAGS += --std=gnu11 +endif +ifeq ($(HOSTOS),cygwin)
HOSTCFLAGS += -ansi
endifSignature · 6 lines
2.1.4 _______________________________________________ U-Boot mailing list U-Boot at lists.denx.de <mailto:[email protected]> https://lists.denx.de/listinfo/u-boot <https://lists.denx.de/listinfo/u-boot>
PATCH v2 1/1 Makefile: adopt --std=gnu11 for HOSTCFLAGS on Linux
Quoted 24 lines
From: "Dr. Philipp Tomsich" <[email protected]>
Date: Mon, 14 May 2018 17:02:43 +0200Quoted 21 lines · Mark Kettenis
Quoted 19 lines
From: Philipp Tomsich <[email protected]>
Date: Mon, 14 May 2018 15:22:06 +0200Following 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.
Quoted 8 lines
Quoted 5 lines
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…
Many of the files in question (e.g.
lib/sha{1,256}.c) are shared between the target and the host tools.
Sure. But these files are all supposed to be fairly high-level code written in standard C. Ane decent C99 compiler shoul be able to compile that code. The specific GCC 6 requirement for the cross compiler was (mostly) introduced to be able to meet size constraints nad I don't think it makes sense to enforce it for the host compiler.
PATCH v2 1/1 Makefile: adopt --std=gnu11 for HOSTCFLAGS on Linux
In reply to Philipp TomsichQuoted 12 lines · Philipp Tomsich
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.
Quoted 7 lines
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.
References: commit
83d290c56fab("SPDX: Convert all of our single license tags to Linux Kernel style")Signed-off-by Philipp Tomsich <[email protected]>Reviewed-by Tom Rini <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
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/20180524/6de72b7d/attachment.sig>