Search code examples
gccbuildlibtoolrhel6gcc4.9

gcc 4.9.2 build error on RHEL6


I'm trying to build gcc 4.9.2 on RHEL6, as follows:

unpack the source tarball (to ~/gcc-4.9.2)

in the source dir:

./contrib/download_prerequisites

create a separate build directory ~/gcc-4.9.2-build

in the build dir:

~/gcc-4.9.2/configure --prefix=/usr/local/gcc-4.9.2
make

This fails with:

make[6]: Entering directory `/root/gcc-4.9.2-build-try0/x86_64-unknown-linux-gnu/libjava/classpath/native/jni/java-math'
/bin/sh ../../../libtool --tag=CC   --mode=compile /root/gcc-4.9.2-build-try0/./gcc/xgcc -B/root/gcc-4.9.2-build-try0/./gcc/ -B/usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/bin/ -B/usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/lib/ -isystem /usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/include -isystem /usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/sys-include    -DHAVE_CONFIG_H -I. -I/root/gcc-4.9.2/libjava/classpath/native/jni/java-math -I../../../include  -I/root/gcc-4.9.2/libjava/classpath/include -I/root/gcc-4.9.2/libjava/classpath/native/jni/classpath -I/root/gcc-4.9.2/libjava/classpath/native/jni/native-lib  -W -Wall -Wmissing-declarations -Wwrite-strings -Wmissing-prototypes -Wno-long-long  -I/usr/include -g -O2 -MT gnu_java_math_GMP.lo -MD -MP -MF .deps/gnu_java_math_GMP.Tpo -c -o gnu_java_math_GMP.lo /root/gcc-4.9.2/libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c
libtool: compile:  /root/gcc-4.9.2-build-try0/./gcc/xgcc -B/root/gcc-4.9.2-build-try0/./gcc/ -B/usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/bin/ -B/usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/lib/ -isystem /usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/include -isystem /usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/sys-include -DHAVE_CONFIG_H -I. -I/root/gcc-4.9.2/libjava/classpath/native/jni/java-math -I../../../include -I/root/gcc-4.9.2/libjava/classpath/include -I/root/gcc-4.9.2/libjava/classpath/native/jni/classpath -I/root/gcc-4.9.2/libjava/classpath/native/jni/native-lib -W -Wall -Wmissing-declarations -Wwrite-strings -Wmissing-prototypes -Wno-long-long -I/usr/include -g -O2 -MT gnu_java_math_GMP.lo -MD -MP -MF .deps/gnu_java_math_GMP.Tpo -c /root/gcc-4.9.2/libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c  -fPIC -DPIC -o .libs/gnu_java_math_GMP.o
mv -f .deps/gnu_java_math_GMP.Tpo .deps/gnu_java_math_GMP.Plo
/bin/sh ../../../libtool --tag=CC   --mode=link /root/gcc-4.9.2-build-try0/./gcc/xgcc -B/root/gcc-4.9.2-build-try0/./gcc/ -B/usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/bin/ -B/usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/lib/ -isystem /usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/include -isystem /usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/sys-include    -W -Wall -Wmissing-declarations -Wwrite-strings -Wmissing-prototypes -Wno-long-long  -I/usr/include -g -O2 -module -version-info 0:0:0 -no-undefined -lgmp -avoid-version  -o libjavamath.la -rpath /usr/local/gcc-4.9.2/lib/../lib64/gcj-4.9.2-15 gnu_java_math_GMP.lo ../../../native/jni/classpath/jcl.lo -lrt
libtool: link: /root/gcc-4.9.2-build-try0/./gcc/xgcc -B/root/gcc-4.9.2-build-try0/./gcc/ -B/usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/bin/ -B/usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/lib/ -isystem /usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/include -isystem /usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/sys-include    -shared  .libs/gnu_java_math_GMP.o ../../../native/jni/classpath/.libs/jcl.o   /root/gcc-4.9.2-build-try0/./gmp/.libs/libgmp.a -lrt    -Wl,-soname -Wl,libjavamath.so -o .libs/libjavamath.so
/usr/bin/ld: /root/gcc-4.9.2-build-try0/./gmp/.libs/libgmp.a(mp_set_fns.o): relocation R_X86_64_32 against `__gmp_default_allocate' can not be used when making a shared object; recompile with -fPIC
/root/gcc-4.9.2-build-try0/./gmp/.libs/libgmp.a: could not read symbols: Bad value
collect2: error: ld returned 1 exit status
make[6]: *** [libjavamath.la] Error 1
make[6]: Leaving directory `/root/gcc-4.9.2-build-try0/x86_64-unknown-linux-gnu/libjava/classpath/native/jni/java-math'

A little googling pointed me at the --disable-shared option, which sort of helped, but now:

in the build dir:

~/gcc-4.9.2/configure --prefix=/usr/local/gcc-4.9.2 --disable-shared

make

yielded a slightly different error:

make[8]: Entering directory `/root/gcc-4.9.2-build/x86_64-unknown-linux-gnu/32/libjava/classpath/native/jni/classpath'
/bin/sh ../../../libtool --tag=CC   --mode=compile /root/gcc-4.9.2-build/./gcc/xgcc -B/root/gcc-4.9.2-build/./gcc/ -B/usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/bin/ -B/usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/lib/ -isystem /usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/include -isystem /usr/local/gcc-4.9.2/x86_64-unknown-linux-gnu/sys-include  -m32 -DHAVE_CONFIG_H -I. -I/root/gcc-4.9.2/libjava/classpath/native/jni/classpath -I../../../include  -I/root/gcc-4.9.2/libjava/classpath/include -I/root/gcc-4.9.2/libjava/classpath/native/jni/classpath -I/root/gcc-4.9.2/libjava/classpath/native/jni/native-lib  -W -Wall -Wmissing-declarations -Wwrite-strings -Wmissing-prototypes -Wno-long-long -Wstrict-prototypes -pedantic -fexceptions -fasynchronous-unwind-tables -g -O2  -m32 -MT jcl.lo -MD -MP -MF .deps/jcl.Tpo -c -o jcl.lo /root/gcc-4.9.2/libjava/classpath/native/jni/classpath/jcl.c
libtool: compile: not configured to build any kind of library
libtool: compile: See the libtool documentation for more information.
libtool: compile: Fatal configuration error.
make[8]: *** [jcl.lo] Error 1
make[8]: Leaving directory `/root/gcc-4.9.2-build/x86_64-unknown-linux-gnu/32/libjava/classpath/native/jni/classpath'

Adding the --enable-static option made no difference.


Any suggestions on what might be wrong?

BTW, gcc 4.9.1 gave the same errors.


System: Linux 2.6.32-431.29.2.el6.x86_64 #1 SMP Sun Jul 27 15:55:46 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux

System is RHEL6, fully updated via Redhat, and has no custom RPMs that I know of.


Solution

  • Just completed building 4.9.2 on a CentOS 6.4 VM using 4.4.7 gcc. Ran into an out of space issue, which caused the build to fail, but once resolved, everything else went smoothly.

    Looks like your build is failing in the Java side of town? Not sure if you need the Java support, so have you tried compiling just the c/c++ language support?

    ~/gcc-4.9.2/configure --enable-languages=c,c++ ...
    

    I also don't require 32-bit binaries, so I add --disable-multilib to the list of configure parameters.