Search code examples
linuxgccbuildconfiguregcj

How to Build gcc 4.2.0 in Redhat 7.0 for backward compatibility?


I must compile gcc 4.2.0 as a program dependency to compile (backward compatibility for a Cobol system). I solved some issues, but now is throwing an exception like this:

>/bin/sh ./libtool --tag=GCJ --mode=link /u01/home/app/talka/gcc/gcc-4.2.0/host-x86_64-unknown-linux-gnu/gcc/gcj -B/u01/home/app/talka/gcc/gcc-4.2.0/x86_64-unknown-linux-gnu/32/libjava/ -B/u01/home/app/talka/gcc/gcc-4.2.0/host-x86_64-unknown-linux-gnu/gcc/ -L/u01/home/app/talka/gcc/gcc-4.2.0/x86_64-unknown-linux-gnu/32/libjava -ffloat-store -fomit-frame-pointer -g -O2  -m32 -m32 -o jv-convert --main=gnu.gcj.convert.Convert -rpath /usr/local/lib/../lib -shared-libgcc   >-L/u01/home/app/talka/gcc/gcc-4.2.0/x86_64-unknown-linux-gnu/32/libjava/.libs libgcj.la
>
>/u01/home/app/talka/gcc/gcc-4.2.0/host-x86_64-unknown-linux-gnu/gcc/gcj -B/u01/home/app/talka/gcc/gcc-4.2.0/x86_64-unknown-linux-gnu/32/libjava/ -B/u01/home/app/talka/gcc/gcc-4.2.0/host-x86_64-unknown-linux-gnu/gcc/ -ffloat-store -fomit-frame-pointer -g -O2 -m32 -m32 -o .libs/jv-convert --main=gnu.gcj.convert.Convert -shared-libgcc  -L/u01/home/app/talka/gcc/gcc-4.2.0/x86_64-unknown-linux-gnu/32/libjava -L/u01/home/app/talka/gcc/gcc-4.2.0/x86_64-unknown-linux-gnu/32/libjava/.libs >./.libs/libgcj.so -L/u01/home/app/talka/gcc/gcc-4.2.0/x86_64-unknown-linux-gnu/32/libstdc++-v3/src -L/u01/home/app/talka/gcc/gcc-4.2.0/x86_64-unknown-linux-gnu/32/libstdc++-v3/src/.libs -lpthread -lrt -ldl -L/u01/home/app/talka/gcc/gcc-4.2.0/host-x86_64-unknown-linux-gnu/gcc/32 -L/usr/local/lib/../lib -L/lib/../lib -L/usr/lib/../lib -L/u01/home/app/talka/gcc/gcc-4.2.0/host-x86_64-unknown-linux-gnu/gcc -L/usr/local/lib -lgcc_s -lc -lgcc_s -Wl,--rpath -Wl,/usr/local/lib/../lib
>
>./.libs/libgcj.so: undefined reference to `__cxa_call_unexpected'
>
>collect2: ld returned 1 exit status
>
>make[5]: *** [jv-convert] Error 1
>
>make[5]: Leaving directory `/u01/home/app/talka/gcc/gcc-4.2.0/x86_64-unknown-linux-gnu/32/libjava'
>
>make[4]: *** [all-recursive] Error 1
>
>make[4]: Leaving directory `/u01/home/app/talka/gcc/gcc-4.2.0/x86_64-unknown-linux-gnu/32/libjava'
>
>make[3]: *** [multi-do] Error 1
>
>make[3]: Leaving directory `/u01/home/app/talka/gcc/gcc-4.2.0/x86_64-unknown-linux-gnu/libjava'
>
>make[2]: *** [all-multi] Error 2
>
>make[2]: Leaving directory `/u01/home/app/talka/gcc/gcc-4.2.0/x86_64-unknown-linux-gnu/libjava'
>
>make[1]: *** [all-target-libjava] Error 2
>
>make[1]: Leaving directory `/u01/home/app/talka/gcc/gcc-4.2.0'
>
>make: *** [all] Error 2

If we see this log, we can figure out that behavior is about a java lib (gcj) dependecy compilation. I've tried to avoid this java feature compilation with these settings:

sudo ./configure --program-suffix=4.2.0 --without-libjava --without-gcj --disable-libgcj

but it is still compiling GCJ library yet and the problem is still happening.

Our Linux Distribution is Redhat 7.0, and default gcc is 4.8.2 20140120 (Red Hat 4.3.2-16)

I will thank you any help.


Solution

  • GCC-4.2.0 : The bug fix version is gcc-4.2.4 ... Old gcc requires an oldish OS for the build : RHEL 6 → CentOS 6.9 ... But no chance building these old versions on RHEL 7.

    Build gcc-4.2.4 :

    $ tar xvf gcc-4.2.4.tar.bz2
    $ mkdir build-gcc42 && cd build-gcc42/
    $ export CC=gcc34 CXX=g++34 && ../gcc-4.2.4/configure --prefix=/usr/local/gcc424 --program-suffix=42 --enable-languages=c,c++ --enable-shared --enable-threads=posix --enable-__cxa_atexit -disable-checking --with-gnu-ld
    $ make
    

    Package : gcc42-c++-4.2.4-1.el6.x86_64.rpm (14.9MB) https://drive.google.com/file/d/1eYWk6Nd63xeqqAUoJldNWRuwEGO6cAyv/view?usp=sharing → provides /usr/bin/{ gcc42, g++42 }.

    Download, and install: # cd Downloads/ && yum install ./gcc42-c++-4.2.4-1.el6.x86_64.rpm. ... Works perfect with CentOS 7 (RHEL 7).


    Other old extra compilers for EL7 are {gcc34, g++34} https://drive.google.com/drive/folders/0B7S255p3kFXNSXBic2V4ekN0Slk?usp=sharing