This repository contains Bazel rules that leverage rules_distroless to build tiny sysroot tar files for a matrix of target platforms:
Currently, only a single distribution is supported as a source of packages. In practice, the choice of distro doesn't matter, but the code allows you to add more distros easily.
- Debian 12 (bookworm)
- amd64
- arm64
- libstdc++ (GNU)
- libc++ (LLVM)
There are multiple ways for obtaining sysroots:
-
Build the target of choice and put it into a cloud storage bucket The following targets can be built:
@sysroots//:sysroot_bookworm_libcxx_amd64@sysroots//:sysroot_bookworm_libstdcxx_amd64@sysroots//:sysroot_bookworm_libcxx_arm64@sysroots//:sysroot_bookworm_libstdcxx_arm64
$ bazel build @sysroots//:sysroot_bookworm_libcxx_amd64 bazel-bin/sysroot_bookworm_libcxx_amd64.tar.zst -
Download the container image and use docker export
$ crane export --platform=linux/amd64 ghcr.io/malt3/sysroots/libcxx:bookworm ./sysroot.tar $ crane export --platform=linux/arm64 ghcr.io/malt3/sysroots/libstdcxx:bookworm ./sysroot.tar -
Directly download an image layer as an http_archive in Bazel. For this, have a look at the example
I recommend toolchains_llvm and static-clang. The example shows a way to set this up with the ability to target different C++ standard library implementations.