building native cross compiler

Michael Zintakis michael.zintakis@googlemail.com
Fri Mar 11 16:56:00 GMT 2011


Ian, Many thanks!


A few points which I probably did not explain fully!

It seems that I actually need to build 3 GCC compilers:

1. The 'native' compiler (following the 3-stage bootstrap process as 
described), which is placed 'somewhere' in my source tree and which has 
the only task of building the cross compiler as described in step 2;

2. Cross compiler (single-stage?) which is able to compile for the two 
target environments I am interested in - powerpc and i586/i686. Its main 
task is to compile and build my software for the selected target 
environment as well as building another GCC compiler (described in 3).

3. GCC compiler which is used as part of my built image and its only 
function is to compile programs/packages/binaries in the target 
environment for the target environment (being i586/i686 or powerpc).

If my assumption is correct in the (very simplified) scenario where I 
have x86_64 host environment and the target is, say, powerpc, then GCC 
No 1 needs to have x86_64 arch build, together with all the tools it 
needs. If so, I presume I need to follow the "Building native compiler" 
section (with the 3-stage bootstrap) for building that.

GCC No 2 (single-stage, no bootstrap?) would have to be also x86_64 and 
have libraries and tools built for both arches (cross-compilation) - 
x86_64 and powerpc.

GCC No 3 would have to be powerpc only and have the libraries and tools 
for that arch only.

Is that correct? If so, what process needs to be followed for building 
GCC No 3 - 3-stage bootstrap or a single-stage and bootstrap disabled?

If the above is all correct, this seems to be a long-drawn process. Is 
there any other route of achieving this (bearing in mind that I have to 
preserve the target environment as 'pure' as possible from the host)?

>> 1. Does that mean that I should follow the steps in the previous
>> section ("Building a native compiler"), use the 3-stage bootstrapping
>> and after this use the resulting compiler to build another GCC cross
>> compiler (including the appropriate toolchain) for the 3 architectures
>> I am interested in and use this compiler to build my software?
>>     
>
> Yes.  Actually most people just skip the step of building the native
> compiler, and just use the native compiler they have installed anyhow.
> That will normally work fine.
>   
Unfortunately, I can't do that - it is part of the process I need to 
follow - build a 'pure' GCC compiler which then builds my software 
without relying on the host environment (or at least relying on it as 
little as possible). I know that I could just transfer the GCC 
files/binaries from the host environment onto my source tree and do the 
rest, but that is not an option for me.


>> 3. If that is the case what steps should I use to build the GCC
>> compiler for the target image architectures (powerpc and i586/i686)?
>>     
>
> Here you are building a cross compiler.  I'm not sure what you are
> asking, exactly.  You use --target when you run configure as described
> in the documentation.
>   
I meant (but it seems I haven't explained it properly) GCC No 3 as I 
pointed out above.


>> 5. I assume at the end of this process I will end up with my native
>> cross compiler which I could then use to build my software. Do I need
>> to do anything else?
>>     
>
> The words "native cross compiler" don't mean anything to me.  I would
> say that you have a cross-compiler which runs on your build system.
>
>   
>> 6. Also, later in that section I am advised that for building the
>> binutils (which I would need to anyway!) I need to use the same --host
>> and --target that are used for configuring GCC, but which one - the
>> native cross-compiling GCC or the one that helped build it?
>>     
>
> The cross-compiler.
>
> It may help you to glance at
>     http://www.airs.com/ian/configure/configure_5.html#SEC29
> to understand the terminology we use.
>   
Brilliant guidance that - yes, I see "native" as in for the host 
environment, so I slightly messed these terms up I see.




More information about the Gcc-help mailing list