如何在 Redhat 7.0 中构建 gcc 4.2.0 以实现向后兼容?

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

我必须将 gcc 4.2.0 编译为要编译的程序依赖项(Cobol 系统的向后兼容性)。我解决了一些问题,但现在抛出这样的异常:

>/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

如果我们看到这个日志,我们可以发现该行为与 java lib (gcj) 依赖编译有关。我试图通过这些设置避免此 java 功能编译:

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

但它仍在编译 GCJ 库,问题仍然存在。

我们的 Linux 发行版是 Redhat 7.0,默认 gcc4.8.2 20140120 (红帽 4.3.2-16)

我会感谢你的任何帮助。

GCC-4.2.0:错误修复版本是 gcc-4.2.4 ...旧的 gcc 需要旧的 OS 来构建:RHEL 6 → CentOS 6.9 .. . 但是没有机会在 RHEL 7 上构建这些旧版本。

构建 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

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

下载并安装:# cd Downloads/ && yum install ./gcc42-c++-4.2.4-1.el6.x86_64.rpm。 ... 与 CentOS 7 (RHEL 7) 完美配合。


其他旧的 EL7 额外编译器是 {gcc34, g++34} https://drive.google.com/drive/folders/0B7S255p3kFXNSXBic2V4ekN0Slk?usp=sharing