Cross Compilation - Faster Builds
When building an app with auterion-cli, it calls docker build --platform linux/arm64
under the hood. This makes docker run the build step in an emulated environment using QEMU.
This is convenient, as one can use the normal compilation steps for ones app as you would on the host, without having to worry about cross compilation. However, in larger projects, build times can grow quite long since the entire compilation is done in an emulated environment.
Cross compilation can improve the situation, but is generally fairly complex to set up. We provide tooling to allow for faster cross compilation.
Multi-stage build
We use dockers multi-stage build process for easier cross compilation
Sysroot stage: Runs emulated in the target arch (arm64), install all dependencies your app needs. This prepares a sysroot we can then later use to link against
Compile stage: Runs on your native arch (amd64). Compile your app using the supplied cross compiler. Link against the libraries installed in the first stage.
Run stage: Runs emulated in the target arch, and on the target. Based off the sysroot stage, copy over the compiled binaries from the build stage
Dockerfile setup
app-cross-buildenv contents
This image contains everything from auterion/app-base plus:
Cross-compilers for arm64 and amd64
aarch64-linux-gnu-*
x86_64-linux-gnu-*
CMake toolchain files for cross-compiling
/Toolchain_amd64.cmake
/Toolchain_arm64.cmake
Last updated