On Mon, 10 Aug 2020, Ron Zamir via Gcc-help wrote:
trying to build gcc-10.2
I've added the latest sources for the GMP, MPFR, MPC, ISL libraries
My system is CentOS 7.8 with gcc version 4.85
I'm running configure with the following parameters:
CC=/usr/bin/gcc CXX=/usr/bin/g++ ../gcc-10.2.0/configure
CFLAGS="-std=gnu99" CXXFLAGS="-std=c++11" --prefix=$HOME/.local/gcc-10
--disable-multilib
the additional CFLAGS and CXXFLAGS parameters where added to try to fix the
error (below)
when I run make, I get the error:
libtool: compile: /usr/bin/gcc -DHAVE_CONFIG_H -I.
-I../../../gcc-10.2.0/gmp/mpn -I.. -D__GMP_WITHIN_GMP
-I../../../gcc-10.2.0/gmp -DOPERATION_compute_powtab -DNO_ASM -g -c
compute_powtab.c -o compute_powtab.o
compute_powtab.c: In function 'mpn_compute_powtab_mul':
compute_powtab.c:142:3: error: 'for' loop initial declarations are only
allowed in C99 mode
for (long pi = start_idx; pi >= 0; pi--)
^
compute_powtab.c:142:3: note: use option -std=c99 or -std=gnu99 to compile
your code
compute_powtab.c: In function 'mpn_compute_powtab_div':
compute_powtab.c:226:3: error: 'for' loop initial declarations are only
allowed in C99 mode
for (long pi = n_pows - 1; pi >= 0; pi--)
^
compute_powtab.c:274:13: error: redefinition of 'pi'
for (long pi = n_pows; pi >= 0; pi--)
^
compute_powtab.c:226:13: note: previous definition of 'pi' was here
for (long pi = n_pows - 1; pi >= 0; pi--)
^
compute_powtab.c:274:3: error: 'for' loop initial declarations are only
allowed in C99 mode
for (long pi = n_pows; pi >= 0; pi--)
^
compute_powtab.c: In function 'powtab_decide':
compute_powtab.c:296:3: error: 'for' loop initial declarations are only
allowed in C99 mode
for (size_t pn = (un + 1) >> 1; pn != 1; pn = (pn + 1) >> 1)
^
compute_powtab.c:304:10: error: redefinition of 'pn'
size_t pn = un - 1;
^
compute_powtab.c:296:15: note: previous definition of 'pn' was here
for (size_t pn = (un + 1) >> 1; pn != 1; pn = (pn + 1) >> 1)
^
compute_powtab.c:308:3: error: 'for' loop initial declarations are only
allowed in C99 mode
for (long i = n_pows - 2; i >= 0; i--)
^
make[5]: *** [compute_powtab.lo] Error 1
what flags should I specify to fix this error?
You could use even newer gmp sources from the gmp-6.2 branch (not the main
gmp branch), which includes this patch
https://gmplib.org/repo/gmp-6.2/annotate/adcd8c8de72c/mpn/generic/compute_powtab.c
CC='/usr/bin/gcc -std=gnu99' may also work.
GMP's configure would normally add -std=gnu99 for you, but gcc's build
machinery passes it some CFLAGS, and GMP trusts the user to know what they
are doing if they explicitly pass some CFLAGS. Maybe during stage1 if we
detect that the compiler is an old version of gcc/clang we could add
-std=gnu99 in the CFLAGS that gcc passes to gmp.
Another option would be to install mpc-devel from centos instead of adding
the sources of gmp+mpfr+mpc, I think it has versions recent enough to be
supported.
--
Marc Glisse