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

时间:2018-03-22 21:42:48

标签: linux gcc build configure gcj

我必须将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 ,默认 gcc 4.8.2 20140120(红帽4.3.2-16)

我会感谢你的帮助。

1 个答案:

答案 0 :(得分:1)

GCC-4.2.0:错误修复版本是gcc-4.2.4 ...旧的gcc需要一个旧的操作系统来构建: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