]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/distpack: remove some tools from packaged distribution
authorMichael Matloob <matloob@golang.org>
Thu, 6 Feb 2025 21:11:50 +0000 (16:11 -0500)
committerMichael Matloob <matloob@google.com>
Fri, 16 May 2025 22:31:52 +0000 (15:31 -0700)
This change removes some tools that are not used for builds, or
otherwise invoked by the go command (other than through "go tool"
itself) from the packaged distributions produced by distpack. When these
tools are missing, "go tool" will build and run them as needed.

Also update a case where we print a buildid commandline to specify
invoking buildid using "go tool" rather than the binary at it's install
location, because it may not exist there in packaged distributions
anymore.

The tools in this CL are the lowest hanging fruit. There are a few more
tools that aren't used by builds, but we'd have to get the go command to
run them using "go tool" rather than finding them in the tool install
directory.

For #71867

Change-Id: I217683bd549962a1add87405bf3fb1225e2333c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/666755
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Matloob <matloob@google.com>
src/cmd/distpack/pack.go
src/cmd/go/internal/work/buildid.go

index a4f18da8bd4bc66bc59bad9efcd7992ecac917b6..5b10198887fdafb1025da7a36b379beaaf9caefb 100644 (file)
@@ -167,9 +167,9 @@ func main() {
                        if !strings.HasPrefix(name, "pkg/tool/"+goosUnderGoarch+"/") {
                                return false
                        }
-                       // Inside pkg/tool/$GOOS_$GOARCH, discard helper tools.
+                       // Inside pkg/tool/$GOOS_$GOARCH, discard helper tools, and tools not needed for builds.
                        switch strings.TrimSuffix(path.Base(name), ".exe") {
-                       case "api", "dist", "distpack", "metadata":
+                       case "addr2line", "api", "buildid", "dist", "distpack", "metadata", "nm", "objdump", "pprof", "test2json", "trace":
                                return false
                        }
                }
index 9bf3ab9acc3246ede3e2ad321d5fb225f95b834a..0bf9ba1781b0f746f2448d831a500623925fad0a 100644 (file)
@@ -642,7 +642,7 @@ func (b *Builder) updateBuildID(a *Action, target string) error {
        sh := b.Shell(a)
 
        if cfg.BuildX || cfg.BuildN {
-               sh.ShowCmd("", "%s # internal", joinUnambiguously(str.StringList(base.Tool("buildid"), "-w", target)))
+               sh.ShowCmd("", "%s # internal", joinUnambiguously(str.StringList("go", "tool", "buildid", "-w", target)))
                if cfg.BuildN {
                        return nil
                }