AlexTereshenkov/sysroots

★ 0Forks 0GitHub ↗Compare

README

C++ sysroot builder

This repository contains Bazel rules that leverage rules_distroless to build tiny sysroot tar files for a matrix of target platforms:

Distribution

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)

Architectures

  • amd64
  • arm64

C++ standard libraries

  • libstdc++ (GNU)
  • libc++ (LLVM)

Obtaining a sysroot

There are multiple ways for obtaining sysroots:

  1. 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
    
  2. 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
    
  3. Directly download an image layer as an http_archive in Bazel. For this, have a look at the example

Using this sysroot in Bazel

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.

Contributors

malt3

Issues