Skip to content

Commit e7ddb9e

Browse files
authored
Add exec_compatible_with to @go_sdk//:builder (#3943)
go_tool_binary() is completely oblivious of toolchains. The reason being that Go toolchains actually depend on their output. Adding a toolchain dependency would thus add a cyclic dependency. This is problematic, because it means that the actions with mnemonic GoToolchainBinaryBuild end up getting scheduled on arbitrary workers. Address this by adding exec_compatible_with to the locations where go_tool_binary() is instantiated, namely the auto-generated BUILD files that are part of Go SDKs. Fixes: #3942
1 parent a54fd56 commit e7ddb9e

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

go/private/BUILD.sdk.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ go_tool_binary(
6464
srcs = ["@io_bazel_rules_go//go/tools/builders:builder_srcs"],
6565
ldflags = "-X main.rulesGoStdlibPrefix={}".format(RULES_GO_STDLIB_PREFIX),
6666
sdk = ":go_sdk",
67+
exec_compatible_with = {exec_compatible_with},
6768
)
6869

6970
non_go_reset_target(

go/private/sdk.bzl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "patch", "read_user_netrc", "use_netrc")
1616
load("//go/private:common.bzl", "executable_path")
1717
load("//go/private:nogo.bzl", "go_register_nogo")
18+
load("//go/private:platforms.bzl", "GOARCH_CONSTRAINTS", "GOOS_CONSTRAINTS")
1819
load("//go/private/skylib/lib:versions.bzl", "versions")
1920

2021
MIN_SUPPORTED_VERSION = (1, 14, 0)
@@ -515,6 +516,10 @@ def _sdk_build_file(ctx, platform, version, experiments):
515516
"{exe}": ".exe" if goos == "windows" else "",
516517
"{version}": version,
517518
"{experiments}": repr(experiments),
519+
"{exec_compatible_with}": repr([
520+
GOARCH_CONSTRAINTS[goarch],
521+
GOOS_CONSTRAINTS[goos],
522+
]),
518523
},
519524
)
520525

0 commit comments

Comments
 (0)