GCC Canadian Cross: Difference between revisions

From OSDev.wiki
Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content added Content deleted
No edit summary
m (tt->code&addstub)
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Stub}}
== Introduction ==
A Canadian Cross is to first build a cross-compiler for system Y (the host) on system X (the build-system). You would then use that cross-compiler, setting <code>--build=<where this compiler runs> --host=<where the compiler you're building shall run> --target=<where the executables the compiler you're building will build shall run></code>. This explanation alone should be sufficient to show why this is both non-trivial and error-prone.

A Canadian Cross is to first build a cross-compiler for system Y (the host) on system X (the build-system). You would then use that cross-compiler, setting <tt>--build=<where this compiler runs> --host=<where the compiler you're building shall run> --target=<where the executables the compiler you're building will build shall run></tt>. This explanation alone should be sufficient to show why this is both non-trivial and error-prone.


==="Minor" Canadian Cross===
==="Minor" Canadian Cross===


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.
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).

for i in `find ./ -name Makefile`; do mv $i $i.old; cat $i.old | sed -e 's/pentium4/i586/g' >$i; done

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]]
[[Category:Compilers]]

Latest revision as of 01:13, 10 September 2018

This page is a stub.
You can help the wiki by accurately adding more contents to it.

A Canadian Cross is to first build a cross-compiler for system Y (the host) on system X (the build-system). You would then use that cross-compiler, setting --build=<where this compiler runs> --host=<where the compiler you're building shall run> --target=<where the executables the compiler you're building will build shall run>. This explanation alone should be sufficient to show why this is both non-trivial and error-prone.

"Minor" Canadian Cross

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.