
Tom,
On 14.02.2019, at 01:31, Tom Rini trini@konsulko.com wrote:
On Wed, Feb 13, 2019 at 10:57:28PM +0100, Thomas Petazzoni wrote:
Commit 51c2345bd24837f9f67f16268da6dc71573f1325 ("Roll CRC16-CCITT into the hash infrastructure") has modified the crc16 code by adding a C99-style loop where the loop iterator is declared inside the for() statement. This breaks the build with old compiler such as gcc 4.7, that do not default to C99:
./tools/../lib/crc16.c: In function 'crc16_ccitt': ./tools/../lib/crc16.c:70:2: error: 'for' loop initial declarations are only allowed in C99 mode ./tools/../lib/crc16.c:70:2: note: use option -std=c99 or -std=gnu99 to compile your code
Switching to the regular coding style used in the rest of U-Boot allows to fix this build issue.
Signed-off-by: Thomas Petazzoni thomas.petazzoni@bootlin.com
So first, as Philipp notes we require gcc-6 or later for U-Boot itself. But you're hitting this on the host and I assume something uncommon but not unsupported yet where it's still on gcc-4.7. So I'm inclined to allow the patch and just note that we're likely to have other breakage in the future. Also, can you please v2 and reword with a Fixes tag instead? Thanks!
At the moment, our code requires at least GNU89 (i.e. not C89) or C99, even when compiling our host tools (which shouldn’t require any GNU extensions, as we shouldn’t need inline-asm in the host tools). So the earliest ISO standard language dialect we can hope to comply with is ISO/IEC 9899:1999 (i.e. C99).
I’ve never been a big fan of requiring GNU89 (i.e. GCC) just to get some of the C99 features we need (e.g. offsetof, const, …) when the source can simply be declared to be C99.
So shouldn’t we just add a “-std=c99” to HOST_EXTRACFLAGS?
Note that all of the ancient GCC versions still shipped with distributions (you don’t want to know how many hours I’ve spend supporting issues caused by CentOS still being on gcc-4.8 even on AArch64) will support C99: C99 support was completed in time for gcc-4.5 (AFAIR).
--Phil.
p.s.: I’m sorry for harping on about this, but I have become a bit of language lawyer over the years… and I promise to shut up about this specific occurance after this email ;-)