Question

I am trying to build a gcc cross compiler. I understand that before compiling the cross compiler I need to have the target binutils built already. why the building of the compiler need the target binutils ? the compiler alone only takes high level code and turn it to the assembly that I defined it in the compiler sources. so why do I need the target bintools for compiling the cross compiler ? It is written in all of the cross compiler documentation that I need them to be build before compiling the cross compiler. (e.g. http://wiki.osdev.org/Building_GCC and http://www.ifp.illinois.edu/~nakazato/tips/xgcc.html).

Était-ce utile?

La solution 2

Your key question seems to be:

why the building of the compiler need the target binutils ?

As described in Building a cross compiler, part of the build process for a GNU cross-compiler is to build runtime libraries for the target using the newly-compiled cross-compiler. So the binutils for the target need to be present for that step to succeed.

It may be possible to build the cross-compiler first, using empty files for the subset of binutils components that gcc needs - such as as and ld and ar and ranlib - then build and install the target binutils components into the proper locations, then build the target runtime libraries.

But it would be less error-prone to do things the following way (and the documentation recommends this): build binutils for the target first, place the specified executables in gcc's source tree, then build the cross-compiler.

Autres conseils

GCC needs an assembler to transform the assembly it generates into object files (machine code), and a linker to link object files together to produce executables and shared libraries. It also needs an archiver to produce static libraries/archives.

Those three are usually provided by the binutils package (among other useful tools): the GNU assembler as, linker ld and the ar archiver.

The binutils (binary utilities) provide low-level handling of binary files, such as linking, assembling, and parsing ELF files. The GCC compiler depends on these tools to create an executable, because it generates object files that binutils assemble into an executable image.

ELF is the format that Linux uses for binary executable files. The GCC compiler relies on binutils to provide much of the platform-specific functionality.

Here your are cross-compiling for some other architecture not for x86. So resulting binutils are platform-specific

while configuring has to give --host!=target. i.e --host=i686-pc-linux-gnu where --target=arm-none-linux-gnueabi. So resulting executable are not same which host already having binutils.

addition the basic things needs to be known.

The build machine, where the toolchain is built.

The host machine, where the toolchain will be executed.

The target machine, where the binaries created by the toolchain are executed.

So binutils will be having tools to generate and manipulate binaries for a given CPU architecture. Not for the one host is using

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top