0

Add initial support for re-client to the chromium build.

This CL adds the'use_rbe' gn argument, that when set to true will use
re-client to do remote execution.

Bug: 1149386
Test: Manually built chromium with use_rbe=true and local config file.
Change-Id: Ibb1d1d89a713de7b7900bc21db7b66169ef8ad01
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2562678
Commit-Queue: Michael Savigny <msavigny@google.com>
Reviewed-by: Dirk Pranke <dpranke@google.com>
Cr-Commit-Position: refs/heads/master@{#835325}
This commit is contained in:
Michael Savigny
2020-12-09 20:03:52 +00:00
committed by Chromium LUCI CQ
parent eb9e02de16
commit 0e3c4167a7
3 changed files with 59 additions and 7 deletions
build/toolchain
buildtools/reclient_cfgs

@ -9,6 +9,7 @@ import("//build/config/sanitizers/sanitizers.gni")
import("//build/config/v8_target_cpu.gni")
import("//build/toolchain/cc_wrapper.gni")
import("//build/toolchain/goma.gni")
import("//build/toolchain/rbe.gni")
import("//build/toolchain/toolchain.gni")
if (is_nacl) {
@ -147,10 +148,15 @@ template("gcc_toolchain") {
}
}
# When the invoker has explicitly overridden use_goma or cc_wrapper in the
# toolchain args, use those values, otherwise default to the global one.
# This works because the only reasonable override that toolchains might
# supply for these values are to force-disable them.
# When the invoker has explicitly overridden user_rbe, use_goma or
# cc_wrapper in the toolchain args, use those values, otherwise default
# to the global one. This works because the only reasonable override
# that toolchains might supply for these values are to force-disable them.
if (defined(toolchain_args.use_rbe)) {
toolchain_uses_rbe = toolchain_args.use_rbe
} else {
toolchain_uses_rbe = use_rbe
}
if (defined(toolchain_args.use_goma)) {
toolchain_uses_goma = toolchain_args.use_goma
} else {
@ -161,6 +167,10 @@ template("gcc_toolchain") {
} else {
toolchain_cc_wrapper = cc_wrapper
}
assert(!(toolchain_uses_rbe && toolchain_uses_goma),
"Goma and RBE can't be used together.")
assert(!(toolchain_cc_wrapper != "" && toolchain_uses_rbe),
"RBE and cc_wrapper can't be used together.")
assert(!(toolchain_cc_wrapper != "" && toolchain_uses_goma),
"Goma and cc_wrapper can't be used together.")
@ -172,9 +182,11 @@ template("gcc_toolchain") {
# wrapper will have picked up gomacc via cmd-line arg. So need to prepend
# gomacc in that case.
goma_path = "$goma_dir/gomacc"
if (toolchain_uses_goma &&
(!defined(invoker_toolchain_args.needs_gomacc_path_arg) ||
!invoker_toolchain_args.needs_gomacc_path_arg)) {
if (toolchain_uses_rbe) {
compiler_prefix = "${cc_rewrapper} "
} else if (toolchain_uses_goma &&
(!defined(invoker_toolchain_args.needs_gomacc_path_arg) ||
!invoker_toolchain_args.needs_gomacc_path_arg)) {
compiler_prefix = "${goma_path} "
} else {
compiler_prefix = "${toolchain_cc_wrapper} "

36
build/toolchain/rbe.gni Normal file

@ -0,0 +1,36 @@
# Defines the configuration of Remote Build Execution (RBE).
# The directory where the re-client tooling binaries are.
rbe_bin_dir = rebase_path("//buildtools/reclient", root_build_dir)
# The directory where the re-client configuration files are.
rbe_cfg_dir = rebase_path("//buildtools/reclient_cfgs", root_build_dir)
# RBE Execution root - this should be the root of the source tree.
# This is defined here instead of in the config file because
# this will vary depending on where the user has placed the
# chromium source on their system.
rbe_exec_root = rebase_path("//")
# Configuration file selection based on operating system.
cfg_file = ""
if (is_linux || is_android) {
cfg_file = "${rbe_cfg_dir}/rewrapper_linux.cfg"
}
if (is_win) {
cfg_file = "${rbe_cfg_dir}/rewrapper_windows.cfg"
}
if (is_mac || is_ios) {
cfg_file = "${rbe_cfg_dir}/rewrapper_mac.cfg"
}
# C/C++ (clang) rewrapper prefix to use when use_rbe is true.
# As more action types are supported in reclient, more prefixes
# can be defined.
cc_rewrapper =
"${rbe_bin_dir}/rewrapper -cfg=${cfg_file} -exec_root=${rbe_exec_root}"
declare_args() {
# Set to true to enable remote compilation using RBE.
use_rbe = false
}

@ -0,0 +1,4 @@
platform=container-image=docker://gcr.io/cloud-marketplace/google/rbe-ubuntu16-04@sha256:b4dad0bfc4951d619229ab15343a311f2415a16ef83bcaa55b44f4e2bf1cf635
server_address=unix:///tmp/reproxy.sock
labels=type=compile,compiler=clang,lang=cpp
exec_strategy=racing