Failure to compile with gcc 4.8

Message ID a1bdbe0c-e01f-8726-e85c-6eb9384f4240@polymtl.ca
State New
Headers show
Series
  • Failure to compile with gcc 4.8
Related show

Commit Message

Roland McGrath via Binutils April 29, 2021, 8:19 p.m.
Hi,

I tried building the repo with gcc 4.8 and got:

    /home/smarchi/src/binutils-gdb/opcodes/ppc-dis.c: In function ‘print_insn_powerpc’:
    /home/smarchi/src/binutils-gdb/opcodes/ppc-dis.c:1071:8: error: ‘for’ loop initial declarations are only allowed in C99 mode
            for (int i = 0; i < 2; i++)
            ^
    /home/smarchi/src/binutils-gdb/opcodes/ppc-dis.c:1071:8: note: use option -std=c99 or -std=gnu99 to compile your code

gcc 4.8 can compile C99, but we need to give it -std=c99 or -std=gnu99.

Should we add this (and to other sub-directories too)?

Simon

Comments

Roland McGrath via Binutils April 29, 2021, 8:50 p.m. | #1
On 4/29/21 3:19 PM, Simon Marchi via Binutils wrote:
> Hi,

> 

> I tried building the repo with gcc 4.8 and got:

> 

>     /home/smarchi/src/binutils-gdb/opcodes/ppc-dis.c: In function ‘print_insn_powerpc’:

>     /home/smarchi/src/binutils-gdb/opcodes/ppc-dis.c:1071:8: error: ‘for’ loop initial declarations are only allowed in C99 mode

>             for (int i = 0; i < 2; i++)

[snip]
>  

>  AC_PROG_CC

> +AC_PROG_CC_C99

>  AC_GNU_SOURCE

>  AC_USE_SYSTEM_EXTENSIONS



Already discussed in this thread:

    https://sourceware.org/pipermail/binutils/2021-April/116325.html

Basically, AC_PROG_CC_C99 is deprecated in newer Autoconf, so the discussion
is talking about maybe upgrading to AC_PROG_CC_C99 2.71.

Peter
Roland McGrath via Binutils April 29, 2021, 9:03 p.m. | #2
On 2021-04-29 4:50 p.m., Peter Bergner wrote:
> On 4/29/21 3:19 PM, Simon Marchi via Binutils wrote:

>> Hi,

>>

>> I tried building the repo with gcc 4.8 and got:

>>

>>     /home/smarchi/src/binutils-gdb/opcodes/ppc-dis.c: In function ‘print_insn_powerpc’:

>>     /home/smarchi/src/binutils-gdb/opcodes/ppc-dis.c:1071:8: error: ‘for’ loop initial declarations are only allowed in C99 mode

>>             for (int i = 0; i < 2; i++)

> [snip]

>>  

>>  AC_PROG_CC

>> +AC_PROG_CC_C99

>>  AC_GNU_SOURCE

>>  AC_USE_SYSTEM_EXTENSIONS

> 

> 

> Already discussed in this thread:

> 

>     https://sourceware.org/pipermail/binutils/2021-April/116325.html

> 

> Basically, AC_PROG_CC_C99 is deprecated in newer Autoconf, so the discussion

> is talking about maybe upgrading to AC_PROG_CC_C99 2.71.

> 

> Peter


Ah, I saw this but didn't realize it was connected.  Well, I would
be in favor of using AC_PROG_CC_C99 right now even if it's deprecated in
the future autoconf versions, at least to unbreak the build in the short
term.  We don't really know when the bump to autoconf 2.71 will happen,
and these lines can easily be removed then.

Simon
Roland McGrath via Binutils April 29, 2021, 10:39 p.m. | #3
On Thu, Apr 29, 2021 at 3:23 PM Simon Marchi via Binutils
<binutils@sourceware.org> wrote:
>

> Hi,

>

> I tried building the repo with gcc 4.8 and got:

>

>     /home/smarchi/src/binutils-gdb/opcodes/ppc-dis.c: In function ‘print_insn_powerpc’:

>     /home/smarchi/src/binutils-gdb/opcodes/ppc-dis.c:1071:8: error: ‘for’ loop initial declarations are only allowed in C99 mode

>             for (int i = 0; i < 2; i++)

>             ^

>     /home/smarchi/src/binutils-gdb/opcodes/ppc-dis.c:1071:8: note: use option -std=c99 or -std=gnu99 to compile your code

>

> gcc 4.8 can compile C99, but we need to give it -std=c99 or -std=gnu99.

>

> Should we add this (and to other sub-directories too)?

>

> diff --git a/opcodes/configure.ac b/opcodes/configure.ac

> index 911c9c6f082..3e79d38971f 100644

> --- a/opcodes/configure.ac

> +++ b/opcodes/configure.ac

> @@ -26,6 +26,7 @@ AC_CANONICAL_TARGET

>  AM_INIT_AUTOMAKE

>

>  AC_PROG_CC

> +AC_PROG_CC_C99

>  AC_GNU_SOURCE

>  AC_USE_SYSTEM_EXTENSIONS

>

> Simon


https://sourceware.org/pipermail/binutils/2021-April/116325.html


-- 
H.J.

Patch

diff --git a/opcodes/configure.ac b/opcodes/configure.ac
index 911c9c6f082..3e79d38971f 100644
--- a/opcodes/configure.ac
+++ b/opcodes/configure.ac
@@ -26,6 +26,7 @@  AC_CANONICAL_TARGET
 AM_INIT_AUTOMAKE
 
 AC_PROG_CC
+AC_PROG_CC_C99
 AC_GNU_SOURCE
 AC_USE_SYSTEM_EXTENSIONS