Currently supports Linux C/C++ (including CGO) & Java builds on Ubuntu 16.04 or Ubuntu 20.04.
Add the following lines to your WORKSPACE
file. You'll probably want to pin your version to a specific commit rather than master.
http_archive(
name = "io_buildbuddy_buildbuddy_toolchain",
sha256 = "e899f235b36cb901b678bd6f55c1229df23fcbc7921ac7a3585d29bff2bf9cfd",
strip_prefix = "buildbuddy-toolchain-fd351ca8f152d66fc97f9d98009e0ae000854e8f",
urls = ["https://github.com/buildbuddy-io/buildbuddy-toolchain/archive/fd351ca8f152d66fc97f9d98009e0ae000854e8f.tar.gz"],
)
load("@io_buildbuddy_buildbuddy_toolchain//:deps.bzl", "buildbuddy_deps")
buildbuddy_deps()
load("@io_buildbuddy_buildbuddy_toolchain//:rules.bzl", "buildbuddy")
buildbuddy(name = "buildbuddy_toolchain")
Now you can use the toolchain in your BuildBuddy RBE builds. For example:
bazel build server \
--remote_executor=remote.buildbuddy.io \
--extra_execution_platforms=@buildbuddy_toolchain//:platform \
--host_platform=@buildbuddy_toolchain//:platform \
--platforms=@buildbuddy_toolchain//:platform \
--crosstool_top=@buildbuddy_toolchain//:toolchain
Bazel provides support for Java toolchains out of the box. You can enabled the Java toolchain with the following flags:
--java_language_version=17
--tool_java_language_version=17
--java_runtime_version=remotejdk_17
--tool_java_runtime_version=remotejdk_17
Available verions are listed in Bazel's User Manual
If you need a custom Java toolchain, see Bazel's docs on Java toolchain configuration.
By default, the RBE images are configured to use GCC. If you would rather
use Clang / LLVM, set llvm = True
in the toolchain repository rule:
buildbuddy(name = "buildbuddy_toolchain", llvm = True)
The following Linux images are available for remote execution:
This image is the default when using the BuildBuddy toolchain. To reference it explicitly, you can declare the toolchain like this:
load("@io_buildbuddy_buildbuddy_toolchain//:rules.bzl", "buildbuddy", "UBUNTU16_04_IMAGE")
buildbuddy(name = "buildbuddy_toolchain", container_image = UBUNTU16_04_IMAGE)
This image includes the following build tools:
- Java 8 (javac 1.8.0_242)
- GCC 5.4.0
- GLIBC 2.23
- Clang/LLVM 11.0.0
- Python 2.7.12 (
python
in$PATH
uses this version) - Python 3.6.10
- Go 1.14.1
To use Ubuntu 20.04, import the toolchain as follows:
load("@io_buildbuddy_buildbuddy_toolchain//:rules.bzl", "buildbuddy", "UBUNTU20_04_IMAGE")
buildbuddy(name = "buildbuddy_toolchain", container_image = UBUNTU20_04_IMAGE)
This image includes the following build tools:
- Java 11.0.17
- GCC 9.4.0
- GLIBC 2.31
- Clang/LLVM 15.0.0
- Python 2.7.18 (
python
in$PATH
uses this version) - Python 3.8.10
- Go 1.19.4
If you need networking, you must enable it for the actions that need it. There is a performance hit when networking is enabled because networking resources need to be setup and torn down for each action. Because of the performance hit, you probably want to enable networking just for the actions that need it by adding the following exec_properties:
+ exec_properties = {
+ "dockerNetwork":"bridge",
+ },
- Check out our official documentation for RBE Setup
- For more advanced use cases, check out Bazel's bazel-toolchains repo and the docs on configuring C++ toolchains.
- Many thanks to the maintainers of LLVM toolchain repo, which served as the basis for this repo.
- Major props to the team at VSCO who's toolchain repo paved the way for using LLVM as a Bazel toolchain.
For advanced users who want to write their own CC toolchain, these existing CC toolchains that can serve as references:
-
Bazel's default local CC toolchains
-
Uber's Zig-based CC Toolchain
-
Apple_support's XCode toolchain