Skip to content

Commit 3b9a4bc

Browse files
authored
Tweak how we pass GOEXPERIMENT to actions (#4022)
**What type of PR is this?** Small cleanup. We can just encode the string in the repo rule instead of creating it for every go action. **What does this PR do? Why is it needed?** **Which issues(s) does this PR fix?** Fixes # **Other notes for review**
1 parent 3994841 commit 3b9a4bc

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

go/private/BUILD.sdk.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ go_sdk(
6262
go_tool_binary(
6363
name = "builder",
6464
srcs = ["@io_bazel_rules_go//go/tools/builders:builder_srcs"],
65+
exec_compatible_with = {exec_compatible_with},
6566
ldflags = "-X main.rulesGoStdlibPrefix={}".format(RULES_GO_STDLIB_PREFIX),
6667
sdk = ":go_sdk",
67-
exec_compatible_with = {exec_compatible_with},
6868
)
6969

7070
non_go_reset_target(

go/private/context.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ def _collect_cc_infos(deps, cdeps):
350350
def _check_binary_dep(go, dep, edge):
351351
"""Checks that this rule doesn't depend on a go_binary or go_test.
352352
353-
go_binary and go_test may return provides with useful information for other
353+
go_binary and go_test may return providers with useful information for other
354354
rules (like go_path), but go_binary and go_test may not depend on other
355355
go_binary and go_binary targets. Their dependencies may be built in
356356
different modes, resulting in conflicts and opaque errors.
@@ -483,7 +483,7 @@ def go_context(ctx, attr = None):
483483
env = {
484484
"GOARCH": mode.goarch,
485485
"GOOS": mode.goos,
486-
"GOEXPERIMENT": ",".join(toolchain.sdk.experiments),
486+
"GOEXPERIMENT": toolchain.sdk.experiments,
487487
"GOROOT": goroot,
488488
"GOROOT_FINAL": "GOROOT",
489489
"CGO_ENABLED": "0" if mode.pure else "1",

go/private/providers.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ GoSDK = provider(
4141
fields = {
4242
"goos": "The host OS the SDK was built for.",
4343
"goarch": "The host architecture the SDK was built for.",
44-
"experiments": "Go experiments to enable via GOEXPERIMENT.",
44+
"experiments": "Comma-separated Go experiments to enable via GOEXPERIMENT.",
4545
"root_file": "A file in the SDK root directory",
4646
"libs": ("Depset of pre-compiled .a files for the standard library " +
4747
"built for the execution platform."),

go/private/rules/sdk.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ go_sdk = rule(
4747
mandatory = True,
4848
doc = "The host architecture the SDK was built for",
4949
),
50-
"experiments": attr.string_list(
50+
"experiments": attr.string(
5151
mandatory = False,
52-
doc = "Go experiments to enable via GOEXPERIMENT",
52+
doc = "Comma-separated Go experiments to enable via GOEXPERIMENT",
5353
),
5454
"root_file": attr.label(
5555
mandatory = True,

go/private/sdk.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ def _sdk_build_file(ctx, platform, version, experiments):
515515
"{goarch}": goarch,
516516
"{exe}": ".exe" if goos == "windows" else "",
517517
"{version}": version,
518-
"{experiments}": repr(experiments),
518+
"{experiments}": repr(",".join(experiments)),
519519
"{exec_compatible_with}": repr([
520520
GOARCH_CONSTRAINTS[goarch],
521521
GOOS_CONSTRAINTS[goos],

0 commit comments

Comments
 (0)