Skip to content

Commit 0042c2b

Browse files
authored
Upgrade bazel to 4.2.1 (LTS), upgrade bazel toolchain to 4.1.0 (grpc#27410)
* update bazel to 4.2.1 * add bazel 4.2.1 to update_mirror.sh * regenerate dockerfiles * upgrade bazel toolchains to 4.1.0 * use create_rbe_exec_properties_dict instead of the deprecated create_exec_properties_dict * RBE ubsan doesnt require the crosstool_top hack anymore * update rules_apple and build_bazel_apple_support
1 parent a51be7c commit 0042c2b

File tree

10 files changed

+37
-65
lines changed

10 files changed

+37
-65
lines changed

WORKSPACE

+12-29
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,15 @@ register_toolchains(
1818
"//third_party/toolchains/bazel_0.26.0_rbe_windows:cc-toolchain-x64_windows",
1919
)
2020

21-
load("@bazel_toolchains//rules/exec_properties:exec_properties.bzl", "create_exec_properties_dict", "custom_exec_properties", "merge_dicts")
21+
load("@bazel_toolchains//rules/exec_properties:exec_properties.bzl", "create_rbe_exec_properties_dict", "custom_exec_properties")
2222

2323
custom_exec_properties(
2424
name = "grpc_custom_exec_properties",
2525
constants = {
26-
"LARGE_MACHINE": merge_dicts(
27-
create_exec_properties_dict(),
28-
# TODO(jtattermusch): specifying 'labels = {"abc": "xyz"}' in create_exec_properties_dict
29-
# is not possible without https://github.com/bazelbuild/bazel-toolchains/pull/748
30-
# and currently the toolchain we're using is too old for that. To be able to select worker
31-
# pools through labels, we use a workaround and populate the corresponding label values
32-
# manually (see create_exec_properties_dict logic for how labels get transformed)
33-
# Remove this workaround once we transition to a new-enough bazel toolchain.
34-
# The next line corresponds to 'labels = {"os": "ubuntu", "machine_size": "large"}'
35-
{
36-
"label:os": "ubuntu",
37-
"label:machine_size": "large",
26+
"LARGE_MACHINE": create_rbe_exec_properties_dict(
27+
labels = {
28+
"os": "ubuntu",
29+
"machine_size": "large",
3830
},
3931
),
4032
},
@@ -45,23 +37,14 @@ load("@bazel_toolchains//rules:rbe_repo.bzl", "rbe_autoconfig")
4537
# Create toolchain configuration for remote execution.
4638
rbe_autoconfig(
4739
name = "rbe_default",
48-
exec_properties = merge_dicts(
49-
create_exec_properties_dict(
50-
docker_add_capabilities = "SYS_PTRACE",
51-
docker_privileged = True,
52-
os_family = "Linux",
53-
),
54-
# TODO(jtattermusch): specifying 'labels = {"abc": "xyz"}' in create_exec_properties_dict
55-
# is not possible without https://github.com/bazelbuild/bazel-toolchains/pull/748
56-
# and currently the toolchain we're using is too old for that. To be able to select worker
57-
# pools through labels, we use a workaround and populate the corresponding label values
58-
# manually (see create_exec_properties_dict logic for how labels get transformed)
59-
# Remove this workaround once we transition to a new-enough bazel toolchain.
60-
# The next line corresponds to 'labels = {"os": "ubuntu", "machine_size": "small"}'
61-
{
62-
"label:os": "ubuntu",
63-
"label:machine_size": "small",
40+
exec_properties = create_rbe_exec_properties_dict(
41+
docker_add_capabilities = "SYS_PTRACE",
42+
docker_privileged = True,
43+
labels = {
44+
"os": "ubuntu",
45+
"machine_size": "small",
6446
},
47+
os_family = "Linux",
6548
),
6649
# use exec_properties instead of deprecated remote_execution_properties
6750
use_legacy_platform_definition = False,

bazel/grpc_deps.bzl

+10-11
Original file line numberDiff line numberDiff line change
@@ -295,11 +295,11 @@ def grpc_deps():
295295
# list of releases is at https://releases.bazel.build/bazel-toolchains.html
296296
http_archive(
297297
name = "bazel_toolchains",
298-
sha256 = "0b36eef8a66f39c8dbae88e522d5bbbef49d5e66e834a982402c79962281be10",
299-
strip_prefix = "bazel-toolchains-1.0.1",
298+
sha256 = "179ec02f809e86abf56356d8898c8bd74069f1bd7c56044050c2cd3d79d0e024",
299+
strip_prefix = "bazel-toolchains-4.1.0",
300300
urls = [
301-
"https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/1.0.1.tar.gz",
302-
"https://github.com/bazelbuild/bazel-toolchains/releases/download/1.0.1/bazel-toolchains-1.0.1.tar.gz",
301+
"https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/4.1.0.tar.gz",
302+
"https://github.com/bazelbuild/bazel-toolchains/releases/download/4.1.0/bazel-toolchains-4.1.0.tar.gz",
303303
],
304304
)
305305

@@ -370,22 +370,21 @@ def grpc_deps():
370370
if "build_bazel_rules_apple" not in native.existing_rules():
371371
http_archive(
372372
name = "build_bazel_rules_apple",
373-
strip_prefix = "rules_apple-b869b0d3868d78a1d4ffd866ccb304fb68aa12c3",
374-
sha256 = "bdc8e66e70b8a75da23b79f1f8c6207356df07d041d96d2189add7ee0780cf4e",
373+
sha256 = "0052d452af7742c8f3a4e0929763388a66403de363775db7e90adecb2ba4944b",
375374
urls = [
376-
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/bazelbuild/rules_apple/archive/b869b0d3868d78a1d4ffd866ccb304fb68aa12c3.tar.gz",
377-
"https://github.com/bazelbuild/rules_apple/archive/b869b0d3868d78a1d4ffd866ccb304fb68aa12c3.tar.gz",
375+
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/bazelbuild/rules_apple/releases/download/0.31.3/rules_apple.0.31.3.tar.gz",
376+
"https://github.com/bazelbuild/rules_apple/releases/download/0.31.3/rules_apple.0.31.3.tar.gz",
378377
],
379378
)
380379

381380
if "build_bazel_apple_support" not in native.existing_rules():
382381
http_archive(
383382
name = "build_bazel_apple_support",
383+
sha256 = "76df040ade90836ff5543888d64616e7ba6c3a7b33b916aa3a4b68f342d1b447",
384384
urls = [
385-
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/bazelbuild/apple_support/releases/download/0.7.1/apple_support.0.7.1.tar.gz",
386-
"https://github.com/bazelbuild/apple_support/releases/download/0.7.1/apple_support.0.7.1.tar.gz",
385+
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/bazelbuild/apple_support/releases/download/0.11.0/apple_support.0.11.0.tar.gz",
386+
"https://github.com/bazelbuild/apple_support/releases/download/0.11.0/apple_support.0.11.0.tar.gz",
387387
],
388-
sha256 = "122ebf7fe7d1c8e938af6aeaee0efe788a3a2449ece5a8d6a428cb18d6f88033",
389388
)
390389

391390
if "libuv" not in native.existing_rules():

bazel/update_mirror.sh

+4
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ upload github.com/bazelbuild/bazel/releases/download/3.7.1/bazel-3.7.1-linux-x86
6969
upload github.com/bazelbuild/bazel/releases/download/3.7.1/bazel-3.7.1-darwin-x86_64
7070
upload github.com/bazelbuild/bazel/releases/download/3.7.1/bazel-3.7.1-windows-x86_64.exe
7171

72+
upload github.com/bazelbuild/bazel/releases/download/4.2.1/bazel-4.2.1-linux-x86_64
73+
upload github.com/bazelbuild/bazel/releases/download/4.2.1/bazel-4.2.1-darwin-x86_64
74+
upload github.com/bazelbuild/bazel/releases/download/4.2.1/bazel-4.2.1-windows-x86_64.exe
75+
7276
# Collect the github archives to mirror from grpc_deps.bzl
7377
grep -o '"https://github.com/[^"]*"' bazel/grpc_deps.bzl | sed 's/^"https:\/\///' | sed 's/"$//' | while read -r line ; do
7478
echo "Updating mirror for ${line}"

templates/tools/dockerfile/bazel.include

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Bazel installation
33

44
# Must be in sync with tools/bazel
5-
ENV BAZEL_VERSION 3.7.1
5+
ENV BAZEL_VERSION 4.2.1
66

77
# The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper.
88
ENV DISABLE_BAZEL_WRAPPER 1

third_party/toolchains/BUILD

+6-15
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ licenses(["notice"]) # Apache v2
1616

1717
package(default_visibility = ["//visibility:public"])
1818

19-
load("@bazel_toolchains//rules/exec_properties:exec_properties.bzl", "create_exec_properties_dict", "merge_dicts")
19+
load("@bazel_toolchains//rules/exec_properties:exec_properties.bzl", "create_rbe_exec_properties_dict")
2020

2121
alias(
2222
name = "rbe_windows",
@@ -30,19 +30,10 @@ platform(
3030
"@bazel_tools//platforms:x86_64",
3131
"@bazel_tools//platforms:windows",
3232
],
33-
exec_properties = merge_dicts(
34-
create_exec_properties_dict(
35-
# See rbe_win2019/Dockerfile for image details
36-
container_image = "docker://gcr.io/grpc-testing/rbe_windows2019_withdbg_toolchain@sha256:7b04ee7e29f942adbf4f70edd2ec4ba20a3e7237e1b54f5cae4b239c6ca41105",
37-
os_family = "Windows",
38-
),
39-
# TODO(jtattermusch): specifying 'labels = {"abc": "xyz"}' in create_exec_properties_dict
40-
# is not possible without https://github.com/bazelbuild/bazel-toolchains/pull/748
41-
# and currently the toolchain we're using is too old for that. To be able to select worker
42-
# pools through labels, we use a workaround and populate the corresponding label values
43-
# manually (see create_exec_properties_dict logic for how labels get transformed)
44-
# Remove this workaround once we transition to a new-enough bazel toolchain.
45-
# The next line corresponds to 'labels = {"os": "windows_2019", "machine_size": "small"}'
46-
{"label:os": "windows_2019", "label:machine_size": "small"}
33+
exec_properties = create_rbe_exec_properties_dict(
34+
# See rbe_win2019/Dockerfile for image details
35+
container_image = "docker://gcr.io/grpc-testing/rbe_windows2019_withdbg_toolchain@sha256:7b04ee7e29f942adbf4f70edd2ec4ba20a3e7237e1b54f5cae4b239c6ca41105",
36+
os_family = "Windows",
37+
labels = {"os": "windows_2019", "machine_size": "small"},
4738
),
4839
)

tools/bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fi
4242

4343
# IMPORTANT: if you update the version here, other parts of infrastructure might needs updating as well
4444
# (e.g. win RBE builds, sanity checks, bazel toolchains etc.)
45-
VERSION=3.7.1
45+
VERSION=4.2.1
4646
echo "INFO: Running bazel wrapper (see //tools/bazel for details), bazel version $VERSION will be used instead of system-wide bazel installation." >&2
4747

4848
# update tools/update_mirror.sh to populate the mirror with new bazel archives

tools/dockerfile/test/bazel/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ RUN python3.6 -m ensurepip && \
7171
# Bazel installation
7272

7373
# Must be in sync with tools/bazel
74-
ENV BAZEL_VERSION 3.7.1
74+
ENV BAZEL_VERSION 4.2.1
7575

7676
# The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper.
7777
ENV DISABLE_BAZEL_WRAPPER 1

tools/dockerfile/test/sanity/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ ENV CLANG_TIDY=clang-tidy-11
101101
# Bazel installation
102102

103103
# Must be in sync with tools/bazel
104-
ENV BAZEL_VERSION 3.7.1
104+
ENV BAZEL_VERSION 4.2.1
105105

106106
# The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper.
107107
ENV DISABLE_BAZEL_WRAPPER 1

tools/internal_ci/windows/bazel_rbe.bat

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
@rem TODO(jtattermusch): make this generate less output
1616
@rem TODO(jtattermusch): use tools/bazel script to keep the versions in sync
17-
choco install bazel -y --version 3.7.1 --limit-output
17+
choco install bazel -y --version 4.2.1 --limit-output
1818

1919
cd github/grpc
2020
set PATH=C:\tools\msys64\usr\bin;C:\Python27;%PATH%

tools/remote_build/rbe_common.bazelrc

-5
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,3 @@ build:ubsan --copt=-gmlt
8787
# use double the default value for "moderate" and "long" timeout as sanitizer
8888
# tests tend to be slower
8989
build:ubsan --test_timeout=60,600,1800,3600
90-
# override the config-agnostic crosstool_top
91-
# how to update the bazel toolchain for ubsan:
92-
# - check for the latest released version in https://github.com/bazelbuild/bazel-toolchains/tree/master/configs/experimental/ubuntu16_04_clang
93-
# - you might need to update the bazel_toolchains dependency in grpc_deps.bzl
94-
build:ubsan --crosstool_top=@bazel_toolchains//configs/experimental/ubuntu16_04_clang/1.3/bazel_0.29.1/ubsan:toolchain

0 commit comments

Comments
 (0)