GCC Canadian Cross: Difference between revisions

Nuke old and useless advise
[unchecked revision][unchecked revision]
(Nuke old and useless advise)
Line 6:
 
Building a cross-compiler takes some time, so you might want to use a faster machine (like, a PIV) to build a cross-compiler for a lesser machine (like, a Pentium laptop). You don't really need the initial cross-compiler for this, as the system compiler on the build machine (PIV) can generate binaries for the host machine (Pentium) alright.
 
Unfortunately, [[GCC]] doesn't really support this decently. It will generate files for the compiling system instead (since they're nearly identical, right?). There is no way to tell GCC not to, except for hacking the makefile. For our example, the PIV kept adding <tt>-march=pentium4</tt>, which obviously makes them unsuited for the laptop. The solution is to use <tt>sed</tt> plus some command-line tricks. This is done after <tt>configure</tt> (since <tt>configure</tt> generates the Makefile), and before <tt>make</tt> (since <tt>make</tt> uses the Makefile).
 
<source lang="bash">for i in `find ./ -name Makefile`; do mv $i $i.old; cat $i.old | sed -e 's/pentium4/i586/g' >$i; done</source>
 
This effectively forces the compiler to do i586 compilation.
 
To make such a "minor" canadian cross, specify <tt>--host</tt> (the system the compiler shall run on) in addition to <tt>--target</tt> (the system the compiler shall compile for). Note that you still need the <tt>sed</tt> line because configure adds <tt>-march</tt> to the Makefile.
 
[[Category:Compilers]]
Anonymous user