Skip to content

Commit ff69e19

Browse files
authored
build: add workaround to support RBE on macOS and windows (#22423)
Adds a workaround for `bazel-toolchains` that allows us to use RBE on macOS or Windows. This no longer works with the recent upgrades to `bazel-toolchains`. t It seems like we can remove this workaround once `bazel-toolchains` supports cross-compilation, or if we start generating the toolchain configurations our own (needs more investigation).
1 parent ce64f5e commit ff69e19

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

WORKSPACE

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ sass_repositories()
6969
# Bring in bazel_toolchains for RBE setup configuration.
7070
http_archive(
7171
name = "bazel_toolchains",
72+
# Patch `bazel-toolchains` to always consider the host platform as Linux. This is necessary
73+
# because the RBE configurations are incorrectly based on the host platform and this breaks
74+
# cross-platform remote execution. e.g. using RBE on macOS.
75+
# See: https://github.com/bazelbuild/bazel-toolchains/issues/895
76+
patches = ["//tools:rbe_cross_platform_workaround.patch"],
7277
sha256 = "1adf5db506a7e3c465a26988514cfc3971af6d5b3c2218925cd6e71ee443fc3f",
7378
strip_prefix = "bazel-toolchains-4.0.0",
7479
urls = [

tools/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package(default_visibility = ["//visibility:public"])
33
exports_files([
44
"system-config-tmpl.js",
55
"system-rxjs-operators.js",
6+
"rbe_cross_platform_workaround.patch",
67
])
78

89
# Workaround for https://github.com/bazelbuild/bazel-toolchains/issues/356. We need the
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
diff --git rules/rbe_repo/util.bzl rules/rbe_repo/util.bzl
2+
index 71a0e9e..a7db7bb 100644
3+
--- rules/rbe_repo/util.bzl
4+
+++ rules/rbe_repo/util.bzl
5+
@@ -136,20 +136,7 @@ def resolve_project_root(ctx):
6+
return mount_project_root, export_project_root, use_default_project
7+
8+
def os_family(ctx):
9+
- """Retrieve the OS Family of host environment
10+
-
11+
- Args:
12+
- ctx: the Bazel context object.
13+
-
14+
- Returns:
15+
- Returns the name of the OS Family
16+
- """
17+
- os_name = ctx.os.name.lower()
18+
- if os_name.find("windows") != -1:
19+
- return "Windows"
20+
- if os_name == "linux":
21+
- return "Linux"
22+
- return os_name
23+
+ return "Linux"
24+
25+
def validate_host(ctx):
26+
"""Perform validations of host environment to be able to run the rule.

0 commit comments

Comments
 (0)