Skip to content

Commit 4211c6d

Browse files
authored
Add toolchain param to affected actions (#3740)
* Add toolchain param to affected actions * Move GO_TOOLCHAIN to common.bzl * Update new location of GO_TOOLCHAIN * Fix error * Format files
1 parent 37ae8b3 commit 4211c6d

17 files changed

+22
-26
lines changed

extras/gomock.bzl

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
# DO NOT USE IT.
2424

2525
load("//go/private:context.bzl", "go_context")
26-
load("//go/private:go_toolchain.bzl", "GO_TOOLCHAIN")
26+
load("//go/private:common.bzl", "GO_TOOLCHAIN")
2727
load("//go/private/rules:wrappers.bzl", go_binary = "go_binary_macro")
2828
load("//go/private:providers.bzl", "GoLibrary")
2929
load("@bazel_skylib//lib:paths.bzl", "paths")

go/private/actions/compilepkg.bzl

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
load("//go/private:common.bzl", "GO_TOOLCHAIN")
1516
load(
1617
"//go/private:mode.bzl",
1718
"link_mode_args",
@@ -162,4 +163,5 @@ def emit_compilepkg(
162163
executable = go.toolchain._builder,
163164
arguments = [args],
164165
env = go.env,
166+
toolchain = GO_TOOLCHAIN,
165167
)

go/private/actions/link.bzl

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

1515
load(
1616
"//go/private:common.bzl",
17+
"GO_TOOLCHAIN",
1718
"as_set",
1819
"count_group_matches",
1920
"has_shared_lib_extension",
@@ -209,6 +210,7 @@ def emit_link(
209210
executable = go.toolchain._builder,
210211
arguments = [builder_args, "--", tool_args],
211212
env = go.env,
213+
toolchain = GO_TOOLCHAIN,
212214
)
213215

214216
def _extract_extldflags(gc_linkopts, extldflags):

go/private/actions/stdlib.bzl

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
load(
1616
"//go/private:common.bzl",
1717
"COVERAGE_OPTIONS_DENYLIST",
18+
"GO_TOOLCHAIN",
1819
)
1920
load(
2021
"//go/private:providers.bzl",
@@ -82,6 +83,7 @@ def _build_stdlib_list_json(go):
8283
executable = go.toolchain._builder,
8384
arguments = [args],
8485
env = _build_env(go),
86+
toolchain = GO_TOOLCHAIN,
8587
)
8688
return out
8789

@@ -149,6 +151,7 @@ def _build_stdlib(go):
149151
executable = go.toolchain._builder,
150152
arguments = [args],
151153
env = _build_env(go),
154+
toolchain = GO_TOOLCHAIN,
152155
)
153156
return GoStdLib(
154157
_list_json = _build_stdlib_list_json(go),

go/private/common.bzl

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
GO_TOOLCHAIN = "@io_bazel_rules_go//go:toolchain"
16+
1517
go_exts = [
1618
".go",
1719
]

go/private/context.bzl

+1-4
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ load(
2626
"OBJCPP_COMPILE_ACTION_NAME",
2727
"OBJC_COMPILE_ACTION_NAME",
2828
)
29-
load(
30-
":go_toolchain.bzl",
31-
"GO_TOOLCHAIN",
32-
)
3329
load(
3430
":providers.bzl",
3531
"CgoContextInfo",
@@ -52,6 +48,7 @@ load(
5248
load(
5349
":common.bzl",
5450
"COVERAGE_OPTIONS_DENYLIST",
51+
"GO_TOOLCHAIN",
5552
"as_iterable",
5653
"goos_to_extension",
5754
"goos_to_shared_extension",

go/private/go_toolchain.bzl

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
Toolchain rules used by go.
1616
"""
1717

18+
load("//go/private:common.bzl", "GO_TOOLCHAIN")
1819
load("//go/private:platforms.bzl", "PLATFORMS")
1920
load("//go/private:providers.bzl", "GoSDK")
2021
load("//go/private/actions:archive.bzl", "emit_archive")
@@ -23,8 +24,6 @@ load("//go/private/actions:link.bzl", "emit_link")
2324
load("//go/private/actions:stdlib.bzl", "emit_stdlib")
2425
load("@bazel_skylib//lib:selects.bzl", "selects")
2526

26-
GO_TOOLCHAIN = "@io_bazel_rules_go//go:toolchain"
27-
2827
def _go_toolchain_impl(ctx):
2928
sdk = ctx.attr.sdk[GoSDK]
3029
cross_compile = ctx.attr.goos != sdk.goos or ctx.attr.goarch != sdk.goarch

go/private/rules/binary.bzl

+1-4
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,11 @@ load(
1818
)
1919
load(
2020
"//go/private:common.bzl",
21+
"GO_TOOLCHAIN",
2122
"asm_exts",
2223
"cgo_exts",
2324
"go_exts",
2425
)
25-
load(
26-
"//go/private:go_toolchain.bzl",
27-
"GO_TOOLCHAIN",
28-
)
2926
load(
3027
"//go/private:providers.bzl",
3128
"GoLibrary",

go/private/rules/go_bin_for_host.bzl

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
load("@local_config_platform//:constraints.bzl", "HOST_CONSTRAINTS")
16-
load("//go/private:go_toolchain.bzl", "GO_TOOLCHAIN")
16+
load("//go/private:common.bzl", "GO_TOOLCHAIN")
1717

1818
def _ensure_target_cfg(ctx):
1919
# A target is assumed to be built in the target configuration if it is neither in the exec nor

go/private/rules/info.bzl

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ load(
1717
"go_context",
1818
)
1919
load(
20-
"//go/private:go_toolchain.bzl",
20+
"//go/private:common.bzl",
2121
"GO_TOOLCHAIN",
2222
)
2323

go/private/rules/library.bzl

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

1515
load(
1616
"//go/private:common.bzl",
17+
"GO_TOOLCHAIN",
1718
"asm_exts",
1819
"cgo_exts",
1920
"go_exts",
@@ -22,10 +23,6 @@ load(
2223
"//go/private:context.bzl",
2324
"go_context",
2425
)
25-
load(
26-
"//go/private:go_toolchain.bzl",
27-
"GO_TOOLCHAIN",
28-
)
2926
load(
3027
"//go/private:providers.bzl",
3128
"GoLibrary",

go/private/rules/nogo.bzl

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ load(
1717
"go_context",
1818
)
1919
load(
20-
"//go/private:go_toolchain.bzl",
20+
"//go/private:common.bzl",
2121
"GO_TOOLCHAIN",
2222
)
2323
load(

go/private/rules/source.bzl

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ load(
1717
"go_context",
1818
)
1919
load(
20-
"//go/private:go_toolchain.bzl",
20+
"//go/private:common.bzl",
2121
"GO_TOOLCHAIN",
2222
)
2323
load(

go/private/rules/stdlib.bzl

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ load(
1717
"go_context",
1818
)
1919
load(
20-
"//go/private:go_toolchain.bzl",
20+
"//go/private:common.bzl",
2121
"GO_TOOLCHAIN",
2222
)
2323
load(

go/private/rules/test.bzl

+1-4
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,13 @@ load(
1818
)
1919
load(
2020
"//go/private:common.bzl",
21+
"GO_TOOLCHAIN",
2122
"as_list",
2223
"asm_exts",
2324
"cgo_exts",
2425
"go_exts",
2526
"split_srcs",
2627
)
27-
load(
28-
"//go/private:go_toolchain.bzl",
29-
"GO_TOOLCHAIN",
30-
)
3128
load(
3229
"//go/private/rules:binary.bzl",
3330
"gc_linkopts",

proto/compiler.bzl

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ load(
2222
"go_context",
2323
)
2424
load(
25-
"//go/private:go_toolchain.bzl",
25+
"//go/private:common.bzl",
2626
"GO_TOOLCHAIN",
2727
)
2828
load(

proto/def.bzl

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ load(
2828
"proto_path",
2929
)
3030
load(
31-
"//go/private:go_toolchain.bzl",
31+
"//go/private:common.bzl",
3232
"GO_TOOLCHAIN",
3333
)
3434
load(

0 commit comments

Comments
 (0)