This repo contains the definitions and scripts to build sysroot packages for x86_64 and
aarch64 (aka arm64) for use with the Bazel toolchains_llvm ruleset.
A matching text article for this repository can be found on my website: Sysroot package generation for use with toolchains_llvm
The source here is based off of the sysroot generation code in gcc-toolchain, authored by @f0rmiga.
Modifications have been made to:
- generate a valid sysroot package for use with toolchains_llvm instead of gcc-toolchain
- simplified to remove code that I didn't need
- and expanded where necessary to show how to fetch RHEL 8 specific files
The stock version of Dockerfile will produce a sysroot with the following library versions.
If you need different versions, I encourage you to go in and make the necessary changes.
Built from source:
- kernel headers 4.18
- glibc 2.28
- libstdc++ 10.3.0
Fetched from RHEL-UBI 8 container:
- openssl
- cyrus-sasl
Use the build.sh script to build the sysroot package using Docker. The current restriction is
that the container must run in x86_64. The sysroot package for other architectures are built using
cross-compilation from x86_64. That is, building a sysroot package on an Apple Silicon machine
is not supported at this time.
The entrypoint is build.sh that takes three args:
- The target architecture (
x86_64oraarch64) - The output directory path for the generated
.tar.zstfile - The target "variant". One of:
base, containing just the kernel, glibc, and libstdc++ filesssl, containingbaseplusopensslandcyrus-saslfrom a RHEL-UBI 8 container
./build.sh x86_64 . base
./build.sh aarch64 . baseIn the end you'll have a compressed size of ~55MB for x86_64 and ~37MB for aarch64.
https://github.com/bazel-contrib/toolchains_llvm?tab=readme-ov-file#sysroots
WORKSPACE implementation
https://github.com/bazel-contrib/toolchains_llvm/blob/1.0.0/tests/WORKSPACE#L116
bzlmod implementation
https://github.com/bazel-contrib/toolchains_llvm/blob/1.0.0/tests/MODULE.bazel#L145