skia2/toolchain/BUILD.bazel
Kevin Lubick fed97e8f40 [bazel] Add RBE support using hermetic Linux Clang toolchain
A new RBE worker-pool called gce_linux was created in
conjunction with this CL. See
https://docs.google.com/document/d/14xMZCKews69SSTfULhE8HDUzT5XvPwZ4CvRufEvcZ74/edit#
for some details on that.

Note: everything under bazel/rbe/gce_linux was autogenerated
and can be ignored from manual review. It basically specifies
what files are on the RBE image that are necessary for running
Bazel.

Testing it out can be done by authenticating for RBE
gcloud auth application-default login --no-browser

Then, run make -C bazel rbe_known_good_builds
to test it out.

On my 4 core laptop with an empty local cache, but a
warm remote cache, the build took <2 min instead of the
10+ minutes it would have [1].

The folder structure in //bazel/rbe is meant to let us
have multiple remote configurations there, e.g.
//bazel/rbe/gce_windows.

Suggested Review Order:
 - bazel/rbe/README.md
 - bazel/rbe/gce_linux_container/Dockerfile to see the
   bare-bones RBE image.
 - bazel/rbe/BUILD.bazel to see a custom platform defined.
   It is nearly identical to the autogenerated one
   in bazel/rbe/gce_linux/config/BUILD, with one extra
   field to force the gce_linux pool to be used.
 - .bazelrc to see the settings needed to make
   --config=linux-rbe work. The naming convention was
   inspired by SkCMS's setup [2], and allows us to have
   some common RBE settings (i.e. config:remote) and
   some specialized ones for the given host machine
   (e.g. config:linux-rbe) A very important, but subtle
   configuration, is on line 86 of .bazelrc where we say
   to use our hermetic toolchain and not whatever C++
   compiler and headers are on the host machine (aka
   the RBE container).
 - toolchain/build_toolchain.bzl to see some additional
   dependencies needed in the toolchain (to run IWYU) which
   I had installed locally but didn't realize were important.
 - third_party/BUILD.bazel to see an example of how failing
   to specify all files can result in something that works
   locally, but fails remotely.
   --execution_log_json_file=/tmp/execlog.json helped debug
   these issues.
 - All other files.

[1] http://go/scrcast/NjM1ODE4MDI0NzM3MTc3Nnw3ODViZmFkMi1iOA
[2] https://skia.googlesource.com/skcms/+/30c8e303800c256febb03a09fdcda7f75d119b1b/.bazelrc#20


Change-Id: Ia0a9e6a06c1a13071949ab402dc5d897df6b12e1
Bug: skia:12541
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/524359
Reviewed-by: Leandro Lovisolo <lovisolo@google.com>
2022-03-28 13:56:16 +00:00

47 lines
1.3 KiB
Python

load("@rules_cc//cc:defs.bzl", "cc_toolchain", "cc_toolchain_suite")
load(":clang_toolchain_config.bzl", "provide_clang_toolchain_config")
package(default_visibility = ["//visibility:public"])
# https://docs.bazel.build/versions/main/be/c-cpp.html#cc_toolchain_suite
cc_toolchain_suite(
name = "clang_suite",
toolchains = {
# The key is target_cpu|compiler
"k8|clang": ":clang_toolchain",
"x86_64|clang": ":clang_toolchain",
"k8": ":clang_toolchain",
},
)
filegroup(name = "not_implemented")
filegroup(
name = "all-toolchain-files",
srcs = [
"IWYU_mapping.imp",
"ar_trampoline.sh",
"clang_trampoline.sh",
"lld_trampoline.sh",
"@clang_linux_amd64//:all_files",
],
)
provide_clang_toolchain_config(
name = "clang_toolchain_config",
)
cc_toolchain(
name = "clang_toolchain",
all_files = ":all-toolchain-files",
ar_files = ":all-toolchain-files",
compiler_files = ":all-toolchain-files",
dwp_files = ":not_implemented",
linker_files = ":all-toolchain-files",
objcopy_files = ":not_implemented",
strip_files = ":not_implemented",
supports_param_files = 0,
toolchain_config = ":clang_toolchain_config",
toolchain_identifier = "clang-toolchain",
)