This repo shows how to set up a Bazel module using rules_python and supporting cross building.
Assuming you run on Linux x86_64, you can do this:
$ bazel run //hello
INFO: Analyzed target //hello:hello (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //hello:hello up-to-date:
bazel-bin/hello/hello
INFO: Elapsed time: 0.094s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Running command line: bazel-bin/hello/hello
3.13.11 (main, Dec 9 2025, 19:04:10) [Clang 21.1.4 ]
Linux-6.17.0-19-generic-x86_64-with-glibc2.42
2.4.4To build for aarch64, you can do this:
$ bazel build --config=aarch64 //hello
WARNING: Build option --platforms has changed, discarding analysis cache (this can be expensive, see https://bazel.build/advanced/performance/iteration-speed).
INFO: Analyzed target //hello:hello (0 packages loaded, 592 targets configured).
INFO: Found 1 target...
Target //hello:hello up-to-date:
bazel-bin/hello/hello
INFO: Elapsed time: 0.376s, Critical Path: 0.12s
INFO: 8 processes: 13 action cache hit, 8 internal.
INFO: Build completed successfully, 8 total actionsTo test it locally on your x86_64 machine, set up Docker with aarch64 emulation.
Then first make Bazel create a launcher script:
$ bazel run --config=aarch64 --script_path=hello_aarch64 //hello
INFO: Analyzed target //hello:hello (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //hello:hello up-to-date:
bazel-bin/hello/hello
INFO: Elapsed time: 0.080s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total actionAfterwards run it in an aarch64 container (python is required because the Bazel launcher needs a host Python, the toolchain used for the hello target is fully hermetic and managed by Bazel):
$ docker run -ti --platform linux/arm64 --volume $HOME:$HOME:ro --workdir $PWD python ./hello_aarch64
3.13.11 (main, Dec 9 2025, 19:03:00) [Clang 21.1.4 ]
Linux-6.17.0-19-generic-aarch64-with-glibc2.41
2.4.4