I was having problems using GCC 2.7.0 to compile the 1.2.13
kernel, and posted a couple of queries to this list. One
kind soul wrote to say that they were having the same problem,
but there were no suggestions.
This could mean that the questions were not sufficiently
specific, or that almost no one else has experienced this
problem, or that lots of people have encountered it, but
have mostly despaired of ever solving it, and reinstalled
their system from scratch.
On the off chance that there are other people out there
who have installed GCC 2.7.0, and now find it impossible to
compile kernel versions in the 1.2.x range, *I* *may* *have*
*solved* *your* *problem*! It is extremely simple. Read on.
At least some distributed binary versions of GCC 2.7.0 (i.e. the
one I've got) are capable of producing executables in both ELF
and the older a.out binary formats --- but produce ELF by
default, because that's where most of the world is headed.
The Linux kernel is not part of the stampede, however, in
the 1.2.x version range. These kernels *must* be compiled
in a.out. The distribution notes to GCC 2.7.0 (or the move_to_elf
document in the GCC subdirectory on sunsite.unc.edu, I can't
remember which at the moment) indicate that you can produce
a.out binaries by adding the option `-b i486-linuxaout' to
the command line. This is *true*. So the first step is to
edit the definitions HOSTCC and CC in the top-level kernel
Makefile, adding this option.
Now, if your header files are clean and correctly installed,
you will probably find that the compile fails almost immediately,
complaining that it cannot find `stdarg.h'. It seems that
this, and possibly some other header files necessary to
compile a.out binaries, need to be drawn from the ELF header
file sets. To point GCC at these additional header files,
define the environment variable C_INCLUDE_PATH to point at
them. In bash:
The header-file errors should disappear. The compile will
*now* fail with `Segmentation fault' when ld is invoked.
In simple operation, gcc calls the ld linker internally,
and (presumably) the -b i486-linuxaout option will trigger
an appropriate request to ld for a.out binary format
linking. When ld is called directly, however, this needs
to be *explicitly* called for. You get a segmentation fault
because ld is trying to run as an ELF linker on a.out
object code (I guess). The combination is toxic, and everybody
dies. The magic option is `-m i386linux', which tells ld
to emulate a proper a.out linker. In the top-level Makefile
again, add `-m i386linux' to the definition of the LD
NOW, the kernel should compile normally. Be sure to compile
your kernel with ELF binary format support. That way, your
system will be able to run the ELF binaries that GCC will
normally generate without all of this jiggery-pokery.
No guarantees --- but if it works for you, please let me
know. It will take some of the bite out of the hours it
took to work out these three simple steps.
Frank G Bennett, Jr | "On reflection, it seems
Law Department, SOAS, London | to me that life could be
Tel: (0171)323-6351 | really quite pleasant
WWW: http://rumple.soas.ac.uk/~fbennett/| compiler."