-
Notifications
You must be signed in to change notification settings - Fork 0
Building gcc 3.4.6
I started using gcc-3.4.6 to cross-compile binutils-2.14 and gcc-3.2.2 a few years back when gcc-3.2.2 started having ICE problems or erring out during compilation with the native compiler. It's a good middleman compiler for compiling older legacy code. I've been maintaining and installing it alongside the system's native compiler.
This is just a rough list of the steps, problems, and solutions I went through to get a successful build of gcc-3.4.6 on the latest 64-bit version of Debian/Ubuntu based OSes.
sed -i -e 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in
The Multiarch spec changed the paths of libraries since gcc-3.4.6's release. As of writing this, "/lib32/ld-linux.so.2" is symlinked to "/lib/ld-linux.so.2". The 64-bit version is "/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2".
- Change LINK_SPEC definition in gcc/config/i386/linux64.h to support new spec (around line 60).
#define LINK_SPEC "%{!m32:-m elf_x86_64} %{m32:-m elf_i386} \
%{shared:-shared} \
%{!shared: \
%{!static: \
%{rdynamic:-export-dynamic} \
%{m32:%{!dynamic-linker:-dynamic-linker /lib32/ld-linux.so.2}} \
%{!m32:%{!dynamic-linker:-dynamic-linker /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2}}} \
%{static:-static}}"
- Change MULTILIB_OSDIRNAMES in gcc/config/i386/t-linux64 to support new spec.
MULTILIB_OSDIRNAMES = ../lib/x86_64-linux-gnu ../lib32
Warning: The paths used might be different for your flavor of Linux and might change in the future.
../gcc-3.4.6/configure --prefix=$prefix --disable-multilib --disable-nls --enable-shared --enable-languages=c,c++ --enable-threads=posix --mandir=/usr/share/man --libexec=/usr/lib --libdir=/usr/lib --enable-__cxa_atexit --enable-clocale=gnu --program-suffix=-3.4 --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
make --bootstrap
- File stubs.h, stubs-32.h, or cdefs.h not found
- crti.o not compatible for architecture
- crti.o not found
- genmodes: No such file or directory
These are all related to multiarch support. The executables can't find "ld-linux-x86-64.so.2" because the path is no longer valid. The crti.o errors stem from the same problem, I think.
- Install gcc-multilib instead of using native compiler via apt-get. There's probably a better way but this works for now.
sudo apt-get install gcc-multilib g++-multilib libmpc-dev bison flex
- CXXABI_1.3.8 not found
Add "--disable-nls" to the configuration options. At some point while building the language support for libstdc++, gcc-3.4.6 links system libraries to its internally built libstdc++.so.6 which doesn't support the CXXABI_1.3.8.
- lgcc_s not found
The system libraries aren't in gcc-3.4.6's default search paths so the linker can't find them. Symlinking the native system's libraries to gcc-3.4.6's libdir will fix that.
# Symlink to the system's libgcc_s and libstdc++ shared libraries in gcc-3.4.6's libdir
# $prefix is the path passed to --prefix during configure
cd $prefix/lib/gcc/x86_64-linux-gnu/3.4.6
ln -s /lib/x86_64-linux-gnu/libgcc_s.so.1 libgcc_s.so
ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 libstdc++.so
I move gcc-3.4.6's static libstdc++.a and libsupc++.a libraries to gcc-3.4.6's libdir. Then I remove the old shared libraries built by gcc-3.4.6 to prevent conflicts.
cd $prefix/usr/lib/x86_64-linux-gnu
mv ./*.a ../gcc/x86_64-linux-gnu/3.4.6/
cd ..
rm -r x86_64-linux-gnu