From 21c4cb8b86eb5b7db9ee974a24db708047cb30f8 Mon Sep 17 00:00:00 2001 From: Nevena Kotlaja Date: Mon, 30 Oct 2023 14:42:36 +0100 Subject: [PATCH 1/5] Add toolchain param to affected actions --- go/private/actions/compilepkg.bzl | 1 + go/private/actions/link.bzl | 1 + go/private/actions/stdlib.bzl | 2 ++ 3 files changed, 4 insertions(+) diff --git a/go/private/actions/compilepkg.bzl b/go/private/actions/compilepkg.bzl index 4085f0cf2a..9c41bb88e8 100644 --- a/go/private/actions/compilepkg.bzl +++ b/go/private/actions/compilepkg.bzl @@ -162,4 +162,5 @@ def emit_compilepkg( executable = go.toolchain._builder, arguments = [args], env = go.env, + toolchain = "@io_bazel_rules_go//go:toolchain", ) diff --git a/go/private/actions/link.bzl b/go/private/actions/link.bzl index 3a1af2863f..0872b9d01d 100644 --- a/go/private/actions/link.bzl +++ b/go/private/actions/link.bzl @@ -209,6 +209,7 @@ def emit_link( executable = go.toolchain._builder, arguments = [builder_args, "--", tool_args], env = go.env, + toolchain = "@io_bazel_rules_go//go:toolchain", ) def _extract_extldflags(gc_linkopts, extldflags): diff --git a/go/private/actions/stdlib.bzl b/go/private/actions/stdlib.bzl index 3dc6fe74d8..9673c0292c 100644 --- a/go/private/actions/stdlib.bzl +++ b/go/private/actions/stdlib.bzl @@ -82,6 +82,7 @@ def _build_stdlib_list_json(go): executable = go.toolchain._builder, arguments = [args], env = _build_env(go), + toolchain = "@io_bazel_rules_go//go:toolchain", ) return out @@ -149,6 +150,7 @@ def _build_stdlib(go): executable = go.toolchain._builder, arguments = [args], env = _build_env(go), + toolchain = "@io_bazel_rules_go//go:toolchain", ) return GoStdLib( _list_json = _build_stdlib_list_json(go), From b37fdc5346890293f8eb20b4ee350f17895e62fc Mon Sep 17 00:00:00 2001 From: Nevena Kotlaja Date: Tue, 31 Oct 2023 15:25:57 +0100 Subject: [PATCH 2/5] Move GO_TOOLCHAIN to common.bzl --- extras/gomock.bzl | 2 +- go/private/actions/compilepkg.bzl | 3 ++- go/private/actions/link.bzl | 3 ++- go/private/actions/stdlib.bzl | 5 +++-- go/private/common.bzl | 2 ++ go/private/context.bzl | 2 +- go/private/go_toolchain.bzl | 3 +-- go/private/rules/binary.bzl | 3 --- go/private/rules/info.bzl | 2 +- go/private/rules/library.bzl | 5 +---- go/private/rules/nogo.bzl | 2 +- go/private/rules/source.bzl | 2 +- go/private/rules/stdlib.bzl | 2 +- go/private/rules/test.bzl | 3 --- 14 files changed, 17 insertions(+), 22 deletions(-) diff --git a/extras/gomock.bzl b/extras/gomock.bzl index 72fbaabc2f..3046c9f1d5 100644 --- a/extras/gomock.bzl +++ b/extras/gomock.bzl @@ -23,7 +23,7 @@ # DO NOT USE IT. load("//go/private:context.bzl", "go_context") -load("//go/private:go_toolchain.bzl", "GO_TOOLCHAIN") +load("//go/private:common.bzl", "GO_TOOLCHAIN") load("//go/private/rules:wrappers.bzl", go_binary = "go_binary_macro") load("//go/private:providers.bzl", "GoLibrary") load("@bazel_skylib//lib:paths.bzl", "paths") diff --git a/go/private/actions/compilepkg.bzl b/go/private/actions/compilepkg.bzl index 9c41bb88e8..03096a923f 100644 --- a/go/private/actions/compilepkg.bzl +++ b/go/private/actions/compilepkg.bzl @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +load("//go/private:common.bzl", "GO_TOOLCHAIN") load( "//go/private:mode.bzl", "link_mode_args", @@ -162,5 +163,5 @@ def emit_compilepkg( executable = go.toolchain._builder, arguments = [args], env = go.env, - toolchain = "@io_bazel_rules_go//go:toolchain", + toolchain = GO_TOOLCHAIN, ) diff --git a/go/private/actions/link.bzl b/go/private/actions/link.bzl index 0872b9d01d..e037836460 100644 --- a/go/private/actions/link.bzl +++ b/go/private/actions/link.bzl @@ -17,6 +17,7 @@ load( "as_set", "count_group_matches", "has_shared_lib_extension", + "GO_TOOLCHAIN", ) load( "//go/private:mode.bzl", @@ -209,7 +210,7 @@ def emit_link( executable = go.toolchain._builder, arguments = [builder_args, "--", tool_args], env = go.env, - toolchain = "@io_bazel_rules_go//go:toolchain", + toolchain = GO_TOOLCHAIN, ) def _extract_extldflags(gc_linkopts, extldflags): diff --git a/go/private/actions/stdlib.bzl b/go/private/actions/stdlib.bzl index 9673c0292c..c7b889c083 100644 --- a/go/private/actions/stdlib.bzl +++ b/go/private/actions/stdlib.bzl @@ -15,6 +15,7 @@ load( "//go/private:common.bzl", "COVERAGE_OPTIONS_DENYLIST", + "GO_TOOLCHAIN", ) load( "//go/private:providers.bzl", @@ -82,7 +83,7 @@ def _build_stdlib_list_json(go): executable = go.toolchain._builder, arguments = [args], env = _build_env(go), - toolchain = "@io_bazel_rules_go//go:toolchain", + toolchain = GO_TOOLCHAIN, ) return out @@ -150,7 +151,7 @@ def _build_stdlib(go): executable = go.toolchain._builder, arguments = [args], env = _build_env(go), - toolchain = "@io_bazel_rules_go//go:toolchain", + toolchain = GO_TOOLCHAIN, ) return GoStdLib( _list_json = _build_stdlib_list_json(go), diff --git a/go/private/common.bzl b/go/private/common.bzl index fb571eeeae..db24c4aa54 100644 --- a/go/private/common.bzl +++ b/go/private/common.bzl @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +GO_TOOLCHAIN = "@io_bazel_rules_go//go:toolchain" + go_exts = [ ".go", ] diff --git a/go/private/context.bzl b/go/private/context.bzl index b1699cf996..aadf3b3bb1 100644 --- a/go/private/context.bzl +++ b/go/private/context.bzl @@ -27,7 +27,7 @@ load( "OBJC_COMPILE_ACTION_NAME", ) load( - ":go_toolchain.bzl", + ":common.bzl", "GO_TOOLCHAIN", ) load( diff --git a/go/private/go_toolchain.bzl b/go/private/go_toolchain.bzl index 2dc3bf4feb..74c865c173 100644 --- a/go/private/go_toolchain.bzl +++ b/go/private/go_toolchain.bzl @@ -15,6 +15,7 @@ Toolchain rules used by go. """ +load("//go/private:common.bzl", "GO_TOOLCHAIN") load("//go/private:platforms.bzl", "PLATFORMS") load("//go/private:providers.bzl", "GoSDK") load("//go/private/actions:archive.bzl", "emit_archive") @@ -23,8 +24,6 @@ load("//go/private/actions:link.bzl", "emit_link") load("//go/private/actions:stdlib.bzl", "emit_stdlib") load("@bazel_skylib//lib:selects.bzl", "selects") -GO_TOOLCHAIN = "@io_bazel_rules_go//go:toolchain" - def _go_toolchain_impl(ctx): sdk = ctx.attr.sdk[GoSDK] cross_compile = ctx.attr.goos != sdk.goos or ctx.attr.goarch != sdk.goarch diff --git a/go/private/rules/binary.bzl b/go/private/rules/binary.bzl index 3d9646dd56..4582d463db 100644 --- a/go/private/rules/binary.bzl +++ b/go/private/rules/binary.bzl @@ -21,9 +21,6 @@ load( "asm_exts", "cgo_exts", "go_exts", -) -load( - "//go/private:go_toolchain.bzl", "GO_TOOLCHAIN", ) load( diff --git a/go/private/rules/info.bzl b/go/private/rules/info.bzl index 28cd1ba0ed..40ef98473d 100644 --- a/go/private/rules/info.bzl +++ b/go/private/rules/info.bzl @@ -17,7 +17,7 @@ load( "go_context", ) load( - "//go/private:go_toolchain.bzl", + "//go/private:common.bzl", "GO_TOOLCHAIN", ) diff --git a/go/private/rules/library.bzl b/go/private/rules/library.bzl index eeb7952442..c2e6830386 100644 --- a/go/private/rules/library.bzl +++ b/go/private/rules/library.bzl @@ -17,15 +17,12 @@ load( "asm_exts", "cgo_exts", "go_exts", + "GO_TOOLCHAIN", ) load( "//go/private:context.bzl", "go_context", ) -load( - "//go/private:go_toolchain.bzl", - "GO_TOOLCHAIN", -) load( "//go/private:providers.bzl", "GoLibrary", diff --git a/go/private/rules/nogo.bzl b/go/private/rules/nogo.bzl index 6fed164fbe..b411d7b189 100644 --- a/go/private/rules/nogo.bzl +++ b/go/private/rules/nogo.bzl @@ -17,7 +17,7 @@ load( "go_context", ) load( - "//go/private:go_toolchain.bzl", + "//go/private:common.bzl", "GO_TOOLCHAIN", ) load( diff --git a/go/private/rules/source.bzl b/go/private/rules/source.bzl index f92f5f83ae..e6d8ab41f5 100644 --- a/go/private/rules/source.bzl +++ b/go/private/rules/source.bzl @@ -17,7 +17,7 @@ load( "go_context", ) load( - "//go/private:go_toolchain.bzl", + "//go/private:common.bzl", "GO_TOOLCHAIN", ) load( diff --git a/go/private/rules/stdlib.bzl b/go/private/rules/stdlib.bzl index b1e64f6e88..60c856035b 100644 --- a/go/private/rules/stdlib.bzl +++ b/go/private/rules/stdlib.bzl @@ -17,7 +17,7 @@ load( "go_context", ) load( - "//go/private:go_toolchain.bzl", + "//go/private:common.bzl", "GO_TOOLCHAIN", ) load( diff --git a/go/private/rules/test.bzl b/go/private/rules/test.bzl index 84687fc54f..1e93ea8df5 100644 --- a/go/private/rules/test.bzl +++ b/go/private/rules/test.bzl @@ -23,9 +23,6 @@ load( "cgo_exts", "go_exts", "split_srcs", -) -load( - "//go/private:go_toolchain.bzl", "GO_TOOLCHAIN", ) load( From 7de32f785ce863ee8cd2d95dc3a620c09de70dc2 Mon Sep 17 00:00:00 2001 From: Nevena Kotlaja Date: Tue, 31 Oct 2023 15:34:27 +0100 Subject: [PATCH 3/5] Update new location of GO_TOOLCHAIN --- go/private/rules/go_bin_for_host.bzl | 2 +- proto/compiler.bzl | 2 +- proto/def.bzl | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go/private/rules/go_bin_for_host.bzl b/go/private/rules/go_bin_for_host.bzl index 3f2dca99ef..97a7afbdf7 100644 --- a/go/private/rules/go_bin_for_host.bzl +++ b/go/private/rules/go_bin_for_host.bzl @@ -13,7 +13,7 @@ # limitations under the License. load("@local_config_platform//:constraints.bzl", "HOST_CONSTRAINTS") -load("//go/private:go_toolchain.bzl", "GO_TOOLCHAIN") +load("//go/private:common.bzl", "GO_TOOLCHAIN") def _ensure_target_cfg(ctx): # A target is assumed to be built in the target configuration if it is neither in the exec nor diff --git a/proto/compiler.bzl b/proto/compiler.bzl index b0c00b6b59..1d66493989 100644 --- a/proto/compiler.bzl +++ b/proto/compiler.bzl @@ -22,7 +22,7 @@ load( "go_context", ) load( - "//go/private:go_toolchain.bzl", + "//go/private:common.bzl", "GO_TOOLCHAIN", ) load( diff --git a/proto/def.bzl b/proto/def.bzl index 073af3afe1..93ce850915 100644 --- a/proto/def.bzl +++ b/proto/def.bzl @@ -28,7 +28,7 @@ load( "proto_path", ) load( - "//go/private:go_toolchain.bzl", + "//go/private:common.bzl", "GO_TOOLCHAIN", ) load( From 4e8e77c0459f328a217dfbfbf8ac57d68db86910 Mon Sep 17 00:00:00 2001 From: Nevena Kotlaja Date: Tue, 31 Oct 2023 15:39:00 +0100 Subject: [PATCH 4/5] Fix error --- go/private/context.bzl | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/go/private/context.bzl b/go/private/context.bzl index aadf3b3bb1..c581d5b22f 100644 --- a/go/private/context.bzl +++ b/go/private/context.bzl @@ -26,10 +26,6 @@ load( "OBJCPP_COMPILE_ACTION_NAME", "OBJC_COMPILE_ACTION_NAME", ) -load( - ":common.bzl", - "GO_TOOLCHAIN", -) load( ":providers.bzl", "CgoContextInfo", @@ -54,6 +50,7 @@ load( "COVERAGE_OPTIONS_DENYLIST", "as_iterable", "goos_to_extension", + "GO_TOOLCHAIN", "goos_to_shared_extension", "is_struct", ) From de57873cf6a3cf3b4625698cabf18ecbdf63ce06 Mon Sep 17 00:00:00 2001 From: Nevena Kotlaja Date: Tue, 31 Oct 2023 15:59:08 +0100 Subject: [PATCH 5/5] Format files --- go/private/actions/link.bzl | 2 +- go/private/context.bzl | 2 +- go/private/rules/binary.bzl | 2 +- go/private/rules/library.bzl | 2 +- go/private/rules/test.bzl | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/go/private/actions/link.bzl b/go/private/actions/link.bzl index e037836460..bdd58553aa 100644 --- a/go/private/actions/link.bzl +++ b/go/private/actions/link.bzl @@ -14,10 +14,10 @@ load( "//go/private:common.bzl", + "GO_TOOLCHAIN", "as_set", "count_group_matches", "has_shared_lib_extension", - "GO_TOOLCHAIN", ) load( "//go/private:mode.bzl", diff --git a/go/private/context.bzl b/go/private/context.bzl index c581d5b22f..22a43bcaea 100644 --- a/go/private/context.bzl +++ b/go/private/context.bzl @@ -48,9 +48,9 @@ load( load( ":common.bzl", "COVERAGE_OPTIONS_DENYLIST", + "GO_TOOLCHAIN", "as_iterable", "goos_to_extension", - "GO_TOOLCHAIN", "goos_to_shared_extension", "is_struct", ) diff --git a/go/private/rules/binary.bzl b/go/private/rules/binary.bzl index 4582d463db..96db3ce130 100644 --- a/go/private/rules/binary.bzl +++ b/go/private/rules/binary.bzl @@ -18,10 +18,10 @@ load( ) load( "//go/private:common.bzl", + "GO_TOOLCHAIN", "asm_exts", "cgo_exts", "go_exts", - "GO_TOOLCHAIN", ) load( "//go/private:providers.bzl", diff --git a/go/private/rules/library.bzl b/go/private/rules/library.bzl index c2e6830386..88955fc14e 100644 --- a/go/private/rules/library.bzl +++ b/go/private/rules/library.bzl @@ -14,10 +14,10 @@ load( "//go/private:common.bzl", + "GO_TOOLCHAIN", "asm_exts", "cgo_exts", "go_exts", - "GO_TOOLCHAIN", ) load( "//go/private:context.bzl", diff --git a/go/private/rules/test.bzl b/go/private/rules/test.bzl index 1e93ea8df5..6cf3ac7167 100644 --- a/go/private/rules/test.bzl +++ b/go/private/rules/test.bzl @@ -18,12 +18,12 @@ load( ) load( "//go/private:common.bzl", + "GO_TOOLCHAIN", "as_list", "asm_exts", "cgo_exts", "go_exts", "split_srcs", - "GO_TOOLCHAIN", ) load( "//go/private/rules:binary.bzl",