diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/bazel.mk | 7 | ||||
-rw-r--r-- | tools/bazel_gazelle_generate.patch | 15 | ||||
-rw-r--r-- | tools/bazel_gazelle_noise.patch (renamed from tools/bazel_gazelle.patch) | 0 | ||||
-rw-r--r-- | tools/checkescape/BUILD | 6 | ||||
-rw-r--r-- | tools/checkunsafe/BUILD | 2 | ||||
-rw-r--r-- | tools/github/BUILD | 2 | ||||
-rw-r--r-- | tools/github/nogo/BUILD | 2 | ||||
-rw-r--r-- | tools/github/reviver/BUILD | 2 | ||||
-rwxr-xr-x | tools/go_branch.sh | 22 | ||||
-rwxr-xr-x | tools/make_apt.sh | 6 | ||||
-rw-r--r-- | tools/nogo/BUILD | 56 | ||||
-rw-r--r-- | tools/nogo/defs.bzl | 8 | ||||
-rw-r--r-- | tools/rules_go_symbols.patch (renamed from tools/rules_go.patch) | 10 | ||||
-rw-r--r-- | tools/rules_go_visibility.patch | 22 |
14 files changed, 107 insertions, 53 deletions
diff --git a/tools/bazel.mk b/tools/bazel.mk index fb0fc6524..60b50cfb0 100644 --- a/tools/bazel.mk +++ b/tools/bazel.mk @@ -75,6 +75,7 @@ UID := $(shell id -u ${USER}) GID := $(shell id -g ${USER}) USERADD_OPTIONS := DOCKER_RUN_OPTIONS := +DOCKER_RUN_OPTIONS += --rm DOCKER_RUN_OPTIONS += --user $(UID):$(GID) DOCKER_RUN_OPTIONS += --entrypoint "" DOCKER_RUN_OPTIONS += --init @@ -160,15 +161,13 @@ bazel-image: load-default ## Ensures that the local builder exists. @docker commit $(BUILDER_NAME) gvisor.dev/images/builder >&2 .PHONY: bazel-image -# Note: when starting the bazel server, we tie the life of the container to the -# bazel server's life, so that the container disappears naturally. ifneq (true,$(shell $(wrapper echo true))) bazel-server: bazel-image ## Ensures that the server exists. @$(call header,DOCKER RUN) @docker rm -f $(DOCKER_NAME) 2>/dev/null || true - @mkdir -p $(GCLOUD_CONFIG) @mkdir -p $(BAZEL_CACHE) - @docker run -d --rm --name $(DOCKER_NAME) \ + @mkdir -p $(GCLOUD_CONFIG) + @docker run -d --name $(DOCKER_NAME) \ -v "$(CURDIR):$(CURDIR)" \ --workdir "$(CURDIR)" \ $(DOCKER_RUN_OPTIONS) \ diff --git a/tools/bazel_gazelle_generate.patch b/tools/bazel_gazelle_generate.patch new file mode 100644 index 000000000..fd1e1bda6 --- /dev/null +++ b/tools/bazel_gazelle_generate.patch @@ -0,0 +1,15 @@ +diff --git a/language/go/generate.go b/language/go/generate.go +index 2892948..feb4ad6 100644 +--- a/language/go/generate.go ++++ b/language/go/generate.go +@@ -691,6 +691,10 @@ func (g *generator) setImportAttrs(r *rule.Rule, importPath string) { + } + + func (g *generator) commonVisibility(importPath string) []string { ++ if importPath == "golang.org/x/tools/go/analysis/internal/facts" { ++ // Imported by nogo main. We add a visibility exception. ++ return []string{"//visibility:public"} ++ } + // If the Bazel package name (rel) contains "internal", add visibility for + // subpackages of the parent. + // If the import path contains "internal" but rel does not, this is diff --git a/tools/bazel_gazelle.patch b/tools/bazel_gazelle_noise.patch index e35f38933..e35f38933 100644 --- a/tools/bazel_gazelle.patch +++ b/tools/bazel_gazelle_noise.patch diff --git a/tools/checkescape/BUILD b/tools/checkescape/BUILD index 8956be621..940538b9e 100644 --- a/tools/checkescape/BUILD +++ b/tools/checkescape/BUILD @@ -8,8 +8,8 @@ go_library( nogo = False, visibility = ["//tools/nogo:__subpackages__"], deps = [ - "@org_golang_x_tools//go/analysis:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/buildssa:go_tool_library", - "@org_golang_x_tools//go/ssa:go_tool_library", + "@org_golang_x_tools//go/analysis:go_default_library", + "@org_golang_x_tools//go/analysis/passes/buildssa:go_default_library", + "@org_golang_x_tools//go/ssa:go_default_library", ], ) diff --git a/tools/checkunsafe/BUILD b/tools/checkunsafe/BUILD index 0c264151b..0bb07b415 100644 --- a/tools/checkunsafe/BUILD +++ b/tools/checkunsafe/BUILD @@ -8,6 +8,6 @@ go_library( nogo = False, visibility = ["//tools/nogo:__subpackages__"], deps = [ - "@org_golang_x_tools//go/analysis:go_tool_library", + "@org_golang_x_tools//go/analysis:go_default_library", ], ) diff --git a/tools/github/BUILD b/tools/github/BUILD index aad088d13..7d0a179f7 100644 --- a/tools/github/BUILD +++ b/tools/github/BUILD @@ -9,7 +9,7 @@ go_binary( deps = [ "//tools/github/nogo", "//tools/github/reviver", - "@com_github_google_go_github_v28//github:go_default_library", + "@com_github_google_go_github_v32//github:go_default_library", "@org_golang_x_oauth2//:go_default_library", ], ) diff --git a/tools/github/nogo/BUILD b/tools/github/nogo/BUILD index 19b7eec4d..4259fe94c 100644 --- a/tools/github/nogo/BUILD +++ b/tools/github/nogo/BUILD @@ -11,6 +11,6 @@ go_library( ], deps = [ "//tools/nogo", - "@com_github_google_go_github_v28//github:go_default_library", + "@com_github_google_go_github_v32//github:go_default_library", ], ) diff --git a/tools/github/reviver/BUILD b/tools/github/reviver/BUILD index 7d78480a7..fc54782f5 100644 --- a/tools/github/reviver/BUILD +++ b/tools/github/reviver/BUILD @@ -12,7 +12,7 @@ go_library( visibility = [ "//tools/github:__subpackages__", ], - deps = ["@com_github_google_go_github_v28//github:go_default_library"], + deps = ["@com_github_google_go_github_v32//github:go_default_library"], ) go_test( diff --git a/tools/go_branch.sh b/tools/go_branch.sh index 026733d3c..392e40619 100755 --- a/tools/go_branch.sh +++ b/tools/go_branch.sh @@ -16,14 +16,25 @@ set -xeou pipefail +# Remember our current directory. +declare orig_dir +orig_dir=$(pwd) +readonly orig_dir + +# Record the current working commit. +declare head +head=$(git describe --always) +readonly head + # Create a temporary working directory, and ensure that this directory and all # subdirectories are cleaned up upon exit. declare tmp_dir tmp_dir=$(mktemp -d) readonly tmp_dir finish() { - cd / # Leave tmp_dir. - rm -rf "${tmp_dir}" + cd "${orig_dir}" # Leave tmp_dir. + rm -rf "${tmp_dir}" # Remove all contents. + git checkout -f "${head}" # Restore commit. } trap finish EXIT @@ -37,7 +48,7 @@ readonly module origpwd othersrc # Build an amd64 & arm64 gopath. declare -r go_amd64="${tmp_dir}/amd64" declare -r go_arm64="${tmp_dir}/arm64" -make build BAZEL_OPTIONS="" TARGETS="//:gopath" 2>/dev/null +make build BAZEL_OPTIONS="" TARGETS="//:gopath" rsync --recursive --delete --copy-links bazel-bin/gopath/ "${go_amd64}" make build BAZEL_OPTIONS=--config=cross-aarch64 TARGETS="//:gopath" 2>/dev/null rsync --recursive --delete --copy-links bazel-bin/gopath/ "${go_arm64}" @@ -70,11 +81,6 @@ declare -r go_merged="${tmp_dir}/merged" rsync --recursive "${go_amd64}/" "${go_merged}" rsync --recursive "${go_arm64}/" "${go_merged}" -# Record the current working commit. -declare head -head=$(git describe --always) -readonly head - # We expect to have an existing go branch that we will use as the basis for this # commit. That branch may be empty, but it must exist. We search for this branch # using the local branch, the "origin" branch, and other remotes, in order. diff --git a/tools/make_apt.sh b/tools/make_apt.sh index 302ed8aa3..68f6973ec 100755 --- a/tools/make_apt.sh +++ b/tools/make_apt.sh @@ -119,7 +119,11 @@ for dir in "${root}"/pool/*/binary-*; do arches+=("${arch}") repo_packages="${release}"/main/"${name}" mkdir -p "${repo_packages}" - (cd "${root}" && apt-ftparchive --arch "${arch}" packages pool > "${repo_packages}"/Packages) + (cd "${root}" && apt-ftparchive packages "${dir##${root}/}" > "${repo_packages}"/Packages) + if ! [[ -s "${repo_packages}"/Packages ]]; then + echo "Packages file is size zero." >&2 + exit 1 + fi (cd "${repo_packages}" && cat Packages | gzip > Packages.gz) (cd "${repo_packages}" && cat Packages | xz > Packages.xz) done diff --git a/tools/nogo/BUILD b/tools/nogo/BUILD index 566e0889e..7976c7521 100644 --- a/tools/nogo/BUILD +++ b/tools/nogo/BUILD @@ -38,34 +38,34 @@ go_library( "//tools/checkunsafe", "@co_honnef_go_tools//staticcheck:go_default_library", "@co_honnef_go_tools//stylecheck: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/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/bools:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/buildtag:go_tool_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/errorsas:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/httpresponse: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/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/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/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", - "@org_golang_x_tools//go/gcexportdata:go_tool_library", + "@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/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/bools:go_default_library", + "@org_golang_x_tools//go/analysis/passes/buildtag:go_default_library", + "@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/errorsas:go_default_library", + "@org_golang_x_tools//go/analysis/passes/httpresponse: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/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/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/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/gcexportdata:go_default_library", ], ) diff --git a/tools/nogo/defs.bzl b/tools/nogo/defs.bzl index 161ea972e..0c48a7a5a 100644 --- a/tools/nogo/defs.bzl +++ b/tools/nogo/defs.bzl @@ -188,6 +188,14 @@ def _nogo_aspect_impl(target, ctx): # All work is done in the shadow properties for go rules. For a proto # library, we simply skip the analysis portion but still need to return a # valid NogoInfo to reference the generated binary. + # + # Note that we almost exclusively use go_library, not go_tool_library. + # This is because nogo is manually annotated, so the go_tool_library kind + # is not needed to avoid dependency loops. Unfortunately, bazel coverdata + # is exported *only* as a go_tool_library. This does not cause a problem, + # since there is guaranteed to be no conflict. However for consistency, + # we should not introduce new go_tool_library dependencies unless strictly + # necessary. if ctx.rule.kind in ("go_library", "go_tool_library", "go_binary", "go_test"): srcs = ctx.rule.files.srcs deps = ctx.rule.attr.deps diff --git a/tools/rules_go.patch b/tools/rules_go_symbols.patch index 5e1e87084..46767f169 100644 --- a/tools/rules_go.patch +++ b/tools/rules_go_symbols.patch @@ -2,13 +2,13 @@ diff --git a/go/private/rules/test.bzl b/go/private/rules/test.bzl index 17516ad7..76b6c68c 100644 --- a/go/private/rules/test.bzl +++ b/go/private/rules/test.bzl -@@ -121,9 +121,6 @@ def _go_test_impl(ctx): +@@ -117,9 +117,6 @@ def _go_test_impl(ctx): ) - + test_gc_linkopts = gc_linkopts(ctx) - if not go.mode.debug: - # Disable symbol table and DWARF generation for test binaries. - test_gc_linkopts.extend(["-s", "-w"]) - - # Now compile the test binary itself - test_library = GoLibrary( + + # Link in the run_dir global for bzltestutil + test_gc_linkopts.extend(["-X", "github.com/bazelbuild/rules_go/go/tools/bzltestutil.RunDir=" + run_dir]) diff --git a/tools/rules_go_visibility.patch b/tools/rules_go_visibility.patch new file mode 100644 index 000000000..e5bb2e3d5 --- /dev/null +++ b/tools/rules_go_visibility.patch @@ -0,0 +1,22 @@ +diff --git a/third_party/org_golang_x_tools-gazelle.patch b/third_party/org_golang_x_tools-gazelle.patch +index 7bdacff5..2fe9ce93 100644 +--- a/third_party/org_golang_x_tools-gazelle.patch ++++ b/third_party/org_golang_x_tools-gazelle.patch +@@ -2054,7 +2054,7 @@ diff -urN b/go/analysis/internal/facts/BUILD.bazel c/go/analysis/internal/facts/ + + "imports.go", + + ], + + importpath = "golang.org/x/tools/go/analysis/internal/facts", +-+ visibility = ["//go/analysis:__subpackages__"], +++ visibility = ["//visibility:public"], + + deps = [ + + "//go/analysis", + + "//go/types/objectpath", +@@ -2078,7 +2078,7 @@ diff -urN b/go/analysis/internal/facts/BUILD.bazel c/go/analysis/internal/facts/ + +alias( + + name = "go_default_library", + + actual = ":facts", +-+ visibility = ["//go/analysis:__subpackages__"], +++ visibility = ["//visibility:public"], + +) + + + +go_test( |