Skip to content

Commit

Permalink
Switch linux RBE to ubuntu18.04, get rid of rbe_autoconfig (grpc#32559)
Browse files Browse the repository at this point in the history
First step in the modernization of our RBE stack (see
go/rbe-tech-debt-notes).

- Get rid of the deprecated rbe_autoconfig and start using
[rbe_configs_gen](https://github.com/bazelbuild/bazel-toolchains#rbe_configs_gen---cli-tool-to-generate-configs)
+ check in the generated toolchain configs.
- Switch from marketplace.gcr.io/google/rbe-ubuntu16-04 to
marketplace.gcr.io/google/rbe-ubuntu18-04 (this image is still not owned
by us, but at least it's newer and demonstrates how a switch to a newer
docker image is done).
- provide script for generating the linux RBE toolchain configs.
- cleanup RBE configuration in the bazelrc files used for remote build
  • Loading branch information
jtattermusch authored Mar 10, 2023
1 parent d47b569 commit a27b86f
Show file tree
Hide file tree
Showing 20 changed files with 6,824 additions and 56 deletions.
31 changes: 0 additions & 31 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,6 @@ custom_exec_properties(
},
)

load("@bazel_toolchains//rules:rbe_repo.bzl", "rbe_autoconfig")

# Create toolchain configuration for remote execution.
rbe_autoconfig(
name = "rbe_default",
exec_properties = create_rbe_exec_properties_dict(
docker_add_capabilities = "SYS_PTRACE",
docker_privileged = True,
labels = {
"os": "ubuntu",
"machine_size": "small",
},
os_family = "Linux",
),
# use exec_properties instead of deprecated remote_execution_properties
use_legacy_platform_definition = False,
)

load("@bazel_toolchains//rules:environments.bzl", "clang_env")
load("@bazel_skylib//lib:dicts.bzl", "dicts")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
Expand Down Expand Up @@ -71,17 +51,6 @@ local_repository(
path = "./src/core/ext/transport/binder/java",
)

# Create msan toolchain configuration for remote execution.
rbe_autoconfig(
name = "rbe_msan",
env = dicts.add(
clang_env(),
{
"BAZEL_LINKOPTS": "-lc++:-lc++abi:-lm",
},
),
)

load("@io_bazel_rules_python//python:pip.bzl", "pip_install")

pip_install(
Expand Down
6 changes: 3 additions & 3 deletions include/grpc/support/port_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -776,12 +776,12 @@ extern void gpr_unreachable_code(const char* reason, const char* file,

#define GRPC_CALLBACK_API_NONEXPERIMENTAL

/* clang 11 with msan miscompiles destruction of [[no_unique_address]] members
* of zero size - for a repro see:
/* clang 12 and lower with msan miscompiles destruction of [[no_unique_address]]
* members of zero size - for a repro see:
* test/core/compiler_bugs/miscompile_with_no_unique_address_test.cc
*/
#ifdef __clang__
#if __clang__ && __clang_major__ <= 11 && __has_feature(memory_sanitizer)
#if __clang__ && __clang_major__ <= 12 && __has_feature(memory_sanitizer)
#undef GPR_NO_UNIQUE_ADDRESS
#define GPR_NO_UNIQUE_ADDRESS
#endif
Expand Down
1 change: 1 addition & 0 deletions test/distrib/bazel/test_single_bazel_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ EXCLUDED_TARGETS=(
# This appears to be a legitimately broken BUILD file. There's a reference to
# a non-existent "link_dynamic_library.sh".
"-//third_party/toolchains/rbe_windows_bazel_5.2.0_vs2019:all"
"-//third_party/toolchains:rbe_windows_default_toolchain_suite"

# TODO(jtattermusch): add back once fixed
"-//examples/android/binder/..."
Expand Down
47 changes: 43 additions & 4 deletions third_party/toolchains/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,52 @@ package(default_visibility = ["//visibility:public"])

load("@bazel_toolchains//rules/exec_properties:exec_properties.bzl", "create_rbe_exec_properties_dict")

# The default toolchain suite for RBE linux, pass it to --crosstool_top
alias(
name = "rbe_windows",
actual = ":rbe_windows_2019",
name = "rbe_linux_default_toolchain_suite",
actual = "//third_party/toolchains/rbe_ubuntu1804/cc:toolchain",
)

# RBE Windows
# The default CC toolchain suite for RBE linux
alias(
name = "rbe_linux_default_cc_toolchain",
actual = "//third_party/toolchains/rbe_ubuntu1804/config:cc-toolchain",
)

# The default platform for RBE Linux
platform(
name = "rbe_linux_default_platform",
# Inherit from the platform target generated by 'rbe_configs_gen'.
parents = ["//third_party/toolchains/rbe_ubuntu1804/config:platform"],
exec_properties = create_rbe_exec_properties_dict(
docker_add_capabilities = "SYS_PTRACE",
docker_privileged = True,
# by default, all RBE actions will run on "small" workers.
# For individual targets, this can be overridden by adding the "exec_properties = LARGE_MACHINE"
# attribute.
labels = {
"os": "ubuntu",
"machine_size": "small",
},
os_family = "Linux",
),
)

# The default toolchain suite for RBE windows, pass it to --crosstool_top
alias(
name = "rbe_windows_default_toolchain_suite",
actual = "//third_party/toolchains/rbe_windows_bazel_5.2.0_vs2019:toolchain",
)

# The default CC toolchain suite for RBE windows
alias(
name = "rbe_windows_default_cc_toolchain",
actual = "//third_party/toolchains/rbe_windows_bazel_5.2.0_vs2019:cc-toolchain-x64_windows",
)

# The default platform for RBE windows
platform(
name = "rbe_windows_2019",
name = "rbe_windows_default_platform",
constraint_values = [
"@platforms//cpu:x86_64",
"@platforms//os:windows",
Expand All @@ -34,6 +72,7 @@ platform(
# See rbe_win2019/Dockerfile for image details
container_image = "docker://gcr.io/grpc-testing/rbe_windows2019@sha256:41772e8eeb9dd8c8b996bf32d58164d84b2315c8e81e634bbff5a0216b7f52fd",
os_family = "Windows",
# by default, all RBE actions will run on "small" workers.
labels = {"os": "windows_2019", "machine_size": "small"},
),
)
5 changes: 4 additions & 1 deletion third_party/toolchains/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Windows RBE toolchain configuration
# RBE toolchain configuration (Linux and Windows)

- rbe_ubuntu1804: Autogenerated toolchain configuration for linux RBE.
Run `generate_linux_rbe_configs.sh` to regenerate.

- rbe_windows_bazel_5.2.0_vs2019: The autogenerated toolchain configuration for windows RBE.
Note that the bazel version denotes the bazel version that was used to generate the toolchain configuration. The configuration
Expand Down
60 changes: 60 additions & 0 deletions third_party/toolchains/generate_linux_rbe_configs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash
# Copyright 2023 The gRPC Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Generate linux RBE configs using rbe_configs_gen.
# See https://github.com/bazelbuild/bazel-toolchains#rbe_configs_gen---cli-tool-to-generate-configs

set -ex

cd $(dirname $0)/../..

REPO_ROOT="$(pwd)"

TEMP_DIR="$(mktemp -d)"
pushd "${TEMP_DIR}"
# Build the "rbe_configs_gen" binary using the official instructions.
git clone https://github.com/bazelbuild/bazel-toolchains.git
cd bazel-toolchains
# Build "rbe_configs_gen" binary under docker and put it to the current directory.
docker run --rm -v $PWD:/srcdir -w /srcdir golang:1.16 go build -o rbe_configs_gen ./cmd/rbe_configs_gen/rbe_configs_gen.go
popd

# location of the "rbe_config_gen" binary as build by the previous step.
RBE_CONFIGS_GEN_TOOL_PATH="${TEMP_DIR}/bazel-toolchains/rbe_configs_gen"

# the container under which RBE actions will run
LINUX_RBE_DOCKER_IMAGE=l.gcr.io/google/rbe-ubuntu18-04@sha256:48b67b41118dbcdfc265e7335f454fbefa62681ab8d47200971fc7a52fb32054

# Bazel version used for configuring
# Needs to be one of the versions from bazel/supported_versions.txt chosen so that the result is compatible
# with other supported bazel versions.
BAZEL_VERSION=5.4.0

# TODO(jtattermusch): experiment with --cpp_env_json to simplify bazel build configuration.

# Where to store the generated configs (relative to repo root)
CONFIG_OUTPUT_PATH=third_party/toolchains/rbe_ubuntu1804

# Delete old generated configs.
rm -rf "${REPO_ROOT}/${CONFIG_OUTPUT_PATH}"

${RBE_CONFIGS_GEN_TOOL_PATH} \
--bazel_version="${BAZEL_VERSION}" \
--toolchain_container="${LINUX_RBE_DOCKER_IMAGE}" \
--output_src_root="${REPO_ROOT}" \
--output_config_path="${CONFIG_OUTPUT_PATH}" \
--exec_os=linux \
--target_os=linux \
--generate_java_configs=false
Loading

0 comments on commit a27b86f

Please sign in to comment.