LinuxMacOSToolchain
Native cross-compilers for Linux ARM/x86 targets, no Docker/emulation
Loading...
Searching...
No Matches
LinuxMacOSToolchain

Real cross-compilers for building Linux (ARM/x86) targets natively — no Docker, no emulation. Fast local iteration (compile-test-compile) against one target architecture without needing the Docker daemon running; complements, doesn't replace, the Docker buildx+QEMU multi-platform path (safeAPIRBC2oo2TestEnv/etc/scripts/build_multiarch.sh), which is better for producing container images across many architectures at once.

Despite the name (kept for continuity), setup.sh also supports a native Linux host (via apt/dnf), not just macOS.

Usage

./setup.sh # once — on macOS/Homebrew-on-Linux, installs prebuilt cross-gcc via the
# messense/macos-cross-toolchains Homebrew tap; on a bare Linux host, prints
# the apt-get/dnf command to run yourself, then re-run setup.sh
./verify.sh # cross-compiles a trivial hello-world for every bin/<arch>/<distro>/ target
# and confirms the ELF header's target architecture (can't execute foreign-arch
# binaries on this host)
PATH="$(pwd)/bin/aarch64/ubuntu:$PATH" cmake -S ../safeAPIFreamwork -B build-linux-aarch64 \
-DCMAKE_TOOLCHAIN_FILE=../safeAPIFreamwork/cmake/Toolchain-Linux.cmake \
-DLINUX_CROSS_COMPILE=aarch64-linux-gnu
cmake --build build-linux-aarch64

Layout: bin/<arch>/<distro>/

ubuntu/, debian/, fedora/ are three identical symlink sets pointing at the same glibc cross-gcc (mainstream glibc distros are ABI-compatible for this purpose) — alpine/ is the one genuinely separate (musl) toolchain. Architectures: aarch64, arm, x86_64, i686.

Coverage gaps (Linux-host apt/dnf path)

arm on dnf and musl on either package manager have no reliable cross-compiler package — use the Homebrew path instead, or build musl-cross-make manually. x86_64/i686 on a Linux host fall back to the native compiler (gcc -m32 for the 32-bit case). Not yet verified end-to-end on a real Linux host — package names were cross-checked against Debian/Ubuntu/Fedora documentation but this project's own development happened on macOS.

Scope

Cross-compiled output can't be run on this host — verify.sh only confirms the ELF header's target architecture. Actual execution needs QEMU or the real target hardware.