Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add toolchain param to affected actions #3740

Merged
merged 5 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion extras/gomock.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 2 additions & 0 deletions go/private/actions/compilepkg.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -162,4 +163,5 @@ def emit_compilepkg(
executable = go.toolchain._builder,
arguments = [args],
env = go.env,
toolchain = GO_TOOLCHAIN,
)
2 changes: 2 additions & 0 deletions go/private/actions/link.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

load(
"//go/private:common.bzl",
"GO_TOOLCHAIN",
"as_set",
"count_group_matches",
"has_shared_lib_extension",
Expand Down Expand Up @@ -209,6 +210,7 @@ def emit_link(
executable = go.toolchain._builder,
arguments = [builder_args, "--", tool_args],
env = go.env,
toolchain = GO_TOOLCHAIN,
)

def _extract_extldflags(gc_linkopts, extldflags):
Expand Down
3 changes: 3 additions & 0 deletions go/private/actions/stdlib.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
load(
"//go/private:common.bzl",
"COVERAGE_OPTIONS_DENYLIST",
"GO_TOOLCHAIN",
)
load(
"//go/private:providers.bzl",
Expand Down Expand Up @@ -82,6 +83,7 @@ def _build_stdlib_list_json(go):
executable = go.toolchain._builder,
arguments = [args],
env = _build_env(go),
toolchain = GO_TOOLCHAIN,
)
return out

Expand Down Expand Up @@ -149,6 +151,7 @@ def _build_stdlib(go):
executable = go.toolchain._builder,
arguments = [args],
env = _build_env(go),
toolchain = GO_TOOLCHAIN,
)
return GoStdLib(
_list_json = _build_stdlib_list_json(go),
Expand Down
2 changes: 2 additions & 0 deletions go/private/common.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
Expand Down
5 changes: 1 addition & 4 deletions go/private/context.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ load(
"OBJCPP_COMPILE_ACTION_NAME",
"OBJC_COMPILE_ACTION_NAME",
)
load(
":go_toolchain.bzl",
"GO_TOOLCHAIN",
)
load(
":providers.bzl",
"CgoContextInfo",
Expand All @@ -52,6 +48,7 @@ load(
load(
":common.bzl",
"COVERAGE_OPTIONS_DENYLIST",
"GO_TOOLCHAIN",
"as_iterable",
"goos_to_extension",
"goos_to_shared_extension",
Expand Down
3 changes: 1 addition & 2 deletions go/private/go_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand Down
5 changes: 1 addition & 4 deletions go/private/rules/binary.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@ load(
)
load(
"//go/private:common.bzl",
"GO_TOOLCHAIN",
"asm_exts",
"cgo_exts",
"go_exts",
)
load(
"//go/private:go_toolchain.bzl",
"GO_TOOLCHAIN",
)
load(
"//go/private:providers.bzl",
"GoLibrary",
Expand Down
2 changes: 1 addition & 1 deletion go/private/rules/go_bin_for_host.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion go/private/rules/info.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ load(
"go_context",
)
load(
"//go/private:go_toolchain.bzl",
"//go/private:common.bzl",
"GO_TOOLCHAIN",
)

Expand Down
5 changes: 1 addition & 4 deletions go/private/rules/library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

load(
"//go/private:common.bzl",
"GO_TOOLCHAIN",
"asm_exts",
"cgo_exts",
"go_exts",
Expand All @@ -22,10 +23,6 @@ load(
"//go/private:context.bzl",
"go_context",
)
load(
"//go/private:go_toolchain.bzl",
"GO_TOOLCHAIN",
)
load(
"//go/private:providers.bzl",
"GoLibrary",
Expand Down
2 changes: 1 addition & 1 deletion go/private/rules/nogo.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ load(
"go_context",
)
load(
"//go/private:go_toolchain.bzl",
"//go/private:common.bzl",
"GO_TOOLCHAIN",
)
load(
Expand Down
2 changes: 1 addition & 1 deletion go/private/rules/source.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ load(
"go_context",
)
load(
"//go/private:go_toolchain.bzl",
"//go/private:common.bzl",
"GO_TOOLCHAIN",
)
load(
Expand Down
2 changes: 1 addition & 1 deletion go/private/rules/stdlib.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ load(
"go_context",
)
load(
"//go/private:go_toolchain.bzl",
"//go/private:common.bzl",
"GO_TOOLCHAIN",
)
load(
Expand Down
5 changes: 1 addition & 4 deletions go/private/rules/test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,13 @@ load(
)
load(
"//go/private:common.bzl",
"GO_TOOLCHAIN",
"as_list",
"asm_exts",
"cgo_exts",
"go_exts",
"split_srcs",
)
load(
"//go/private:go_toolchain.bzl",
"GO_TOOLCHAIN",
)
load(
"//go/private/rules:binary.bzl",
"gc_linkopts",
Expand Down
2 changes: 1 addition & 1 deletion proto/compiler.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ load(
"go_context",
)
load(
"//go/private:go_toolchain.bzl",
"//go/private:common.bzl",
"GO_TOOLCHAIN",
)
load(
Expand Down
2 changes: 1 addition & 1 deletion proto/def.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ load(
"proto_path",
)
load(
"//go/private:go_toolchain.bzl",
"//go/private:common.bzl",
"GO_TOOLCHAIN",
)
load(
Expand Down