Cross compilation — documentation

submited by
Style Pass
2021-06-17 18:30:10

When compiling code, we can distinguish between the build platform, where the executable is built, and the host platform, where the compiled executable runs. 1

Native compilation is the special case where those two platforms are the same. Cross compilation is the general case where those two platforms are not.

Cross compilation needed when the host platform has limited resources (such as CPU) or when it’s not easily accessible for development.

It matters in cases where you’d like to distribute a compiler binary, as you’d then like to build a compiler on the build platform, compile code on the host plaform and run the final executable on the target platform.

In case that’s not possible (when the host platform is not easily accessible for development), the platform config has to be constructed manually via the following template:

Note that <vendor> is often unknown and <abi> is optional. There’s also no unique identifier for a platform, for example unknown and pc are interchangeable (hence it’s called config.guess).

Leave a Comment