aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Schouten <eschouten@apple.com>2024-05-15 12:51:22 +0200
committerGitHub <noreply@github.com>2024-05-15 12:51:22 +0200
commite7ddb9ea474e6b5137dfc074f913529df80d7e5c (patch)
tree14bb74cd96034851029d0125bd2a62105716169d
parenta54fd5674f7184fe6e483fb5aee065a314994081 (diff)
downloadbazelbuild-rules_go-upstream-master.tar.gz
Add exec_compatible_with to @go_sdk//:builder (#3943)upstream-master
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
-rw-r--r--go/private/BUILD.sdk.bazel1
-rw-r--r--go/private/sdk.bzl5
2 files changed, 6 insertions, 0 deletions
diff --git a/go/private/BUILD.sdk.bazel b/go/private/BUILD.sdk.bazel
index 5256d6b9..95072c8d 100644
--- a/go/private/BUILD.sdk.bazel
+++ b/go/private/BUILD.sdk.bazel
@@ -64,6 +64,7 @@ go_tool_binary(
srcs = ["@io_bazel_rules_go//go/tools/builders:builder_srcs"],
ldflags = "-X main.rulesGoStdlibPrefix={}".format(RULES_GO_STDLIB_PREFIX),
sdk = ":go_sdk",
+ exec_compatible_with = {exec_compatible_with},
)
non_go_reset_target(
diff --git a/go/private/sdk.bzl b/go/private/sdk.bzl
index 63978902..c15cb7da 100644
--- a/go/private/sdk.bzl
+++ b/go/private/sdk.bzl
@@ -15,6 +15,7 @@
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "patch", "read_user_netrc", "use_netrc")
load("//go/private:common.bzl", "executable_path")
load("//go/private:nogo.bzl", "go_register_nogo")
+load("//go/private:platforms.bzl", "GOARCH_CONSTRAINTS", "GOOS_CONSTRAINTS")
load("//go/private/skylib/lib:versions.bzl", "versions")
MIN_SUPPORTED_VERSION = (1, 14, 0)
@@ -515,6 +516,10 @@ def _sdk_build_file(ctx, platform, version, experiments):
"{exe}": ".exe" if goos == "windows" else "",
"{version}": version,
"{experiments}": repr(experiments),
+ "{exec_compatible_with}": repr([
+ GOARCH_CONSTRAINTS[goarch],
+ GOOS_CONSTRAINTS[goos],
+ ]),
},
)