This is the mail archive of the crossgcc@sourceware.org mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Cross Compile Process


On Fri, Apr 1, 2011 at 12:10 AM, Yann E. MORIN
<yann.morin.1998@anciens.enib.fr> wrote:
> Xun, All,
>
> On Friday 01 April 2011 035611 Xun Li wrote:
>> I have been using crosstoll-NG for a while and it is a great tool!
>> Now I am trying to understand the internals of crosstool about how it
>> actually works so that I will be able to contribute and help others in
>> the future.
>> I looked into the script and the steps but I was getting confused
>> about the complicated process of building a cross compiler.
>> Are there any good documents explaining this well or would enable me
>> better understand how gcc actually get built?
>
> It's not yet in the released versions, but there is a tentative tutorial
> in the docs/ directory. You can look at it on-line at:
> ?http://ymorin.is-a-geek.org/hg/crosstool-ng/file/tip/docs/9%20-%20How%20is%20a%20toolchain%20constructed.txt
>

I have read the whole document and now understand most of the concepts.
One more question, why building GCC requires the C library? GCC only
compiles programs into assemblies while LD from binuntils links them
with C libraries. Why binutils doesn't need to understand C library
but GCC needs to?
Thanks!

> Or you can clone the repository and look locally:
> ?hg clone http://ymorin.is-a-geek.org/hg/crosstool-ng
>
>> Specifically, I am confused at the following questions:
>> 1. Why does it need to fetch the linux kernel? I searched around about
>> how to build a cross compiler, the methodologies are all different.
>
> It's explained in the above doc.
>
>> Some need to get the linux-libc headers, some don't need to get
>> anything.
>
> The doc is still not complete. You need the kernel headers iff you are
> targetting a Linux kernel based system. For bare-metal (with or without
> newlib), you do not need the Linux kernel headers, as you are not using
> Linux on the target.
>
> For Mingw targets, you do not need the Mingw 'kernel' headers, as those
> are not a moving target.
>
>> 2. What is the major difference of using newlib instead of glibc?
>
> The glibc, eglibc and uClibc C libraries all target Linux-based systems.
> glibc and its eglibc fork can also target Hurd, Solaris etc...
>
> Newlib is meant to be run on bare-metal systems, where there is no
> kernel at all (eg. a bootloader).
>
> So the choice is not between glibc/eglibc/uClibc on one side, and newlib
> on the other side. It rather depends on the target system: Linux kernel,
> or bare-metal.
>
> Note: you can also build a bare-metal toolchain that does not have newlib
> at all. Then, your programs will have to provide everything.
>
>> 3. Why building gcc needs to be split into different stages?
>
> It's in the above doc.
>
>> 3. If I am to configure the cross compiler to enable soft-float, where
>> exactly do crosstool set the flags?
>
> Not really documented. You can search for 'CT_DoBuildTargetTuple' in
> scripts/functions
>
> Regards,
> Yann E. MORIN.
>
> --
> .-----------------.--------------------.------------------.--------------------.
> | ?Yann E. MORIN ?| Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
> | +0/33 662376056 | Software ?Designer | \ / CAMPAIGN ? ? | ? ^ ? ? ? ? ? ? ? ?|
> | --==< O_o >==-- '------------.-------: ?X ?AGAINST ? ? ?| ?/e\ ?There is no ?|
> | http://ymorin.is-a-geek.org/ | (*_*) | / \ HTML MAIL ? ?| ?""" ?conspiracy. ?|
> '------------------------------'-------'------------------'--------------------'
>



-- 
Xun Li
Computer Architecture Lab
Department of Computer Science
University of California, Santa Barbara

--
For unsubscribe information see http://sourceware.org/lists.html#faq


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]