technovelty

weblog of Ian Wienand

RSS  |  technovelty home  |  page of ian  |  ian@wienand.org

How much slower is cross compiling to your own host?

The usual case for cross-compiling is that your target is so woefully slow and under-powered that you would be insane to do anything else.

However, sometimes for one of the best reasons of all, "historical reasons", you might ship a 64-bit product but support building on 32-bit hosts, and thus cross-compile even on a very fast architecture like x86. How much does this cost, even though almost everyone is running the 32-bit cross-compiler on a modern 64-bit machine?

To test, I got a a 32-bit cross and a 64-bit native x86_64 compiler and toolchain; in this case based on gcc-4.1.2 and binutils 2.17. I then did a allyesconfig build of Linux 2.6.33 x86_64 kernel 3 times using the cross compilier toolchain and then native one. The results (in seconds):

32-bit64-bit
60905684
60505616
60635652
average
60675650

So, all up, ~7% less by building your 64-bit code on a 64-bit machine with a 32-bit cross-compiler.

posted at: Thu, 06 May 2010 16:50 | in /code/c | permalink | add comment (2 others)

Posted by mirabilos at Fri May 7 18:06:08 2010

You miss two things:

One, gcc skips some optimisation steps while
cross-compiling, to get more reliable.

Two, gcc cross-compilers still introduce more
bugs into the generated code than gcc native
compilers. (Unlike pcc.ludd.ltu.se for example.)

Posted by Jan Lübbe at Fri May 7 23:55:24 2010

Are you sure this is not simply because a 64 bit gcc is faster? It would be interesting to see if building a x86 kernel is faster using a 32 bit native or 64 bit cross compiler.

Add a comment
*Name
*Email (not shown)
Website
*Comment:
Anti-spam:
* denotes required field

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.