Skip to content

Commit

Permalink
Revert "Add automatic platform detection from inbound crosstool_top a…
Browse files Browse the repository at this point in the history
…nd cpu (#2859)" (#3468)

This reverts commit 026db6d.

Bazel is migrating to platforms and toolchains resolution, but this
logic frequently reset platforms back based on the value of the
legacy `--cpu` and `--crosstool_top` flags. Instead, users of rules that
still rely on these flags should use the `platform_mappings` file.
  • Loading branch information
fmeum committed Apr 19, 2023
1 parent 7377180 commit 4add3d9
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 88 deletions.
5 changes: 0 additions & 5 deletions go/platform/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,3 @@ bzl_library(
name = "apple",
srcs = ["apple.bzl"],
)

bzl_library(
name = "crosstool",
srcs = ["crosstool.bzl"],
)
60 changes: 0 additions & 60 deletions go/platform/crosstool.bzl

This file was deleted.

1 change: 0 additions & 1 deletion go/private/rules/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ bzl_library(
"//proto:__pkg__",
],
deps = [
"//go/platform:crosstool",
"//go/private:mode",
"//go/private:platforms",
"//go/private:providers",
Expand Down
22 changes: 0 additions & 22 deletions go/private/rules/transition.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,6 @@ load(
"GoLibrary",
"GoSource",
)
load(
"//go/platform:crosstool.bzl",
"platform_from_crosstool",
)

_DEFAULT_PLATFORMS_VALUE = [Label("@local_config_platform//:host")]
_PLATFORMS_LABEL = "//command_line_option:platforms"

# A list of rules_go settings that are possibly set by go_transition.
# Keep their package name in sync with the implementation of
Expand Down Expand Up @@ -101,8 +94,6 @@ def _go_transition_impl(settings, attr):

goos = getattr(attr, "goos", "auto")
goarch = getattr(attr, "goarch", "auto")
crosstool_top = settings.pop("//command_line_option:crosstool_top")
cpu = settings.pop("//command_line_option:cpu")
_check_ternary("pure", pure)
if goos != "auto" or goarch != "auto":
if goos == "auto":
Expand All @@ -115,17 +106,6 @@ def _go_transition_impl(settings, attr):
fail('pure is "off" but cgo is not supported on {} {}'.format(goos, goarch))
platform = "@io_bazel_rules_go//go/toolchain:{}_{}{}".format(goos, goarch, "_cgo" if cgo else "")
settings["//command_line_option:platforms"] = platform
else:
# If the current target platform differs from the default value (the
# host platform), then we don't want to override it with a value
# inferred from the legacy --cpu and --crosstool_top flags. Otherwise
# it would become impossible to "platformize" a Go build without having
# a matching platform mappings file.
if settings[_PLATFORMS_LABEL] == _DEFAULT_PLATFORMS_VALUE:
# Detect the platform the inbound crosstool/cpu.
platform = platform_from_crosstool(crosstool_top, cpu)
if platform:
settings[_PLATFORMS_LABEL] = platform

tags = getattr(attr, "gotags", [])
if tags:
Expand Down Expand Up @@ -181,8 +161,6 @@ request_nogo_transition = transition(
go_transition = transition(
implementation = _go_transition_impl,
inputs = [
"//command_line_option:cpu",
"//command_line_option:crosstool_top",
"//command_line_option:platforms",
] + TRANSITIONED_GO_SETTING_KEYS,
outputs = [
Expand Down

0 comments on commit 4add3d9

Please sign in to comment.