Question

The question is relatively straight forward: how can I build a GCC of the 4.x series (along with binutils and friends) that targets a 2.4 ABI on the same architecture as the host for the compiler?

The host system would be x86 or x86_64 and the only requirement is that the built ELF files run on an old kernel as long as the ABI matches. (Kernel sources/headers exist)

A compatible libc would be required as well in order to link it in. However, I can dynamically link against it as well, since I know the (g)libc version.

Any pointers would be much appreciated. I'm somewhat familiar with crosstool-ng, but that doesn't even seem to support 2.4 kernels anymore (for obvious reasons).

Was it helpful?

Solution

Probably the easiest way is to setup a modern tool chain on an old OS.

RHEL 2.1 or 3 might be best, as they were supported until recently.

Compiling gcc 4 may be tricky since you'll need maths libraries as well. You may have to do a multi-stage approach.

EDIT:

For compiling newer gcc:

  1. Compile latest make - add to PATH
  2. Unpack gcc
  3. Unpack mpfr, gmp, mpc into the gcc directory
  4. symlink the versioned directories to the base (mpfr, gmp, mpc).
  5. Build and install gcc

Something like this:

cd ~/software
tar xjf $DOWNLOAD/gcc/gcc-core-${GCCVER}.tar.bz2 || failure "unpack gcc failed"
tar xjf $DOWNLOAD/gcc/gcc-g++-${GCCVER}.tar.bz2 || failure "unpack g++ failed"

cd gcc-${GCCVER}

tar xjf $DOWNLOAD/gmp-5.0.2.tar.bz2 || failure "unpack gmp failed"
#tar xjf $DOWNLOAD/gmp-4.3.2.tar.bz2 || failure "unpack gmp failed"
ln -s gmp-* gmp
tar xjf $DOWNLOAD/mpfr-2.4.2.tar.bz2 || failure "unpack mpfr failed"
#tar xjf $DOWNLOAD/mpfr-2.4.2.tar.bz2 || failure "unpack mpfr failed"
ln -s mpfr-* mpfr
tar xzf $DOWNLOAD/mpc-0.9.tar.gz || failure "unpack mpc failed"
ln -s mpc-* mpc

cd ..
mkdir gcc-build
cd gcc-build
../gcc-${GCCVER}/configure --prefix=/opt/tools || failure "configure failed"
make || failure "make failed"
make install || failure "install failed"

OTHER TIPS

I would believe that you probably should build a GCC cross-compiler in that case, and that you should compile GLibc which would handle the dependency to the old 2.4 kernel.

However, did you simply try to compile your code, and simply link it with the old 2.4-kernel compatible Glibc library ? I would suppose that should work.

And did you try to run your binary (obtained the simple way on a recent system using its recent GCC) on the old system? What is not working as expected?

Regards.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top