This directory contains scripts to set up a fully automated, repository-independent ARM64 cross-compilation pipeline for the eclipse-score/communication project using Bazel on an Ubuntu 22.04/24.04 host.
Setting up Bazel for C++ cross-compilation is notoriously challenging, especially for ARM targets. The main difficulties are:
- Toolchain API Instability: Bazel's C++ toolchain API has changed significantly across versions. Many online guides are outdated, and the modern
action_config/tool_pathAPIs are not always compatible with the version ofrules_ccin use. - rules_cc Compatibility: The
rules_ccrepository often lags behind Bazel releases. This leads to breakage if you use the latest Bazel with older toolchain configs, or vice versa. - Sysroot and Linker Issues: Getting the sysroot and linker (
g++vsgcc) set up correctly is critical. If Bazel usesgccfor linking C++ binaries, you get missing symbols likestd::cout. - Opaque Error Messages: Bazel's error messages for toolchain misconfiguration are often cryptic, making debugging slow and frustrating.
- Platform/Constraint Complexity: You must define and register platforms and toolchains explicitly, and Bazel's platform resolution can be non-obvious.
This project uses a legacy workaround that is robust across Bazel 8.x and recent rules_cc:
- Linker Tool Path Set to g++: In the toolchain config, the tool named
linkeris set to the path ofg++(notldorgcc). This forces Bazel to use the C++ linker, avoiding missing C++ symbols. - No action_config Blocks: Only the most stable Starlark APIs are used:
feature,flag_set,flag_group, andtool_path. Noaction_configorwith_feature_setblocks are present, as these are the source of most incompatibilities. - Explicit Sysroot Feature: The sysroot is injected as a feature for all compile and link actions, ensuring the correct headers and libraries are found for ARM.
- Minimal, Explicit Toolchain Registration: Only the required toolchain and platforms are registered, and all tool paths are specified.
- Ubuntu 22.04 or 24.04 host (x86-64)
- Bazel installed
- Internet access (to download
.debpackages fromports.ubuntu.com)
No apt repository access is required — all toolchain and sysroot files are fetched via direct .deb URLs.
Run the three scripts in order from this directory:
# 1. Bootstrap the aarch64 cross-toolchain and sysroot
sudo bash bootstrap_aarch64_toolchain_sysroot.sh
# 2. Build ACL for ARM64 and prepare the cross-compilation environment
bash prepare_score_cross_env.sh
# 3. Apply all required source and build patches
bash apply_score_cross_patches.shThen build with Bazel:
cd ~/test/communication
# ARM64 (Raspberry Pi 5 / aarch64)
bazel build //score/mw/com/example/ipc_bridge:ipc_bridge_cpp \
--platforms=//platforms:rpi5_aarch64
# x86-64 (host)
bazel build //score/mw/com/example/ipc_bridge:ipc_bridge_cppDownloads and installs everything needed for ARM64 cross-compilation directly from .deb packages — no apt repository required. Installs to /usr/bin and /usr/aarch64-linux-gnu.
What it does:
- Downloads
gcc-aarch64-linux-gnu,g++-aarch64-linux-gnu,libc6-dev:arm64, and other required packages - Extracts and installs toolchain binaries and sysroot files
- Cleans up temporary files
Verify after running:
aarch64-linux-gnu-gcc --version
ls /usr/aarch64-linux-gnuBuilds ACL for ARM64 and ensures the required sysroot headers are in place.
What it does:
- Builds
libaclfor ARM64 (if not already built) - Copies
acl.hinto the sysroot if missing
Applies all patches needed for a green-field cross-compilation build.
What it does:
- Copies the rebuilt
libacl.aand headers to the forkedscore_baselibs - Patches sysroot and
local_aclheaders to removeEXPORTmacros - Patches the
score_baselibsBUILDfile to uselocal_aclfor ARM64 - Configures Bazel to disable
-Werror=deprecated-declarations - Registers the ARM64 toolchain and platform in the Bazel workspace
- All scripts are idempotent — safe to re-run.
.debURLs inbootstrap_aarch64_toolchain_sysroot.share hardcoded to specific versions. If a URL returns 404, update it to the latest available version from ports.ubuntu.com.- For manual inspection of any step, read the individual scripts directly.