cmd/distpack: remove some tools from packaged distribution

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>
This commit is contained in:
Michael Matloob 2025-02-06 16:11:50 -05:00 committed by Michael Matloob
parent 8097cf14d2
commit 8798f9e7a4
2 changed files with 3 additions and 3 deletions

View 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
}
}

View 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
}