I've got an arm-based (arm_v8-64, ubuntu20.04) target machine and an amd-based host machine (x86_64, ubuntu20.04).

Since the cpu is much more powerful on the host than on the target, I wonder whether cross compiling could be faster than compiling natively? I mean based on a true-cross-compile environment (like copy all the arm-libs and use corresponding toolchains, not by emulators like QEMU).

  • Hard to answer. We don't know the specs of neither the ARM nor the AMD machine. Nowadays, both can play in the same performance league. My smartphone easiliy outperformes my Intel PC. Also, we don't know why the compile time matters to you. In embedded development, a build-deploy-debug cycle is often much quicker when compiling on the target, even if it has the slower CPU.
    – Philippos
    Commented Jun 16, 2023 at 7:35
  • @Philippos The question states "cpu is much more powerful on the host than on the target". There's no good reason to doubt the OP's assessment of their own hardware. Commented Jun 16, 2023 at 14:41
  • Cross-compiling is typically only one type of task of several tasks in software development. So other factors such as available storage capacity (for revision control?)) and editing capability (bigger screen?) could be more important than just compilation speed.
    – sawdust
    Commented Jul 12, 2023 at 1:21

2 Answers 2


Yes, cross-compiling is usually faster than compiling natively on a slower host. If your program takes one minute to build natively on x86, you can expect it to cross-compile to any other target in one minute using an x86-hosted cross-compiler.

  • 1
    It's been like that for decades. Nowadays I prefer to answer »it depends«, because I've met more and more constellations whether the speed gap between the ARM machine and the x86 host is less than the cross compiling overhead. The typical scenario is not pure compile time, but the whole build-deploy-debug cycle. Additionally, incremental builds typically can't make use of the whole bunch of cores in the host machine. Thus, it depends.
    – Philippos
    Commented Jun 16, 2023 at 7:28
  • 1
    @Philippos the first mistake there is to compare ARM to x86. That detail is largely irrelevant, especially in 2023. Historically ARM has been used for low power embedded devices because it's so good for them, but high performance ARM CPUs also exist. I'd be willing to bet an Apple m2 max will out perform any intel celeron. The more important detail is CPU computing power. That's not reliably measured in MHZ and cores but various benchmarks. Commented Jun 16, 2023 at 10:23

Cross compiling has very little overhead if any at all. The work a cross-compiling host has to do is basically the same as regular [non-cross-] compiling.

... High power cross-compiling host will usually be much faster than a low power host.


How a compiler works

From memory, at Uni in 2005, I was taught a compiler pipelines a number of steps:

  • pre-processing - flattening #inclide etc
  • token steam parsing - chopping source code into a stream of words and operators
  • semantic parsing - eg connecting variable names together
  • translation - converting the semantic tree into an abstract program
  • tiling - choosing CPU operations that fit together to write out the abstract program for a specific architecture.
  • linking - the program units are linked together with cross references memory addresses patched in

Architecture specific optimisations may be made in a few steps but the workflow is basically the same.

"Tiling" is important to understand. The abstract program is the most atomic form of the program but is not generally architecture dependent. CPU instructions often do multiple things in a single instruction (even in RISC instruction sets). Tiling choses architecture instructions that fit together to describe the same program as the abstract one.

Somehow I always imagine tiling like it's Tetris

How is a cross-compiler different?

Remember that a compiler itself is a program which was compiled.

The definition of a cross compiler is just a compiler that was itself tiled with a different instruction set to the one it will tile with.

So an x86_64->ARM cross compiler is running almost exactly the same abstract program as an ARM->ARM compiler!

  • The difference between an x86 host compiling an x86 program vs it compiling an ARM program is just a different instruction set the compiler uses while tiling.
  • The difference between an x86 host compiling an ARM program and an ARM host compiling an ARM program is just that the compiler which compiled the compiler used a different instruction set.

What really matters for compile time?

So what matters is not the architecture of the build host, but the raw CPU and memory capability of the build host.

  • While this answers the literal question, I'm still afraid the OP misses the point. When does compile time matter? If you do it many times. When do you do it often? While development. Now you have your application running on the target, find the error, fix it on the target, build it and run it: a few seconds. Do the same thing on your host, the compilation may be just half a second, but who cares, when the deployment process takes half a minute? There is so much to consider about the toolchain, IDE, connection between host and device – the pure compile time is likely the least relevant.
    – Philippos
    Commented Jun 16, 2023 at 13:25
  • @Philippos the question as asked above is the question. There's no reason to wonder why the OP want's to know, it wont change the answer. And you seem to be under the impression that compiling is going to "be just half a second". There's no evidence for that. Compiling the linux kernel, for example, can take hours on a reasonably powerful modern laptop. The build time, is very important in many cases. Not just in terms of wasting developer time, but also paying a cloud computing company to run your CI process. Cross, vs Native is a good piece of knowledge. Commented Jun 16, 2023 at 14:39
  • @Philippos on the on the other hand a well configured built boot loader can boot from TFTP over the network or simply mount an NFS server. So you can slim down deployment of programs other than the OS itself to near zero. Commented Jun 16, 2023 at 14:47
  • I mentioned the connection between host and device as part of the things to be considered. I didn't read about any broadband network connection. It's not uncommon that target devices need to live in a testing network apart from the development network.
    – Philippos
    Commented Jun 19, 2023 at 10:54
  • @Philippos You are making up hypothetical problems that have nothing to do with the OPs question. Compile time is very important for many of us working with embedded devices. That's a plain fact. The answer (as I've written here) is that cross compilation is basically no different in performance so readers should chose for themselves which is easier and not worry about cross compilation causing a bottleneck. That's what I've written here, it's what the OP is asking about. Commented Jun 19, 2023 at 11:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .