9.10.2015, 4:23, Henri Tuhola kirjoitti:
Hi GCC maintainers
I've spent few days trying to figure out how to build a cross compiler
for my linux distribution.
For me "cross compiler" means producing code for some other system, the
"target
system", instead of the "build & host system". For instance :
x86_64-centos_6.5-linux to i686-ubuntu-linux
x86_64-centos_6.5-linux to sparc-solaris2.10
Here the target system already exists but maybe isn't very suitable to
work as the
preferred development system.
When the target system doesn't yet exist, the question isn't about a
cross compiler
but about creating the still unexisting target system. And one of the
tools needed for
this goal is some kind of cross compiler for the aimed target. How one
"bootstraps"
this, is then a question of attitude. Like "is one allowed to use any
existing tools and
pre-made components during the bootstrap phase?"
Of course one knows that a cross compiler made for 'arm-linux-gnu'
always produces
code for the generic 'arm-linux-gnu', the custom target system with its
custom glibc
doesn't have any influence for that. It has influence only for the
libraries created during
the GCC build process, the target headers and the standard target C
library (e.g. glibc)
have influence to the extra libraries made to be in sync with them.
So the process for creating a cross compiler for unexisting
arm-linux-gnu on an existing
x86_64-linux-gnu host system would be via the "normal cross compiler"
build method :
1. build and install the target binutils
2. copy some suitable target headers and libraries from some existing
(similar) target system
3. build and install the target GCC. Doing it needs the step 2 stuff
4. check that the binutils, GCC and target C library seems to work in
creating executables
5. replace the temporary step 2 stuff with a self-built glibc for the
target.
The process is analog with someone purchasing a car with GoodYear tyres,
driving to a
tyre shop and buying & installing new Michelins. The car stays the same
all the time, no
need to change anything in it although the tyres were changed...
The previous so simply describes "how the world works", not "how the
world is created
from absolute scratch". When one starts to try "creating a hammer
without any existing
hammer", things will become very complicated. For making a new cross
compiler I would
use about 1-4 hours work time, producing barely binutils and GCC for
some already existing
target would be quick, producing also glibc for the unexisting target
would make the process
slower.