Problem building gmp 6.2 with GCC 8.4
Jared Gillis
jared at sonic.net
Tue Jul 28 01:32:07 UTC 2020
Hello,
I am trying to compile GCC 8.4.0 with GMP 6.2.0 and am running into a problem that I can't seem to resolve. For some reason, when compiling gmp, my existing system gcc (4.8.5 from CentOS 7.8), it does not set a C standard, so it defaults to C90, which does not compile gmp correctly:
make[5]: Entering directory `/root/gcc-8.4.0/host-x86_64-pc-linux-gnu/gmp/mpn'
/bin/sh ../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I../../.././gmp/mpn -I.. -D__GMP_WITHIN_GMP -I../../.././gmp -DOPERATION_`echo compute_powtab | sed 's/_$//'` -DNO_ASM -g -c -o compute_powtab.lo compute_powtab.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../.././gmp/mpn -I.. -D__GMP_WITHIN_GMP -I../../.././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
The strange thing is that GCC and GMP's configure steps do determine that they need to set the standard to gnu99:
configure: summary of build options:
Version: GNU MP 6.2.0
Host type: none-pc-linux-gnu
ABI: standard
Install prefix: /usr
Compiler: gcc -std=gnu99
Static libraries: yes
Shared libraries: no
Though it's only appending the "-std=gnu99" to the CC var, not the CFLAGS var. I'm not sure if that's the issue, or if so, how to fix it without editing the 10+ Makefiles that GCC or GMP created.
The steps and configure options I used were:
extract gcc-8.4.0 and gmp-6.2.0
symlink gcc-8.4.0/gmp to gmp-6.2.0
Run ./configure --prefix=/usr --program-prefix=vanilla- --program-suffix=-8.4.0 --enable-languages=c,c++,lto --enable-version-specific-runtime-libs --enable-shared --enable-static --enable-gold=yes --enable-ld=yes
Run make. Make then generates Makefiles for GMP and starts compilation, but hits the noted fail very soon.
I've used these exact same steps on the same host to build GCC 7.3.0 with GMP 6.1.2, and GCC 4.9.3 with GMP 6.1.0 in the past and haven't run into this issue before.
I'm not sure if this issue is on the GMP or GCC side, and I appreciate any help or advice offered.
Thanks in advance!
--
Jared
More information about the gmp-discuss
mailing list