buildbuddy-io / buildbuddy-toolchain

Bazel toolchains for BuildBuddy RBE
MIT License
12 stars 12 forks source link

BuildBuddy RBE Toolchain

Currently supports Linux C/C++ (including CGO) & Java builds on Ubuntu 16.04 or Ubuntu 20.04.

Usage instructions

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

Java support

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.

Linux image variants

The following Linux images are available for remote execution:

Ubuntu 16.04 image (default)

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:

Ubuntu 20.04 image

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:

Networking

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",
+    },

Additional resources

Other CC toolchains

For advanced users who want to write their own CC toolchain, these existing CC toolchains that can serve as references: