From 3a614d6c70907045abb5205914e15223e7792565 Mon Sep 17 00:00:00 2001 From: Jay Conrod Date: Fri, 8 May 2020 12:56:23 -0400 Subject: [PATCH 1/2] Revert "nogo: stop using go_tool_library (#2474)" This reverts commit 8e6cfa5ef437aca79a987ad87e093c2065d71394. --- go/core.rst | 9 +- go/def.bzl | 68 +- go/nogo.rst | 40 +- go/private/rules/nogo.bzl | 14 +- go/tools/builders/BUILD.bazel | 11 +- tests/core/nogo/coverage/coverage_test.go | 4 +- tests/core/nogo/custom/custom_test.go | 16 +- tests/core/nogo/deps/deps_test.go | 18 +- tests/core/nogo/vet/vet_test.go | 2 +- third_party/org_golang_x_tools-extras.patch | 857 ++++++++++++++++---- 10 files changed, 807 insertions(+), 232 deletions(-) diff --git a/go/core.rst b/go/core.rst index 091b325970..26839775fa 100644 --- a/go/core.rst +++ b/go/core.rst @@ -24,7 +24,6 @@ Core Go rules .. _test_arg: https://docs.bazel.build/versions/master/user-manual.html#flag--test_arg .. _test_filter: https://docs.bazel.build/versions/master/user-manual.html#flag--test_filter .. _write a CROSSTOOL file: https://github.com/bazelbuild/bazel/wiki/Yet-Another-CROSSTOOL-Writing-Tutorial -.. _Deprecation schedule: https://github.com/bazelbuild/rules_go/wiki/Deprecation-schedule .. role:: param(kbd) .. role:: type(emphasis) @@ -386,11 +385,9 @@ the same package. This rule is a limited variant of ``go_library`` which may be used to bootstrap tools used by rules_go. This avoids a circular dependency. - -**DEPRECATED:** This rule should no longer be used. ``go_library`` should be -used instead. This was previously needed for ``nogo`` to avoid a circular -dependency, but it's no longer necessary. See `Deprecation schedule`_ for more -information. +If you are building analyzers to be linked into a `nogo`_ binary, you'll +need to use ``go_tool_library`` since ``go_library`` depends on `nogo`_ +implicitly. Providers ^^^^^^^^^ diff --git a/go/def.bzl b/go/def.bzl index c3401aecab..d1a4cdbaaf 100644 --- a/go/def.bzl +++ b/go/def.bzl @@ -80,41 +80,41 @@ load( # This is not backward compatible, so use caution when depending on this -- # new analyses may discover issues in existing builds. TOOLS_NOGO = [ - "@org_golang_x_tools//go/analysis/passes/asmdecl:go_default_library", - "@org_golang_x_tools//go/analysis/passes/assign:go_default_library", - "@org_golang_x_tools//go/analysis/passes/atomic:go_default_library", - "@org_golang_x_tools//go/analysis/passes/atomicalign:go_default_library", - "@org_golang_x_tools//go/analysis/passes/bools:go_default_library", - "@org_golang_x_tools//go/analysis/passes/buildssa:go_default_library", - "@org_golang_x_tools//go/analysis/passes/buildtag:go_default_library", + "@org_golang_x_tools//go/analysis/passes/asmdecl:go_tool_library", + "@org_golang_x_tools//go/analysis/passes/assign:go_tool_library", + "@org_golang_x_tools//go/analysis/passes/atomic:go_tool_library", + "@org_golang_x_tools//go/analysis/passes/atomicalign:go_tool_library", + "@org_golang_x_tools//go/analysis/passes/bools:go_tool_library", + "@org_golang_x_tools//go/analysis/passes/buildssa:go_tool_library", + "@org_golang_x_tools//go/analysis/passes/buildtag:go_tool_library", # TODO(#2396): pass raw cgo sources to cgocall and re-enable. - # "@org_golang_x_tools//go/analysis/passes/cgocall:go_default_library", - "@org_golang_x_tools//go/analysis/passes/composite:go_default_library", - "@org_golang_x_tools//go/analysis/passes/copylock:go_default_library", - "@org_golang_x_tools//go/analysis/passes/ctrlflow:go_default_library", - "@org_golang_x_tools//go/analysis/passes/deepequalerrors:go_default_library", - "@org_golang_x_tools//go/analysis/passes/errorsas:go_default_library", - "@org_golang_x_tools//go/analysis/passes/findcall:go_default_library", - "@org_golang_x_tools//go/analysis/passes/httpresponse:go_default_library", - "@org_golang_x_tools//go/analysis/passes/inspect:go_default_library", - "@org_golang_x_tools//go/analysis/passes/loopclosure:go_default_library", - "@org_golang_x_tools//go/analysis/passes/lostcancel:go_default_library", - "@org_golang_x_tools//go/analysis/passes/nilfunc:go_default_library", - "@org_golang_x_tools//go/analysis/passes/nilness:go_default_library", - "@org_golang_x_tools//go/analysis/passes/pkgfact:go_default_library", - "@org_golang_x_tools//go/analysis/passes/printf:go_default_library", - "@org_golang_x_tools//go/analysis/passes/shadow:go_default_library", - "@org_golang_x_tools//go/analysis/passes/shift:go_default_library", - "@org_golang_x_tools//go/analysis/passes/sortslice:go_default_library", - "@org_golang_x_tools//go/analysis/passes/stdmethods:go_default_library", - "@org_golang_x_tools//go/analysis/passes/stringintconv:go_default_library", - "@org_golang_x_tools//go/analysis/passes/structtag:go_default_library", - "@org_golang_x_tools//go/analysis/passes/testinggoroutine:go_default_library", - "@org_golang_x_tools//go/analysis/passes/tests:go_default_library", - "@org_golang_x_tools//go/analysis/passes/unmarshal:go_default_library", - "@org_golang_x_tools//go/analysis/passes/unreachable:go_default_library", - "@org_golang_x_tools//go/analysis/passes/unsafeptr:go_default_library", - "@org_golang_x_tools//go/analysis/passes/unusedresult:go_default_library", + # "@org_golang_x_tools//go/analysis/passes/cgocall:go_tool_library", + "@org_golang_x_tools//go/analysis/passes/composite:go_tool_library", + "@org_golang_x_tools//go/analysis/passes/copylock:go_tool_library", + "@org_golang_x_tools//go/analysis/passes/ctrlflow:go_tool_library", + "@org_golang_x_tools//go/analysis/passes/deepequalerrors:go_tool_library", + "@org_golang_x_tools//go/analysis/passes/errorsas:go_tool_library", + "@org_golang_x_tools//go/analysis/passes/findcall:go_tool_library", + "@org_golang_x_tools//go/analysis/passes/httpresponse:go_tool_library", + "@org_golang_x_tools//go/analysis/passes/inspect:go_tool_library", + "@org_golang_x_tools//go/analysis/passes/loopclosure:go_tool_library", + "@org_golang_x_tools//go/analysis/passes/lostcancel:go_tool_library", + "@org_golang_x_tools//go/analysis/passes/nilfunc:go_tool_library", + "@org_golang_x_tools//go/analysis/passes/nilness:go_tool_library", + "@org_golang_x_tools//go/analysis/passes/pkgfact:go_tool_library", + "@org_golang_x_tools//go/analysis/passes/printf:go_tool_library", + "@org_golang_x_tools//go/analysis/passes/shadow:go_tool_library", + "@org_golang_x_tools//go/analysis/passes/shift:go_tool_library", + "@org_golang_x_tools//go/analysis/passes/sortslice:go_tool_library", + "@org_golang_x_tools//go/analysis/passes/stdmethods:go_tool_library", + "@org_golang_x_tools//go/analysis/passes/stringintconv:go_tool_library", + "@org_golang_x_tools//go/analysis/passes/structtag:go_tool_library", + "@org_golang_x_tools//go/analysis/passes/testinggoroutine:go_tool_library", + "@org_golang_x_tools//go/analysis/passes/tests:go_tool_library", + "@org_golang_x_tools//go/analysis/passes/unmarshal:go_tool_library", + "@org_golang_x_tools//go/analysis/passes/unreachable:go_tool_library", + "@org_golang_x_tools//go/analysis/passes/unsafeptr:go_tool_library", + "@org_golang_x_tools//go/analysis/passes/unusedresult:go_tool_library", ] # Current version or next version to be tagged. Gazelle and other tools may diff --git a/go/nogo.rst b/go/nogo.rst index 09260f715e..c09bda2cd9 100644 --- a/go/nogo.rst +++ b/go/nogo.rst @@ -3,6 +3,7 @@ .. _nogo: nogo.rst#nogo .. _go_library: core.rst#go_library +.. _go_tool_library: core.rst#go_tool_library .. _analysis: https://godoc.org/golang.org/x/tools/go/analysis .. _Analyzer: https://godoc.org/golang.org/x/tools/go/analysis#Analyzer .. _GoLibrary: providers.rst#GoLibrary @@ -49,16 +50,16 @@ want to run. # analyzer from the local repository ":importunsafe", # analyzer from a remote repository - "@org_golang_x_tools//go/analysis/passes/printf:go_default_library", + "@org_golang_x_tools//go/analysis/passes/printf:go_tool_library", ], visibility = ["//visibility:public"], # must have public visibility ) - go_library( + go_tool_library( name = "importunsafe", srcs = ["importunsafe.go"], importpath = "importunsafe", - deps = ["@org_golang_x_tools//go/analysis:go_default_library"], + deps = ["@org_golang_x_tools//go/analysis:go_tool_library"], visibility = ["//visibility:public"], ) @@ -96,7 +97,7 @@ the ``TOOLS_NOGO`` list of dependencies. .. code:: bzl - load("@io_bazel_rules_go//go:def.bzl", "go_library", "nogo", "TOOLS_NOGO") + load("@io_bazel_rules_go//go:def.bzl", "nogo", "TOOLS_NOGO") nogo( name = "my_nogo", @@ -107,11 +108,11 @@ the ``TOOLS_NOGO`` list of dependencies. visibility = ["//visibility:public"], # must have public visibility ) - go_library( + go_tool_library( name = "importunsafe", srcs = ["importunsafe.go"], importpath = "importunsafe", - deps = ["@org_golang_x_tools//go/analysis:go_default_library"], + deps = ["@org_golang_x_tools//go/analysis:go_tool_library"], visibility = ["//visibility:public"], ) @@ -156,35 +157,40 @@ already been run. For example: Any diagnostics reported by the analyzer will stop the build. Do not emit diagnostics unless they are severe enough to warrant stopping the build. -Each analyzer must be written as a `go_library`_ rule and should import -`@org_golang_x_tools//go/analysis:go_default_library`, the package anaysis -framework. +Each analyzer must be written as a `go_tool_library`_ rule and must import +`@org_golang_x_tools//go/analysis:go_tool_library`, the `go_tool_library`_ +version of the package `analysis`_ target. For example: .. code:: bzl - load("@io_bazel_rules_go//go:def.bzl", "go_library") + load("@io_bazel_rules_go//go:def.bzl", "go_tool_library") - go_library( + go_tool_library( name = "importunsafe", srcs = ["importunsafe.go"], importpath = "importunsafe", - deps = ["@org_golang_x_tools//go/analysis:go_default_library"], + deps = ["@org_golang_x_tools//go/analysis:go_tool_library"], visibility = ["//visibility:public"], ) - go_library( + go_tool_library( name = "unsafedom", srcs = [ "check_dom.go", "dom_utils.go", ], importpath = "unsafedom", - deps = ["@org_golang_x_tools//go/analysis:go_default_library"], + deps = ["@org_golang_x_tools//go/analysis:go_tool_library"], visibility = ["//visibility:public"], ) +**NOTE**: `go_tool_library`_ is a limited variant of ``go_library`` which avoids +a circular dependency: `go_library`_ implicitly depends on `nogo`_, which +depends on analyzer libraries, which must not depend on `nogo`_. +`go_tool_library`_ does not have the same implicit dependency. + Pass labels for these targets to the ``deps`` attribute of your `nogo`_ target, as described in the `Setup`_ section. @@ -295,7 +301,7 @@ See the full list of available nogo checks: .. code:: shell - bazel query 'kind(go_library, @org_golang_x_tools//go/analysis/passes/...)' + bazel query 'kind(go_tool_library, @org_golang_x_tools//go/analysis/passes/...)' API @@ -324,6 +330,10 @@ Attributes | | | These libraries must declare an ``analysis.Analyzer`` variable named `Analyzer` to ensure that | | the analyzers they implement are called by nogo. | +| | +| To avoid bootstrapping problems, these libraries must be `go_tool_library`_ targets, and must | +| import `@org_golang_x_tools//go/analysis:go_tool_library`, the `go_tool_library`_ version of | +| the package `analysis`_ target. | +----------------------------+-----------------------------+---------------------------------------+ | :param:`config` | :type:`label` | :value:`None` | +----------------------------+-----------------------------+---------------------------------------+ diff --git a/go/private/rules/nogo.bzl b/go/private/rules/nogo.bzl index 34d9ddeaa0..245f2ec957 100644 --- a/go/private/rules/nogo.bzl +++ b/go/private/rules/nogo.bzl @@ -137,7 +137,9 @@ nogo = rule( "_nogo_srcs": attr.label( default = "@io_bazel_rules_go//go/tools/builders:nogo_srcs", ), - "_go_context_data": attr.label(default = "//:go_context_data"), + "_cgo_context_data": attr.label(default = "//:cgo_context_data_proxy"), + "_go_config": attr.label(default = "//:go_config"), + "_stdlib": attr.label(default = "//:stdlib"), "_whitelist_function_transition": attr.label( default = "@bazel_tools//tools/whitelists/function_transition_whitelist", ), @@ -149,11 +151,11 @@ nogo = rule( def nogo_wrapper(**kwargs): if kwargs.get("vet"): kwargs["deps"] = kwargs.get("deps", []) + [ - "@org_golang_x_tools//go/analysis/passes/atomic:go_default_library", - "@org_golang_x_tools//go/analysis/passes/bools:go_default_library", - "@org_golang_x_tools//go/analysis/passes/buildtag:go_default_library", - "@org_golang_x_tools//go/analysis/passes/nilfunc:go_default_library", - "@org_golang_x_tools//go/analysis/passes/printf:go_default_library", + "@org_golang_x_tools//go/analysis/passes/atomic:go_tool_library", + "@org_golang_x_tools//go/analysis/passes/bools:go_tool_library", + "@org_golang_x_tools//go/analysis/passes/buildtag:go_tool_library", + "@org_golang_x_tools//go/analysis/passes/nilfunc:go_tool_library", + "@org_golang_x_tools//go/analysis/passes/printf:go_tool_library", ] kwargs = {k: v for k, v in kwargs.items() if k != "vet"} nogo(**kwargs) diff --git a/go/tools/builders/BUILD.bazel b/go/tools/builders/BUILD.bazel index cca6bda90f..c93d4a1559 100644 --- a/go/tools/builders/BUILD.bazel +++ b/go/tools/builders/BUILD.bazel @@ -50,12 +50,17 @@ go_source( "flags.go", "nogo_main.go", ], + # //go/tools/builders:nogo_srcs is considered a different target by + # Bazel's visibility check than + # @io_bazel_rules_go//go/tools/builders:nogo_srcs. Only the latter is + # allowed to depend on + # @org_golang_x_tools//go/analysis/internal/facts:go_tool_library. tags = ["manual"], visibility = ["//visibility:public"], deps = [ - "@org_golang_x_tools//go/analysis:go_default_library", - "@org_golang_x_tools//go/analysis/internal/facts:go_default_library", - "@org_golang_x_tools//go/gcexportdata:go_default_library", + "@org_golang_x_tools//go/analysis:go_tool_library", + "@org_golang_x_tools//go/analysis/internal/facts:go_tool_library", + "@org_golang_x_tools//go/gcexportdata:go_tool_library", ], ) diff --git a/tests/core/nogo/coverage/coverage_test.go b/tests/core/nogo/coverage/coverage_test.go index b57d6c223c..9d728badd0 100644 --- a/tests/core/nogo/coverage/coverage_test.go +++ b/tests/core/nogo/coverage/coverage_test.go @@ -24,7 +24,7 @@ func TestMain(m *testing.M) { bazel_testing.TestMain(m, bazel_testing.Args{ Main: ` -- BUILD.bazel -- -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "nogo") +load("@io_bazel_rules_go//go:def.bzl", "go_test", "go_tool_library", "nogo") go_test( name = "coverage_target", @@ -32,7 +32,7 @@ go_test( deps = [":coverage_target_dep"], ) -go_library( +go_tool_library( name = "coverage_target_dep", importmap = "mapped/coverage_target/dep", importpath = "coverage_target/dep", diff --git a/tests/core/nogo/custom/custom_test.go b/tests/core/nogo/custom/custom_test.go index d3bbf0515b..0f724fd917 100644 --- a/tests/core/nogo/custom/custom_test.go +++ b/tests/core/nogo/custom/custom_test.go @@ -31,7 +31,7 @@ func TestMain(m *testing.M) { Nogo: "@//:nogo", Main: ` -- BUILD.bazel -- -load("@io_bazel_rules_go//go:def.bzl", "go_library", "nogo") +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_tool_library", "nogo") nogo( name = "nogo", @@ -44,29 +44,29 @@ nogo( visibility = ["//visibility:public"], ) -go_library( +go_tool_library( name = "importfmt", srcs = ["importfmt.go"], importpath = "importfmtanalyzer", - deps = ["@org_golang_x_tools//go/analysis:go_default_library"], + deps = ["@org_golang_x_tools//go/analysis:go_tool_library"], visibility = ["//visibility:public"], ) -go_library( +go_tool_library( name = "foofuncname", srcs = ["foofuncname.go"], importpath = "foofuncanalyzer", - deps = ["@org_golang_x_tools//go/analysis:go_default_library"], + deps = ["@org_golang_x_tools//go/analysis:go_tool_library"], visibility = ["//visibility:public"], ) -go_library( +go_tool_library( name = "visibility", srcs = ["visibility.go"], importpath = "visibilityanalyzer", deps = [ - "@org_golang_x_tools//go/analysis:go_default_library", - "@org_golang_x_tools//go/ast/inspector:go_default_library", + "@org_golang_x_tools//go/analysis:go_tool_library", + "@org_golang_x_tools//go/ast/inspector:go_tool_library", ], visibility = ["//visibility:public"], ) diff --git a/tests/core/nogo/deps/deps_test.go b/tests/core/nogo/deps/deps_test.go index 8e9eac9faa..91993fc251 100644 --- a/tests/core/nogo/deps/deps_test.go +++ b/tests/core/nogo/deps/deps_test.go @@ -27,7 +27,7 @@ func TestMain(m *testing.M) { Nogo: "@//:nogo", Main: ` -- BUILD.bazel -- -load("@io_bazel_rules_go//go:def.bzl", "go_library", "nogo") +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_tool_library", "nogo") nogo( name = "nogo", @@ -39,44 +39,44 @@ nogo( visibility = ["//visibility:public"], ) -go_library( +go_tool_library( name = "a", srcs = ["a.go"], importpath = "a", deps = [ ":c", - "@org_golang_x_tools//go/analysis:go_default_library" + "@org_golang_x_tools//go/analysis:go_tool_library" ], visibility = ["//visibility:public"], ) -go_library( +go_tool_library( name = "b", srcs = ["b.go"], importpath = "b", deps = [ ":c", - "@org_golang_x_tools//go/analysis:go_default_library" + "@org_golang_x_tools//go/analysis:go_tool_library" ], visibility = ["//visibility:public"], ) -go_library( +go_tool_library( name = "c", srcs = ["c.go"], importpath = "c", deps = [ ":d", - "@org_golang_x_tools//go/analysis:go_default_library" + "@org_golang_x_tools//go/analysis:go_tool_library" ], visibility = ["//visibility:public"], ) -go_library( +go_tool_library( name = "d", srcs = ["d.go"], importpath = "d", - deps = ["@org_golang_x_tools//go/analysis:go_default_library"], + deps = ["@org_golang_x_tools//go/analysis:go_tool_library"], visibility = ["//visibility:public"], ) diff --git a/tests/core/nogo/vet/vet_test.go b/tests/core/nogo/vet/vet_test.go index 2f922a1dba..37be7c69ed 100644 --- a/tests/core/nogo/vet/vet_test.go +++ b/tests/core/nogo/vet/vet_test.go @@ -28,7 +28,7 @@ func TestMain(m *testing.M) { bazel_testing.TestMain(m, bazel_testing.Args{ Main: ` -- BUILD.bazel -- -load("@io_bazel_rules_go//go:def.bzl", "go_library", "nogo") +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_tool_library", "nogo") nogo( name = "nogo", diff --git a/third_party/org_golang_x_tools-extras.patch b/third_party/org_golang_x_tools-extras.patch index 779f27c7e6..133fbccced 100644 --- a/third_party/org_golang_x_tools-extras.patch +++ b/third_party/org_golang_x_tools-extras.patch @@ -1,38 +1,56 @@ diff -urN c/go/analysis/BUILD.bazel d/go/analysis/BUILD.bazel --- c/go/analysis/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/analysis/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -11,3 +11,9 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -11,3 +11,15 @@ importpath = "golang.org/x/tools/go/analysis", visibility = ["//visibility:public"], ) + -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = [ ++ "analysis.go", ++ "diagnostic.go", ++ "doc.go", ++ "validate.go", ++ ], ++ importpath = "golang.org/x/tools/go/analysis", + visibility = ["//visibility:public"], +) diff -urN c/go/analysis/internal/facts/BUILD.bazel d/go/analysis/internal/facts/BUILD.bazel --- c/go/analysis/internal/facts/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/analysis/internal/facts/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -7,13 +7,22 @@ - "imports.go", +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -14,6 +14,23 @@ ], - importpath = "golang.org/x/tools/go/analysis/internal/facts", -- visibility = ["//go/analysis:__subpackages__"], + ) + ++go_tool_library( ++ name = "go_tool_library", ++ srcs = [ ++ "facts.go", ++ "imports.go", ++ ], ++ importpath = "golang.org/x/tools/go/analysis/internal/facts", + visibility = [ + "//go/analysis:__subpackages__", + "@io_bazel_rules_go//go/tools/builders:__pkg__", + ], - deps = [ - "//go/analysis:go_default_library", - "//go/types/objectpath:go_default_library", - ], - ) - -+alias( -+ name = "go_tool_library", -+ actual = ":go_default_library", -+ visibility = ["//visibility:public"], ++ deps = [ ++ "//go/analysis:go_tool_library", ++ "//go/types/objectpath:go_tool_library", ++ ], +) + go_test( @@ -41,14 +59,25 @@ diff -urN c/go/analysis/internal/facts/BUILD.bazel d/go/analysis/internal/facts/ diff -urN c/go/analysis/passes/asmdecl/BUILD.bazel d/go/analysis/passes/asmdecl/BUILD.bazel --- c/go/analysis/passes/asmdecl/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/analysis/passes/asmdecl/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -11,6 +11,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -11,6 +11,17 @@ ], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = ["asmdecl.go"], ++ importpath = "golang.org/x/tools/go/analysis/passes/asmdecl", + visibility = ["//visibility:public"], ++ deps = [ ++ "//go/analysis:go_tool_library", ++ "//go/analysis/passes/internal/analysisutil:go_tool_library", ++ ], +) + go_test( @@ -57,14 +86,27 @@ diff -urN c/go/analysis/passes/asmdecl/BUILD.bazel d/go/analysis/passes/asmdecl/ diff -urN c/go/analysis/passes/assign/BUILD.bazel d/go/analysis/passes/assign/BUILD.bazel --- c/go/analysis/passes/assign/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/analysis/passes/assign/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -13,6 +13,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -13,6 +13,19 @@ ], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = ["assign.go"], ++ importpath = "golang.org/x/tools/go/analysis/passes/assign", + visibility = ["//visibility:public"], ++ deps = [ ++ "//go/analysis:go_tool_library", ++ "//go/analysis/passes/inspect:go_tool_library", ++ "//go/analysis/passes/internal/analysisutil:go_tool_library", ++ "//go/ast/inspector:go_tool_library", ++ ], +) + go_test( @@ -73,14 +115,27 @@ diff -urN c/go/analysis/passes/assign/BUILD.bazel d/go/analysis/passes/assign/BU diff -urN c/go/analysis/passes/atomic/BUILD.bazel d/go/analysis/passes/atomic/BUILD.bazel --- c/go/analysis/passes/atomic/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/analysis/passes/atomic/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -13,6 +13,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -13,6 +13,19 @@ ], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = ["atomic.go"], ++ importpath = "golang.org/x/tools/go/analysis/passes/atomic", + visibility = ["//visibility:public"], ++ deps = [ ++ "//go/analysis:go_tool_library", ++ "//go/analysis/passes/inspect:go_tool_library", ++ "//go/analysis/passes/internal/analysisutil:go_tool_library", ++ "//go/ast/inspector:go_tool_library", ++ ], +) + go_test( @@ -89,14 +144,27 @@ diff -urN c/go/analysis/passes/atomic/BUILD.bazel d/go/analysis/passes/atomic/BU diff -urN c/go/analysis/passes/atomicalign/BUILD.bazel d/go/analysis/passes/atomicalign/BUILD.bazel --- c/go/analysis/passes/atomicalign/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/analysis/passes/atomicalign/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -13,6 +13,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -13,6 +13,19 @@ ], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = ["atomicalign.go"], ++ importpath = "golang.org/x/tools/go/analysis/passes/atomicalign", + visibility = ["//visibility:public"], ++ deps = [ ++ "//go/analysis:go_tool_library", ++ "//go/analysis/passes/inspect:go_tool_library", ++ "//go/analysis/passes/internal/analysisutil:go_tool_library", ++ "//go/ast/inspector:go_tool_library", ++ ], +) + go_test( @@ -130,14 +198,27 @@ diff -urN c/go/analysis/passes/atomicalign/BUILD.bazel.orig d/go/analysis/passes diff -urN c/go/analysis/passes/bools/BUILD.bazel d/go/analysis/passes/bools/BUILD.bazel --- c/go/analysis/passes/bools/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/analysis/passes/bools/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -13,6 +13,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -13,6 +13,19 @@ ], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = ["bools.go"], ++ importpath = "golang.org/x/tools/go/analysis/passes/bools", + visibility = ["//visibility:public"], ++ deps = [ ++ "//go/analysis:go_tool_library", ++ "//go/analysis/passes/inspect:go_tool_library", ++ "//go/analysis/passes/internal/analysisutil:go_tool_library", ++ "//go/ast/inspector:go_tool_library", ++ ], +) + go_test( @@ -146,14 +227,25 @@ diff -urN c/go/analysis/passes/bools/BUILD.bazel d/go/analysis/passes/bools/BUIL diff -urN c/go/analysis/passes/buildssa/BUILD.bazel d/go/analysis/passes/buildssa/BUILD.bazel --- c/go/analysis/passes/buildssa/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/analysis/passes/buildssa/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -11,6 +11,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -11,6 +11,17 @@ ], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = ["buildssa.go"], ++ importpath = "golang.org/x/tools/go/analysis/passes/buildssa", + visibility = ["//visibility:public"], ++ deps = [ ++ "//go/analysis:go_tool_library", ++ "//go/ssa:go_tool_library", ++ ], +) + go_test( @@ -162,14 +254,25 @@ diff -urN c/go/analysis/passes/buildssa/BUILD.bazel d/go/analysis/passes/buildss diff -urN c/go/analysis/passes/buildtag/BUILD.bazel d/go/analysis/passes/buildtag/BUILD.bazel --- c/go/analysis/passes/buildtag/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/analysis/passes/buildtag/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -11,6 +11,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -11,6 +11,17 @@ ], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = ["buildtag.go"], ++ importpath = "golang.org/x/tools/go/analysis/passes/buildtag", + visibility = ["//visibility:public"], ++ deps = [ ++ "//go/analysis:go_tool_library", ++ "//go/analysis/passes/internal/analysisutil:go_tool_library", ++ ], +) + go_test( @@ -178,14 +281,25 @@ diff -urN c/go/analysis/passes/buildtag/BUILD.bazel d/go/analysis/passes/buildta diff -urN c/go/analysis/passes/cgocall/BUILD.bazel d/go/analysis/passes/cgocall/BUILD.bazel --- c/go/analysis/passes/cgocall/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/analysis/passes/cgocall/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -11,6 +11,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -11,6 +11,17 @@ ], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = ["cgocall.go"], ++ importpath = "golang.org/x/tools/go/analysis/passes/cgocall", + visibility = ["//visibility:public"], ++ deps = [ ++ "//go/analysis:go_tool_library", ++ "//go/analysis/passes/internal/analysisutil:go_tool_library", ++ ], +) + go_test( @@ -194,14 +308,29 @@ diff -urN c/go/analysis/passes/cgocall/BUILD.bazel d/go/analysis/passes/cgocall/ diff -urN c/go/analysis/passes/composite/BUILD.bazel d/go/analysis/passes/composite/BUILD.bazel --- c/go/analysis/passes/composite/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/analysis/passes/composite/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -15,6 +15,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -15,6 +15,21 @@ ], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = [ ++ "composite.go", ++ "whitelist.go", ++ ], ++ importpath = "golang.org/x/tools/go/analysis/passes/composite", + visibility = ["//visibility:public"], ++ deps = [ ++ "//go/analysis:go_tool_library", ++ "//go/analysis/passes/inspect:go_tool_library", ++ "//go/ast/inspector:go_tool_library", ++ ], +) + go_test( @@ -210,14 +339,27 @@ diff -urN c/go/analysis/passes/composite/BUILD.bazel d/go/analysis/passes/compos diff -urN c/go/analysis/passes/copylock/BUILD.bazel d/go/analysis/passes/copylock/BUILD.bazel --- c/go/analysis/passes/copylock/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/analysis/passes/copylock/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -13,6 +13,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -13,6 +13,19 @@ ], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = ["copylock.go"], ++ importpath = "golang.org/x/tools/go/analysis/passes/copylock", + visibility = ["//visibility:public"], ++ deps = [ ++ "//go/analysis:go_tool_library", ++ "//go/analysis/passes/inspect:go_tool_library", ++ "//go/analysis/passes/internal/analysisutil:go_tool_library", ++ "//go/ast/inspector:go_tool_library", ++ ], +) + go_test( @@ -226,14 +368,28 @@ diff -urN c/go/analysis/passes/copylock/BUILD.bazel d/go/analysis/passes/copyloc diff -urN c/go/analysis/passes/ctrlflow/BUILD.bazel d/go/analysis/passes/ctrlflow/BUILD.bazel --- c/go/analysis/passes/ctrlflow/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/analysis/passes/ctrlflow/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -14,6 +14,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -14,6 +14,20 @@ ], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = ["ctrlflow.go"], ++ importpath = "golang.org/x/tools/go/analysis/passes/ctrlflow", + visibility = ["//visibility:public"], ++ deps = [ ++ "//go/analysis:go_tool_library", ++ "//go/analysis/passes/inspect:go_tool_library", ++ "//go/ast/inspector:go_tool_library", ++ "//go/cfg:go_tool_library", ++ "//go/types/typeutil:go_tool_library", ++ ], +) + go_test( @@ -242,14 +398,27 @@ diff -urN c/go/analysis/passes/ctrlflow/BUILD.bazel d/go/analysis/passes/ctrlflo diff -urN c/go/analysis/passes/deepequalerrors/BUILD.bazel d/go/analysis/passes/deepequalerrors/BUILD.bazel --- c/go/analysis/passes/deepequalerrors/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/analysis/passes/deepequalerrors/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -13,6 +13,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -13,6 +13,19 @@ ], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = ["deepequalerrors.go"], ++ importpath = "golang.org/x/tools/go/analysis/passes/deepequalerrors", + visibility = ["//visibility:public"], ++ deps = [ ++ "//go/analysis:go_tool_library", ++ "//go/analysis/passes/inspect:go_tool_library", ++ "//go/ast/inspector:go_tool_library", ++ "//go/types/typeutil:go_tool_library", ++ ], +) + go_test( @@ -258,14 +427,27 @@ diff -urN c/go/analysis/passes/deepequalerrors/BUILD.bazel d/go/analysis/passes/ diff -urN c/go/analysis/passes/errorsas/BUILD.bazel d/go/analysis/passes/errorsas/BUILD.bazel --- c/go/analysis/passes/errorsas/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/analysis/passes/errorsas/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -13,6 +13,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -13,6 +13,19 @@ ], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = ["errorsas.go"], ++ importpath = "golang.org/x/tools/go/analysis/passes/errorsas", + visibility = ["//visibility:public"], ++ deps = [ ++ "//go/analysis:go_tool_library", ++ "//go/analysis/passes/inspect:go_tool_library", ++ "//go/ast/inspector:go_tool_library", ++ "//go/types/typeutil:go_tool_library", ++ ], +) + go_test( @@ -274,14 +456,22 @@ diff -urN c/go/analysis/passes/errorsas/BUILD.bazel d/go/analysis/passes/errorsa diff -urN c/go/analysis/passes/findcall/BUILD.bazel d/go/analysis/passes/findcall/BUILD.bazel --- c/go/analysis/passes/findcall/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/analysis/passes/findcall/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -8,6 +8,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -8,6 +8,14 @@ deps = ["//go/analysis:go_default_library"], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = ["findcall.go"], ++ importpath = "golang.org/x/tools/go/analysis/passes/findcall", + visibility = ["//visibility:public"], ++ deps = ["//go/analysis:go_tool_library"], +) + go_test( @@ -290,14 +480,27 @@ diff -urN c/go/analysis/passes/findcall/BUILD.bazel d/go/analysis/passes/findcal diff -urN c/go/analysis/passes/httpresponse/BUILD.bazel d/go/analysis/passes/httpresponse/BUILD.bazel --- c/go/analysis/passes/httpresponse/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/analysis/passes/httpresponse/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -13,6 +13,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -13,6 +13,19 @@ ], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = ["httpresponse.go"], ++ importpath = "golang.org/x/tools/go/analysis/passes/httpresponse", + visibility = ["//visibility:public"], ++ deps = [ ++ "//go/analysis:go_tool_library", ++ "//go/analysis/passes/inspect:go_tool_library", ++ "//go/analysis/passes/internal/analysisutil:go_tool_library", ++ "//go/ast/inspector:go_tool_library", ++ ], +) + go_test( @@ -331,40 +534,70 @@ diff -urN c/go/analysis/passes/httpresponse/BUILD.bazel.orig d/go/analysis/passe diff -urN c/go/analysis/passes/inspect/BUILD.bazel d/go/analysis/passes/inspect/BUILD.bazel --- c/go/analysis/passes/inspect/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/analysis/passes/inspect/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -10,3 +10,9 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -10,3 +10,14 @@ "//go/ast/inspector:go_default_library", ], ) + -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = ["inspect.go"], ++ importpath = "golang.org/x/tools/go/analysis/passes/inspect", + visibility = ["//visibility:public"], ++ deps = [ ++ "//go/analysis:go_tool_library", ++ "//go/ast/inspector:go_tool_library", ++ ], +) diff -urN c/go/analysis/passes/internal/analysisutil/BUILD.bazel d/go/analysis/passes/internal/analysisutil/BUILD.bazel --- c/go/analysis/passes/internal/analysisutil/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/analysis/passes/internal/analysisutil/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -6,3 +6,9 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -6,3 +6,10 @@ importpath = "golang.org/x/tools/go/analysis/passes/internal/analysisutil", visibility = ["//go/analysis/passes:__subpackages__"], ) + -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", -+ visibility = ["//visibility:public"], ++ srcs = ["util.go"], ++ importpath = "golang.org/x/tools/go/analysis/passes/internal/analysisutil", ++ visibility = ["//go/analysis/passes:__subpackages__"], +) diff -urN c/go/analysis/passes/loopclosure/BUILD.bazel d/go/analysis/passes/loopclosure/BUILD.bazel --- c/go/analysis/passes/loopclosure/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/analysis/passes/loopclosure/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -12,6 +12,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -12,6 +12,18 @@ ], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = ["loopclosure.go"], ++ importpath = "golang.org/x/tools/go/analysis/passes/loopclosure", + visibility = ["//visibility:public"], ++ deps = [ ++ "//go/analysis:go_tool_library", ++ "//go/analysis/passes/inspect:go_tool_library", ++ "//go/ast/inspector:go_tool_library", ++ ], +) + go_test( @@ -373,14 +606,28 @@ diff -urN c/go/analysis/passes/loopclosure/BUILD.bazel d/go/analysis/passes/loop diff -urN c/go/analysis/passes/lostcancel/BUILD.bazel d/go/analysis/passes/lostcancel/BUILD.bazel --- c/go/analysis/passes/lostcancel/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/analysis/passes/lostcancel/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -14,6 +14,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -14,6 +14,20 @@ ], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = ["lostcancel.go"], ++ importpath = "golang.org/x/tools/go/analysis/passes/lostcancel", + visibility = ["//visibility:public"], ++ deps = [ ++ "//go/analysis:go_tool_library", ++ "//go/analysis/passes/ctrlflow:go_tool_library", ++ "//go/analysis/passes/inspect:go_tool_library", ++ "//go/ast/inspector:go_tool_library", ++ "//go/cfg:go_tool_library", ++ ], +) + go_test( @@ -389,14 +636,26 @@ diff -urN c/go/analysis/passes/lostcancel/BUILD.bazel d/go/analysis/passes/lostc diff -urN c/go/analysis/passes/nilfunc/BUILD.bazel d/go/analysis/passes/nilfunc/BUILD.bazel --- c/go/analysis/passes/nilfunc/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/analysis/passes/nilfunc/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -12,6 +12,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -12,6 +12,18 @@ ], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = ["nilfunc.go"], ++ importpath = "golang.org/x/tools/go/analysis/passes/nilfunc", + visibility = ["//visibility:public"], ++ deps = [ ++ "//go/analysis:go_tool_library", ++ "//go/analysis/passes/inspect:go_tool_library", ++ "//go/ast/inspector:go_tool_library", ++ ], +) + go_test( @@ -405,14 +664,26 @@ diff -urN c/go/analysis/passes/nilfunc/BUILD.bazel d/go/analysis/passes/nilfunc/ diff -urN c/go/analysis/passes/nilness/BUILD.bazel d/go/analysis/passes/nilness/BUILD.bazel --- c/go/analysis/passes/nilness/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/analysis/passes/nilness/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -12,6 +12,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -12,6 +12,18 @@ ], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = ["nilness.go"], ++ importpath = "golang.org/x/tools/go/analysis/passes/nilness", + visibility = ["//visibility:public"], ++ deps = [ ++ "//go/analysis:go_tool_library", ++ "//go/analysis/passes/buildssa:go_tool_library", ++ "//go/ssa:go_tool_library", ++ ], +) + go_test( @@ -421,14 +692,22 @@ diff -urN c/go/analysis/passes/nilness/BUILD.bazel d/go/analysis/passes/nilness/ diff -urN c/go/analysis/passes/pkgfact/BUILD.bazel d/go/analysis/passes/pkgfact/BUILD.bazel --- c/go/analysis/passes/pkgfact/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/analysis/passes/pkgfact/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -8,6 +8,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -8,6 +8,14 @@ deps = ["//go/analysis:go_default_library"], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = ["pkgfact.go"], ++ importpath = "golang.org/x/tools/go/analysis/passes/pkgfact", + visibility = ["//visibility:public"], ++ deps = ["//go/analysis:go_tool_library"], +) + go_test( @@ -437,14 +716,31 @@ diff -urN c/go/analysis/passes/pkgfact/BUILD.bazel d/go/analysis/passes/pkgfact/ diff -urN c/go/analysis/passes/printf/BUILD.bazel d/go/analysis/passes/printf/BUILD.bazel --- c/go/analysis/passes/printf/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/analysis/passes/printf/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -17,6 +17,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -17,6 +17,23 @@ ], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = [ ++ "printf.go", ++ "types.go", ++ ], ++ importpath = "golang.org/x/tools/go/analysis/passes/printf", + visibility = ["//visibility:public"], ++ deps = [ ++ "//go/analysis:go_tool_library", ++ "//go/analysis/passes/inspect:go_tool_library", ++ "//go/analysis/passes/internal/analysisutil:go_tool_library", ++ "//go/ast/inspector:go_tool_library", ++ "//go/types/typeutil:go_tool_library", ++ ], +) + go_test( @@ -453,14 +749,26 @@ diff -urN c/go/analysis/passes/printf/BUILD.bazel d/go/analysis/passes/printf/BU diff -urN c/go/analysis/passes/shadow/BUILD.bazel d/go/analysis/passes/shadow/BUILD.bazel --- c/go/analysis/passes/shadow/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/analysis/passes/shadow/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -12,6 +12,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -12,6 +12,18 @@ ], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = ["shadow.go"], ++ importpath = "golang.org/x/tools/go/analysis/passes/shadow", + visibility = ["//visibility:public"], ++ deps = [ ++ "//go/analysis:go_tool_library", ++ "//go/analysis/passes/inspect:go_tool_library", ++ "//go/ast/inspector:go_tool_library", ++ ], +) + go_test( @@ -469,14 +777,30 @@ diff -urN c/go/analysis/passes/shadow/BUILD.bazel d/go/analysis/passes/shadow/BU diff -urN c/go/analysis/passes/shift/BUILD.bazel d/go/analysis/passes/shift/BUILD.bazel --- c/go/analysis/passes/shift/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/analysis/passes/shift/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -16,6 +16,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -16,6 +16,22 @@ ], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = [ ++ "dead.go", ++ "shift.go", ++ ], ++ importpath = "golang.org/x/tools/go/analysis/passes/shift", + visibility = ["//visibility:public"], ++ deps = [ ++ "//go/analysis:go_tool_library", ++ "//go/analysis/passes/inspect:go_tool_library", ++ "//go/analysis/passes/internal/analysisutil:go_tool_library", ++ "//go/ast/inspector:go_tool_library", ++ ], +) + go_test( @@ -485,14 +809,27 @@ diff -urN c/go/analysis/passes/shift/BUILD.bazel d/go/analysis/passes/shift/BUIL diff -urN c/go/analysis/passes/sortslice/BUILD.bazel d/go/analysis/passes/sortslice/BUILD.bazel --- c/go/analysis/passes/sortslice/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/analysis/passes/sortslice/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -13,6 +13,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -13,6 +13,19 @@ ], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = ["analyzer.go"], ++ importpath = "golang.org/x/tools/go/analysis/passes/sortslice", + visibility = ["//visibility:public"], ++ deps = [ ++ "//go/analysis:go_tool_library", ++ "//go/analysis/passes/inspect:go_tool_library", ++ "//go/ast/inspector:go_tool_library", ++ "//go/types/typeutil:go_tool_library", ++ ], +) + go_test( @@ -501,14 +838,26 @@ diff -urN c/go/analysis/passes/sortslice/BUILD.bazel d/go/analysis/passes/sortsl diff -urN c/go/analysis/passes/stdmethods/BUILD.bazel d/go/analysis/passes/stdmethods/BUILD.bazel --- c/go/analysis/passes/stdmethods/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/analysis/passes/stdmethods/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -12,6 +12,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -12,6 +12,18 @@ ], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = ["stdmethods.go"], ++ importpath = "golang.org/x/tools/go/analysis/passes/stdmethods", + visibility = ["//visibility:public"], ++ deps = [ ++ "//go/analysis:go_tool_library", ++ "//go/analysis/passes/inspect:go_tool_library", ++ "//go/ast/inspector:go_tool_library", ++ ], +) + go_test( @@ -517,14 +866,26 @@ diff -urN c/go/analysis/passes/stdmethods/BUILD.bazel d/go/analysis/passes/stdme diff -urN c/go/analysis/passes/stringintconv/BUILD.bazel d/go/analysis/passes/stringintconv/BUILD.bazel --- c/go/analysis/passes/stringintconv/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/analysis/passes/stringintconv/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -12,6 +12,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -12,6 +12,18 @@ ], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = ["string.go"], ++ importpath = "golang.org/x/tools/go/analysis/passes/stringintconv", + visibility = ["//visibility:public"], ++ deps = [ ++ "//go/analysis:go_tool_library", ++ "//go/analysis/passes/inspect:go_tool_library", ++ "//go/ast/inspector:go_tool_library", ++ ], +) + go_test( @@ -533,14 +894,26 @@ diff -urN c/go/analysis/passes/stringintconv/BUILD.bazel d/go/analysis/passes/st diff -urN c/go/analysis/passes/structtag/BUILD.bazel d/go/analysis/passes/structtag/BUILD.bazel --- c/go/analysis/passes/structtag/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/analysis/passes/structtag/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -12,6 +12,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -12,6 +12,18 @@ ], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = ["structtag.go"], ++ importpath = "golang.org/x/tools/go/analysis/passes/structtag", + visibility = ["//visibility:public"], ++ deps = [ ++ "//go/analysis:go_tool_library", ++ "//go/analysis/passes/inspect:go_tool_library", ++ "//go/ast/inspector:go_tool_library", ++ ], +) + go_test( @@ -549,14 +922,27 @@ diff -urN c/go/analysis/passes/structtag/BUILD.bazel d/go/analysis/passes/struct diff -urN c/go/analysis/passes/testinggoroutine/BUILD.bazel d/go/analysis/passes/testinggoroutine/BUILD.bazel --- c/go/analysis/passes/testinggoroutine/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/analysis/passes/testinggoroutine/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -13,6 +13,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -13,6 +13,19 @@ ], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = ["testinggoroutine.go"], ++ importpath = "golang.org/x/tools/go/analysis/passes/testinggoroutine", + visibility = ["//visibility:public"], ++ deps = [ ++ "//go/analysis:go_tool_library", ++ "//go/analysis/passes/inspect:go_tool_library", ++ "//go/analysis/passes/internal/analysisutil:go_tool_library", ++ "//go/ast/inspector:go_tool_library", ++ ], +) + go_test( @@ -565,14 +951,22 @@ diff -urN c/go/analysis/passes/testinggoroutine/BUILD.bazel d/go/analysis/passes diff -urN c/go/analysis/passes/tests/BUILD.bazel d/go/analysis/passes/tests/BUILD.bazel --- c/go/analysis/passes/tests/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/analysis/passes/tests/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -8,6 +8,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -8,6 +8,14 @@ deps = ["//go/analysis:go_default_library"], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = ["tests.go"], ++ importpath = "golang.org/x/tools/go/analysis/passes/tests", + visibility = ["//visibility:public"], ++ deps = ["//go/analysis:go_tool_library"], +) + go_test( @@ -581,30 +975,59 @@ diff -urN c/go/analysis/passes/tests/BUILD.bazel d/go/analysis/passes/tests/BUIL diff -urN c/go/analysis/passes/unmarshal/BUILD.bazel d/go/analysis/passes/unmarshal/BUILD.bazel --- c/go/analysis/passes/unmarshal/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/analysis/passes/unmarshal/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -13,6 +13,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -13,9 +13,23 @@ ], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = ["unmarshal.go"], ++ importpath = "golang.org/x/tools/go/analysis/passes/unmarshal", + visibility = ["//visibility:public"], ++ deps = [ ++ "//go/analysis:go_tool_library", ++ "//go/analysis/passes/inspect:go_tool_library", ++ "//go/ast/inspector:go_tool_library", ++ "//go/types/typeutil:go_tool_library", ++ ], +) + go_test( name = "go_default_test", srcs = ["unmarshal_test.go"], + embed = [":go_default_library"], + deps = ["//go/analysis/analysistest:go_default_library"], + ) ++ diff -urN c/go/analysis/passes/unreachable/BUILD.bazel d/go/analysis/passes/unreachable/BUILD.bazel --- c/go/analysis/passes/unreachable/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/analysis/passes/unreachable/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -12,6 +12,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -12,6 +12,18 @@ ], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = ["unreachable.go"], ++ importpath = "golang.org/x/tools/go/analysis/passes/unreachable", + visibility = ["//visibility:public"], ++ deps = [ ++ "//go/analysis:go_tool_library", ++ "//go/analysis/passes/inspect:go_tool_library", ++ "//go/ast/inspector:go_tool_library", ++ ], +) + go_test( @@ -613,14 +1036,26 @@ diff -urN c/go/analysis/passes/unreachable/BUILD.bazel d/go/analysis/passes/unre diff -urN c/go/analysis/passes/unsafeptr/BUILD.bazel d/go/analysis/passes/unsafeptr/BUILD.bazel --- c/go/analysis/passes/unsafeptr/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/analysis/passes/unsafeptr/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -12,6 +12,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -12,6 +12,18 @@ ], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = ["unsafeptr.go"], ++ importpath = "golang.org/x/tools/go/analysis/passes/unsafeptr", + visibility = ["//visibility:public"], ++ deps = [ ++ "//go/analysis:go_tool_library", ++ "//go/analysis/passes/inspect:go_tool_library", ++ "//go/ast/inspector:go_tool_library", ++ ], +) + go_test( @@ -629,14 +1064,27 @@ diff -urN c/go/analysis/passes/unsafeptr/BUILD.bazel d/go/analysis/passes/unsafe diff -urN c/go/analysis/passes/unusedresult/BUILD.bazel d/go/analysis/passes/unusedresult/BUILD.bazel --- c/go/analysis/passes/unusedresult/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/analysis/passes/unusedresult/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -13,6 +13,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -13,6 +13,19 @@ ], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = ["unusedresult.go"], ++ importpath = "golang.org/x/tools/go/analysis/passes/unusedresult", + visibility = ["//visibility:public"], ++ deps = [ ++ "//go/analysis:go_tool_library", ++ "//go/analysis/passes/inspect:go_tool_library", ++ "//go/analysis/passes/internal/analysisutil:go_tool_library", ++ "//go/ast/inspector:go_tool_library", ++ ], +) + go_test( @@ -645,13 +1093,25 @@ diff -urN c/go/analysis/passes/unusedresult/BUILD.bazel d/go/analysis/passes/unu diff -urN c/go/ast/astutil/BUILD.bazel d/go/ast/astutil/BUILD.bazel --- c/go/ast/astutil/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/ast/astutil/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -12,6 +12,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -12,6 +12,18 @@ visibility = ["//visibility:public"], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = [ ++ "enclosing.go", ++ "imports.go", ++ "rewrite.go", ++ "util.go", ++ ], ++ importpath = "golang.org/x/tools/go/ast/astutil", + visibility = ["//visibility:public"], +) + @@ -661,13 +1121,23 @@ diff -urN c/go/ast/astutil/BUILD.bazel d/go/ast/astutil/BUILD.bazel diff -urN c/go/ast/inspector/BUILD.bazel d/go/ast/inspector/BUILD.bazel --- c/go/ast/inspector/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/ast/inspector/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -10,6 +10,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -10,6 +10,16 @@ visibility = ["//visibility:public"], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = [ ++ "inspector.go", ++ "typeof.go", ++ ], ++ importpath = "golang.org/x/tools/go/ast/inspector", + visibility = ["//visibility:public"], +) + @@ -677,13 +1147,23 @@ diff -urN c/go/ast/inspector/BUILD.bazel d/go/ast/inspector/BUILD.bazel diff -urN c/go/cfg/BUILD.bazel d/go/cfg/BUILD.bazel --- c/go/cfg/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/cfg/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -10,6 +10,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -10,6 +10,16 @@ visibility = ["//visibility:public"], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = [ ++ "builder.go", ++ "cfg.go", ++ ], ++ importpath = "golang.org/x/tools/go/cfg", + visibility = ["//visibility:public"], +) + @@ -693,14 +1173,25 @@ diff -urN c/go/cfg/BUILD.bazel d/go/cfg/BUILD.bazel diff -urN c/go/gcexportdata/BUILD.bazel d/go/gcexportdata/BUILD.bazel --- c/go/gcexportdata/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/gcexportdata/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -11,6 +11,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -11,6 +11,17 @@ deps = ["//go/internal/gcimporter:go_default_library"], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = [ ++ "gcexportdata.go", ++ "importer.go", ++ ], ++ importpath = "golang.org/x/tools/go/gcexportdata", + visibility = ["//visibility:public"], ++ deps = ["//go/internal/gcimporter:go_tool_library"], +) + go_test( @@ -709,14 +1200,30 @@ diff -urN c/go/gcexportdata/BUILD.bazel d/go/gcexportdata/BUILD.bazel diff -urN c/go/internal/gcimporter/BUILD.bazel d/go/internal/gcimporter/BUILD.bazel --- c/go/internal/gcimporter/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/internal/gcimporter/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -16,6 +16,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -16,6 +16,22 @@ visibility = ["//go:__subpackages__"], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", -+ visibility = ["//visibility:public"], ++ srcs = [ ++ "bexport.go", ++ "bimport.go", ++ "exportdata.go", ++ "gcimporter.go", ++ "iexport.go", ++ "iimport.go", ++ "newInterface10.go", ++ "newInterface11.go", ++ ], ++ importpath = "golang.org/x/tools/go/internal/gcimporter", ++ visibility = ["//go:__subpackages__"], +) + go_test( @@ -725,14 +1232,47 @@ diff -urN c/go/internal/gcimporter/BUILD.bazel d/go/internal/gcimporter/BUILD.ba diff -urN c/go/ssa/BUILD.bazel d/go/ssa/BUILD.bazel --- c/go/ssa/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/ssa/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -33,6 +33,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -33,6 +33,39 @@ ], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = [ ++ "blockopt.go", ++ "builder.go", ++ "const.go", ++ "create.go", ++ "doc.go", ++ "dom.go", ++ "emit.go", ++ "func.go", ++ "identical.go", ++ "identical_17.go", ++ "lift.go", ++ "lvalue.go", ++ "methods.go", ++ "mode.go", ++ "print.go", ++ "sanity.go", ++ "source.go", ++ "ssa.go", ++ "testmain.go", ++ "util.go", ++ "wrappers.go", ++ ], ++ importpath = "golang.org/x/tools/go/ssa", + visibility = ["//visibility:public"], ++ deps = [ ++ "//go/ast/astutil:go_tool_library", ++ "//go/types/typeutil:go_tool_library", ++ ], +) + go_test( @@ -741,13 +1281,20 @@ diff -urN c/go/ssa/BUILD.bazel d/go/ssa/BUILD.bazel diff -urN c/go/types/objectpath/BUILD.bazel d/go/types/objectpath/BUILD.bazel --- c/go/types/objectpath/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/types/objectpath/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -7,6 +7,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -7,6 +7,13 @@ visibility = ["//visibility:public"], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = ["objectpath.go"], ++ importpath = "golang.org/x/tools/go/types/objectpath", + visibility = ["//visibility:public"], +) + @@ -757,14 +1304,28 @@ diff -urN c/go/types/objectpath/BUILD.bazel d/go/types/objectpath/BUILD.bazel diff -urN c/go/types/typeutil/BUILD.bazel d/go/types/typeutil/BUILD.bazel --- c/go/types/typeutil/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 +++ d/go/types/typeutil/BUILD.bazel 2000-01-01 00:00:00.000000000 -0000 -@@ -14,6 +14,12 @@ +@@ -1,4 +1,4 @@ +-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") + + go_library( + name = "go_default_library", +@@ -14,6 +14,20 @@ deps = ["//go/ast/astutil:go_default_library"], ) -+alias( ++go_tool_library( + name = "go_tool_library", -+ actual = ":go_default_library", ++ srcs = [ ++ "callee.go", ++ "imports.go", ++ "map.go", ++ "methodsetcache.go", ++ "ui.go", ++ ], ++ importpath = "golang.org/x/tools/go/types/typeutil", + visibility = ["//visibility:public"], ++ deps = ["//go/ast/astutil:go_tool_library"], +) + go_test( From a4bd0ab1515e3c3407929cbc1abf439c82c62027 Mon Sep 17 00:00:00 2001 From: Jay Conrod Date: Fri, 8 May 2020 12:56:34 -0400 Subject: [PATCH 2/2] Revert "nogo: migrate to configuration transitions (#2473)" This reverts commit 8bdd81a38683860dd9b4b15dfcab04480c17c7e1. --- .bazelci/presubmit.yml | 2 - BUILD.bazel | 17 +--- go/config/BUILD.bazel | 6 -- go/nogo.rst | 32 +++---- go/private/BUILD.bazel | 20 ----- go/private/context.bzl | 8 +- go/private/nogo.bzl | 4 +- go/private/repositories.bzl | 3 +- go/private/rules/nogo.bzl | 57 ------------- go/private/rules/transition.bzl | 14 +-- tests/core/nogo/README.rst | 1 - tests/core/nogo/config/README.rst | 4 +- tests/core/nogo/config/config_test.go | 26 +++--- tests/core/nogo/flag/BUILD.bazel | 7 -- tests/core/nogo/flag/README.rst | 11 --- tests/core/nogo/flag/flag_test.go | 118 -------------------------- 16 files changed, 47 insertions(+), 283 deletions(-) delete mode 100644 tests/core/nogo/flag/BUILD.bazel delete mode 100644 tests/core/nogo/flag/README.rst delete mode 100644 tests/core/nogo/flag/flag_test.go diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 5757658ef0..a3a1eee504 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -316,9 +316,7 @@ platforms: - "-//tests/core/go_proto_library:transitive_test" - "-//tests/core/go_test:data_test" - "-//tests/core/go_test:pwd_test" - - "-//tests/core/nogo/config:config_test" - "-//tests/core/nogo/coverage:coverage_test" - - "-//tests/core/nogo/flag:flag_test" - "-//tests/core/nogo/vet:vet_test" - "-//tests/core/stdlib:buildid_test" - "-//tests/examples/executable_name:executable_name" diff --git a/BUILD.bazel b/BUILD.bazel index e28d9ed9b2..40841dfe79 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -4,7 +4,6 @@ load( ) load( "@io_bazel_rules_go//go/private:rules/nogo.bzl", - "default_nogo", "nogo", ) load( @@ -39,7 +38,7 @@ stdlib( # default_nogo is the nogo target that nogo references by default. It # does not analyze anything, which means no binary is built or run # at compile time. -default_nogo( +nogo( name = "default_nogo", visibility = ["//visibility:public"], ) @@ -54,18 +53,6 @@ nogo( deps = TOOLS_NOGO, ) -# nogo_alias points to the nogo flag which points to the active nogo binary -# when nogo is enabled. -# TODO(bazelbuild/bazel#11291): This exists to avoid a dependency cycle, but -# the cycle shouldn't exist when transitions are taken into account. -alias( - name = "nogo_alias", - actual = select({ - "//go/private:need_nogo": "//go/config:nogo", - "//conditions:default": "//:default_nogo", - }), -) - # go_context_data collects build options and is depended on by all Go targets. # It may depend on cgo_context_data if CGo isn't disabled. go_context_data( @@ -76,7 +63,7 @@ go_context_data( }), coverdata = "//go/tools/coverdata", go_config = ":go_config", - nogo = ":nogo_alias", + nogo = "@io_bazel_rules_nogo//:nogo", stdlib = ":stdlib", visibility = ["//visibility:public"], ) diff --git a/go/config/BUILD.bazel b/go/config/BUILD.bazel index a8d0941e32..b832742767 100644 --- a/go/config/BUILD.bazel +++ b/go/config/BUILD.bazel @@ -58,12 +58,6 @@ string_list_flag( visibility = ["//visibility:public"], ) -label_flag( - name = "nogo", - build_setting_default = "@io_bazel_rules_nogo//:nogo", - visibility = ["//visibility:public"], -) - filegroup( name = "all_files", testonly = True, diff --git a/go/nogo.rst b/go/nogo.rst index c09bda2cd9..e81eb01a6c 100644 --- a/go/nogo.rst +++ b/go/nogo.rst @@ -19,6 +19,10 @@ .. footer:: The ``nogo`` logo was derived from the Go gopher, which was designed by Renee French. (http://reneefrench.blogspot.com/) The design is licensed under the Creative Commons 3.0 Attributions license. Read this article for more details: http://blog.golang.org/gopher +**WARNING**: This functionality is experimental, so its API might change. +Please do not rely on it for production use, but feel free to use it and file +issues. + ``nogo`` is a tool that analyzes the source code of Go programs. It runs alongside the Go compiler in the Bazel Go rules and rejects programs that contain disallowed coding patterns. In addition, ``nogo`` may report @@ -63,19 +67,17 @@ want to run. visibility = ["//visibility:public"], ) -To build with this ``nogo`` target, use the -``--@io_bazel_rules_go//go/config:nogo`` command line flag. - -.. code:: - - bazel build --@io_bazel_rules_go//go/config:nogo=//:my_nogo //:my_binary +Pass a label for your `nogo`_ target to ``go_register_toolchains`` in your +``WORKSPACE`` file. -For convenience, you can add this to your workspace's ``.bazelrc`` file to -avoid having to type this out for every command. +.. code:: bzl -.. code:: + load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies", "go_register_toolchains") + go_rules_dependencies() + go_register_toolchains(nogo = "@//:my_nogo") # my_nogo is in the top-level BUILD file of this workspace - build --@io_bazel_rules_go//go/config:nogo=//:my_nogo +**NOTE**: You must include ``"@//"`` prefix when referring to targets in the local +workspace. The `nogo`_ rule will generate a program that executes all the supplied analyzers at build-time. The generated ``nogo`` program will run alongside the @@ -84,13 +86,13 @@ even if the target is imported from an external repository. However, ``nogo`` will not run when targets from the current repository are imported into other workspaces and built there. -The target ``@io_bazel_rules_go//:tools_nogo`` contains the analyzers from -``golang.org/x/tools``. This is the same set of analyzers that ``go vet`` uses. -You can use this instead of declaring your own ``nogo`` target. +To run all the ``golang.org/x/tools`` analyzers, use ``@io_bazel_rules_go//:tools_nogo``. -.. code:: +.. code:: bzl - build --@io_bazel_rules_go//go/config:nogo=@io_bazel_rules_go//:tools_nogo + load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies", "go_register_toolchains") + go_rules_dependencies() + go_register_toolchains(nogo = "@io_bazel_rules_go//:tools_nogo") To run the analyzers from ``tools_nogo`` together with your own analyzers, use the ``TOOLS_NOGO`` list of dependencies. diff --git a/go/private/BUILD.bazel b/go/private/BUILD.bazel index bbd2050e19..5e393eb388 100644 --- a/go/private/BUILD.bazel +++ b/go/private/BUILD.bazel @@ -1,5 +1,3 @@ -load("@bazel_skylib//rules:common_settings.bzl", "bool_setting") - filegroup( name = "all_rules", srcs = glob(["**/*.bzl"]), @@ -32,21 +30,3 @@ config_setting( name = "stamp", values = {"stamp": "true"}, ) - -# need_nogo_flag is set to false by nogo's incoming edge transition. It's used -# to control whether //:nogo_alias depends on //go/config:nogo to break -# a dependency cycle. -# TODO(bazelbuild/bazel#11291): the cycle shouldn't exist if transitions -# are taken into account, so this should be removed at some point. -bool_setting( - name = "need_nogo_flag", - build_setting_default = True, -) - -config_setting( - name = "need_nogo", - flag_values = { - ":need_nogo_flag": "True", - }, - visibility = ["//:__pkg__"], -) diff --git a/go/private/context.bzl b/go/private/context.bzl index e056345afd..1b56377a9f 100644 --- a/go/private/context.bzl +++ b/go/private/context.bzl @@ -493,12 +493,7 @@ def go_context(ctx, attr = None): def _go_context_data_impl(ctx): coverdata = ctx.attr.coverdata[GoArchive] - nogo = None - if ctx.attr.nogo and DefaultInfo in ctx.attr.nogo: - # TODO: may need multiple files and runfiles. - nogo_files = ctx.attr.nogo[DefaultInfo].files.to_list() - if nogo_files: - nogo = nogo_files[0] + nogo = ctx.files.nogo[0] if ctx.files.nogo else None providers = [ GoContextInfo( coverdata = ctx.attr.coverdata[GoArchive], @@ -524,6 +519,7 @@ go_context_data = rule( providers = [GoConfigInfo], ), "nogo": attr.label( + mandatory = True, cfg = "exec", ), "stdlib": attr.label( diff --git a/go/private/nogo.bzl b/go/private/nogo.bzl index a33972ae4d..189cddc9c3 100644 --- a/go/private/nogo.bzl +++ b/go/private/nogo.bzl @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +DEFAULT_NOGO = "@io_bazel_rules_go//:default_nogo" + def _go_register_nogo_impl(ctx): ctx.template( "BUILD.bazel", @@ -29,6 +31,6 @@ def _go_register_nogo_impl(ctx): go_register_nogo = repository_rule( _go_register_nogo_impl, attrs = { - "nogo": attr.string(default = "@io_bazel_rules_go//:default_nogo"), + "nogo": attr.string(mandatory = True), }, ) diff --git a/go/private/repositories.bzl b/go/private/repositories.bzl index 60ff0b0bfc..5a357e3b57 100644 --- a/go/private/repositories.bzl +++ b/go/private/repositories.bzl @@ -16,7 +16,7 @@ load("@io_bazel_rules_go//go/private:common.bzl", "MINIMUM_BAZEL_VERSION") load("@io_bazel_rules_go//go/private:skylib/lib/versions.bzl", "versions") -load("@io_bazel_rules_go//go/private:nogo.bzl", "go_register_nogo") +load("@io_bazel_rules_go//go/private:nogo.bzl", "DEFAULT_NOGO", "go_register_nogo") load("@io_bazel_rules_go//proto:gogo.bzl", "gogo_special_proto") load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") @@ -252,6 +252,7 @@ def go_rules_dependencies(is_rules_go = False): _maybe( go_register_nogo, name = "io_bazel_rules_nogo", + nogo = DEFAULT_NOGO, ) go_name_hack( diff --git a/go/private/rules/nogo.bzl b/go/private/rules/nogo.bzl index 245f2ec957..4beaf3b2f1 100644 --- a/go/private/rules/nogo.bzl +++ b/go/private/rules/nogo.bzl @@ -16,10 +16,6 @@ load( "@io_bazel_rules_go//go/private:context.bzl", "go_context", ) -load( - "@io_bazel_rules_go//go/private:mode.bzl", - "LINKMODE_NORMAL", -) load( "@io_bazel_rules_go//go/private:providers.bzl", "EXPORT_PATH", @@ -27,48 +23,6 @@ load( "GoLibrary", "get_archive", ) -load( - "@io_bazel_rules_go//go/private:rules/transition.bzl", - "filter_transition_label", -) - -_nogo_transition_dict = { - "@io_bazel_rules_go//go/config:static": False, - "@io_bazel_rules_go//go/config:msan": False, - "@io_bazel_rules_go//go/config:race": False, - "@io_bazel_rules_go//go/config:pure": False, - "@io_bazel_rules_go//go/config:strip": False, - "@io_bazel_rules_go//go/config:debug": False, - "@io_bazel_rules_go//go/config:linkmode": LINKMODE_NORMAL, - "@io_bazel_rules_go//go/config:tags": [], - "@io_bazel_rules_go//go/private:need_nogo_flag": False, -} - -_nogo_transition_keys = sorted([filter_transition_label(label) for label in _nogo_transition_dict.keys()]) - -def _nogo_transition_impl(settings, attr): - """Ensures nogo is built in a safe configuration without a dependency cycle. - - nogo_transition sets all of the //go/config settings to their default - values. The nogo binary shouldn't depend on the link mode or tags of the - binary being checked. This transition doesn't explicitly change the - platform (goos, goarch), but nogo dependencies should have `cfg = "exec"`, - so nogo binaries should be built for the execution platform. - """ - # TODO(bazelbuild/bazel#11291): When this bug is resolved, instead of - # setting //go/private:need_nogo_flag, we should set //go/config:nogo to - # //:default_nogo. - - settings = dict(settings) - for label, value in _nogo_transition_dict.items(): - settings[filter_transition_label(label)] = value - return settings - -nogo_transition = transition( - implementation = _nogo_transition_impl, - inputs = _nogo_transition_keys, - outputs = _nogo_transition_keys, -) def _nogo_impl(ctx): if not ctx.attr.deps: @@ -140,12 +94,8 @@ nogo = rule( "_cgo_context_data": attr.label(default = "//:cgo_context_data_proxy"), "_go_config": attr.label(default = "//:go_config"), "_stdlib": attr.label(default = "//:stdlib"), - "_whitelist_function_transition": attr.label( - default = "@bazel_tools//tools/whitelists/function_transition_whitelist", - ), }, toolchains = ["@io_bazel_rules_go//go:toolchain"], - cfg = nogo_transition, ) def nogo_wrapper(**kwargs): @@ -159,10 +109,3 @@ def nogo_wrapper(**kwargs): ] kwargs = {k: v for k, v in kwargs.items() if k != "vet"} nogo(**kwargs) - -def _default_nogo_impl(ctx): - pass - -default_nogo = rule( - implementation = _default_nogo_impl, -) diff --git a/go/private/rules/transition.bzl b/go/private/rules/transition.bzl index 06073b2179..07e2ff0a96 100644 --- a/go/private/rules/transition.bzl +++ b/go/private/rules/transition.bzl @@ -26,7 +26,7 @@ load( "IS_RULES_GO", ) -def filter_transition_label(label): +def _filter_transition_label(label): """Transforms transition labels for the current workspace. This is a workaround for bazelbuild/bazel#10499. If a transition refers to @@ -120,7 +120,7 @@ def _go_transition_impl(settings, attr): platform = "@io_bazel_rules_go//go/toolchain:{}_{}{}".format(goos, goarch, "_cgo" if cgo else "") settings["//command_line_option:platforms"] = platform if pure != "auto": - pure_label = filter_transition_label("@io_bazel_rules_go//go/config:pure") + pure_label = _filter_transition_label("@io_bazel_rules_go//go/config:pure") settings[pure_label] = pure == "on" _set_ternary(settings, attr, "static") @@ -129,21 +129,21 @@ def _go_transition_impl(settings, attr): tags = getattr(attr, "gotags", []) if tags: - tags_label = filter_transition_label("@io_bazel_rules_go//go/config:tags") + tags_label = _filter_transition_label("@io_bazel_rules_go//go/config:tags") settings[tags_label] = tags linkmode = getattr(attr, "linkmode", "auto") if linkmode != "auto": if linkmode not in LINKMODES: fail("linkmode: invalid mode {}; want one of {}".format(linkmode, ", ".join(LINKMODES))) - linkmode_label = filter_transition_label("@io_bazel_rules_go//go/config:linkmode") + linkmode_label = _filter_transition_label("@io_bazel_rules_go//go/config:linkmode") settings[linkmode_label] = linkmode return settings go_transition = transition( implementation = _go_transition_impl, - inputs = [filter_transition_label(label) for label in [ + inputs = [_filter_transition_label(label) for label in [ "//command_line_option:platforms", "@io_bazel_rules_go//go/config:static", "@io_bazel_rules_go//go/config:msan", @@ -152,7 +152,7 @@ go_transition = transition( "@io_bazel_rules_go//go/config:tags", "@io_bazel_rules_go//go/config:linkmode", ]], - outputs = [filter_transition_label(label) for label in [ + outputs = [_filter_transition_label(label) for label in [ "//command_line_option:platforms", "@io_bazel_rules_go//go/config:static", "@io_bazel_rules_go//go/config:msan", @@ -171,5 +171,5 @@ def _set_ternary(settings, attr, name): value = getattr(attr, name, "auto") _check_ternary(name, value) if value != "auto": - label = filter_transition_label("@io_bazel_rules_go//go/config:{}".format(name)) + label = _filter_transition_label("@io_bazel_rules_go//go/config:{}".format(name)) settings[label] = value == "on" diff --git a/tests/core/nogo/README.rst b/tests/core/nogo/README.rst index 1c756ea412..06b4e12aeb 100644 --- a/tests/core/nogo/README.rst +++ b/tests/core/nogo/README.rst @@ -9,7 +9,6 @@ Contents .. Child list start * `Vet check `_ -* `Nogo flags `_ * `Nogo configuration `_ * `nogo analyzers with dependencies `_ * `Custom nogo analyzers `_ diff --git a/tests/core/nogo/config/README.rst b/tests/core/nogo/config/README.rst index 6ef60e270d..9f2938b2fa 100644 --- a/tests/core/nogo/config/README.rst +++ b/tests/core/nogo/config/README.rst @@ -3,8 +3,6 @@ Nogo configuration .. _nogo: /go/nogo.rst .. _go_binary: /go/core.rst#_go_binary -.. _#1850: https://github.com/bazelbuild/rules_go/issues/1850 -.. _#2470: https://github.com/bazelbuild/rules_go/issues/2470 Tests that verify nogo_ works on targets compiled in non-default configurations. @@ -14,4 +12,4 @@ config_test ----------- Verifies that a `go_binary`_ can be built in non-default configurations with -nogo. Verifies `#1850`_, `#2470`_. +nogo. Verifies #1850. diff --git a/tests/core/nogo/config/config_test.go b/tests/core/nogo/config/config_test.go index 3758d43891..489e67509f 100644 --- a/tests/core/nogo/config/config_test.go +++ b/tests/core/nogo/config/config_test.go @@ -28,35 +28,35 @@ func TestMain(m *testing.M) { load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") go_binary( - name = "shared_bin", - srcs = ["shared_bin.go"], - linkmode = "c-shared", - deps = [":shared_lib"], + name = "pure_bin", + srcs = ["pure_bin.go"], + pure = "on", + deps = [":pure_lib"], ) go_library( - name = "shared_lib", - srcs = ["shared_lib.go"], - importpath = "example.com/nogo/config/shared_lib", + name = "pure_lib", + srcs = ["pure_lib.go"], + importpath = "example.com/nogo/config/pure_lib", ) --- shared_bin.go -- +-- pure_bin.go -- package main -import _ "example.com/nogo/config/shared_lib" +import _ "example.com/nogo/config/pure_lib" func main() { } --- shared_lib.go -- -package shared_lib +-- pure_lib.go -- +package pure_lib `, }) } -func TestShared(t *testing.T) { - if err := bazel_testing.RunBazel("build", "//:shared_bin"); err != nil { +func TestPureAspect(t *testing.T) { + if err := bazel_testing.RunBazel("build", "//:pure_bin"); err != nil { t.Fatal(err) } } diff --git a/tests/core/nogo/flag/BUILD.bazel b/tests/core/nogo/flag/BUILD.bazel deleted file mode 100644 index fdcfd9920f..0000000000 --- a/tests/core/nogo/flag/BUILD.bazel +++ /dev/null @@ -1,7 +0,0 @@ -load("//go/tools/bazel_testing:def.bzl", "go_bazel_test") - -go_bazel_test( - name = "flag_test", - size = "large", - srcs = ["flag_test.go"], -) diff --git a/tests/core/nogo/flag/README.rst b/tests/core/nogo/flag/README.rst deleted file mode 100644 index ffc512bd63..0000000000 --- a/tests/core/nogo/flag/README.rst +++ /dev/null @@ -1,11 +0,0 @@ -Nogo flags -========== - -Tests that verify the nogo Starlark flag interacts correctly with the setting -from ``go_register_nogo``. - -flag_test ---------- -Verifies that nogo may be set either in ``go_register_nogo`` (via -``go_register_toolchains`` or on the command line. The command line flag -takes precedence. diff --git a/tests/core/nogo/flag/flag_test.go b/tests/core/nogo/flag/flag_test.go deleted file mode 100644 index e6d52485ed..0000000000 --- a/tests/core/nogo/flag/flag_test.go +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright 2020 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package flag_test - -import ( - "bytes" - "errors" - "fmt" - "io/ioutil" - "os/exec" - "testing" - - "github.com/bazelbuild/rules_go/go/tools/bazel_testing" -) - -func TestMain(m *testing.M) { - bazel_testing.TestMain(m, bazel_testing.Args{ - Main: ` --- BUILD.bazel -- -load("@io_bazel_rules_go//go:def.bzl", "go_binary") - -go_binary( - name = "bad_printf", - srcs = ["bad_printf.go"], -) - --- bad_printf.go -- -package main - -import "fmt" - -func main() { - // printf analyzer should report an error here - fmt.Printf("hello, %s!\n") -} -`, - }) -} - -func Test(t *testing.T) { - workspaceData, err := ioutil.ReadFile("WORKSPACE") - if err != nil { - t.Fatal(err) - } - for _, test := range []struct { - desc string - workspaceNogo, flagNogo string - wantStderr string - }{ - { - desc: "none", - }, - { - desc: "workspace_only", - workspaceNogo: "@io_bazel_rules_go//:tools_nogo", - wantStderr: "bad_printf.go:7:2: Printf format", - }, - { - desc: "flag_only", - flagNogo: "@io_bazel_rules_go//:tools_nogo", - wantStderr: "bad_printf.go:7:2: Printf format", - }, - { - desc: "flag_overrides_workspace", - workspaceNogo: "@io_bazel_rules_go//:default_nogo", - flagNogo: "@io_bazel_rules_go//:tools_nogo", - wantStderr: "bad_printf.go:7:2: Printf format", - }, - } { - t.Run(test.desc, func(t *testing.T) { - var err error - if test.workspaceNogo == "" { - err = ioutil.WriteFile("WORKSPACE", workspaceData, 0666) - } else { - origLine := []byte("\ngo_register_toolchains()\n") - modifiedLine := []byte(fmt.Sprintf("\ngo_register_toolchains(nogo = \"%s\")\n", test.workspaceNogo)) - data := bytes.Replace(workspaceData, origLine, modifiedLine, 1) - err = ioutil.WriteFile("WORKSPACE", data, 0666) - } - if err != nil { - t.Fatal(err) - } - - args := []string{"build"} - if test.flagNogo != "" { - args = append(args, "--@io_bazel_rules_go//go/config:nogo="+test.flagNogo) - } - args = append(args, ":bad_printf") - err = bazel_testing.RunBazel(args...) - if test.wantStderr == "" && err != nil { - t.Fatalf("unexpected error running bazel: %v", err) - } else if test.wantStderr != "" { - if err == nil { - t.Fatal("unexpected success running bazel") - } - var xerr *exec.ExitError - if !errors.As(err, &xerr) { - t.Fatalf("unexpected error running bazel: %v", err) - } - if !bytes.Contains(xerr.Stderr, []byte(test.wantStderr)) { - t.Fatalf("got error:\n%s\nwant error containing %q", err) - } - } - }) - } -}