]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/distpack: remove more tools from packaged distribution
authorMichael Matloob <matloob@golang.org>
Thu, 15 May 2025 19:30:57 +0000 (15:30 -0400)
committerMichael Matloob <matloob@google.com>
Fri, 16 May 2025 22:32:15 +0000 (15:32 -0700)
The "doc", "fix", and "covdata" tools invoked by the go command are not
needed for builds. Instead of invoking them directly using the installed
binary in the tool directory, use "go tool" to run them, building them
if needed. We can then stop distributing those tools in the
distribution.

covdata is used in tests and can form part of a cached test result, but
test results don't have the same requirements as build outputs to be
completely determined by the action id. We already don't include a
toolid for the covdata tool in the action id for a test run. The more
principled way to do things would be to load the covdata package,
create the actions to build it, and then depend on the output of
that action from the the test action and use that as the covdata tool.
For now, it's probably not worth the effort, but, in the future, if we
wanted to build a tool like cgo as needed, it would be best to build it
in the same action graph. That would introduce a whole bunch of complexity
because we'd need to build the tool in the host configuration, and all
the configuration parameters are global.

For #71867

Change-Id: Id9bbbb5c169296f66c072949f9da552424ecfa2f
Reviewed-on: https://go-review.googlesource.com/c/go/+/673119
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/doc/doc.go
src/cmd/go/internal/fix/fix.go
src/cmd/go/internal/work/cover.go

index 5b10198887fdafb1025da7a36b379beaaf9caefb..fd091c1ebb2037c7f9b2503f6ba4dae2d5609c19 100644 (file)
@@ -169,7 +169,8 @@ func main() {
                        }
                        // Inside pkg/tool/$GOOS_$GOARCH, discard helper tools, and tools not needed for builds.
                        switch strings.TrimSuffix(path.Base(name), ".exe") {
-                       case "addr2line", "api", "buildid", "dist", "distpack", "metadata", "nm", "objdump", "pprof", "test2json", "trace":
+                       case "addr2line", "api", "buildid", "covdata", "dist", "distpack", "doc", "fix",
+                               "metadata", "nm", "objdump", "pprof", "test2json", "trace":
                                return false
                        }
                }
index 3b6cd94799ada37541a9eb93a1228e0d87fb26ee..4156284d1d777d16fe7bd146aa7dc99981d8ff9d 100644 (file)
@@ -9,6 +9,7 @@ import (
        "cmd/go/internal/base"
        "cmd/go/internal/cfg"
        "context"
+       "path/filepath"
 )
 
 var CmdDoc = &base.Command{
@@ -130,5 +131,5 @@ Flags:
 }
 
 func runDoc(ctx context.Context, cmd *base.Command, args []string) {
-       base.Run(cfg.BuildToolexec, base.Tool("doc"), args)
+       base.Run(cfg.BuildToolexec, filepath.Join(cfg.GOROOTbin, "go"), "tool", "doc", args)
 }
index 28ad58daf5f44d9b1259cbcfb20c9ab6182e49b6..8947da05c3ee6373251407ce20ff52fd7364bd94 100644 (file)
@@ -16,6 +16,7 @@ import (
        "fmt"
        "go/build"
        "os"
+       "path/filepath"
 )
 
 var CmdFix = &base.Command{
@@ -80,6 +81,6 @@ func runFix(ctx context.Context, cmd *base.Command, args []string) {
                if *fixes != "" {
                        fixArg = []string{"-r=" + *fixes}
                }
-               base.Run(str.StringList(cfg.BuildToolexec, base.Tool("fix"), "-go="+goVersion, fixArg, files))
+               base.Run(str.StringList(cfg.BuildToolexec, filepath.Join(cfg.GOROOTbin, "go"), "tool", "fix", "-go="+goVersion, fixArg, files))
        }
 }
index 3b732569a8736cc7c7471c9153e8fde82e4994ed..62fcdb3fdad603a84a6695401872c0f126c94e0c 100644 (file)
@@ -7,7 +7,6 @@
 package work
 
 import (
-       "cmd/go/internal/base"
        "cmd/go/internal/cfg"
        "cmd/go/internal/str"
        "cmd/internal/cov/covcmd"
@@ -25,7 +24,7 @@ import (
 func (b *Builder) CovData(a *Action, cmdargs ...any) ([]byte, error) {
        cmdline := str.StringList(cmdargs...)
        args := append([]string{}, cfg.BuildToolexec...)
-       args = append(args, base.Tool("covdata"))
+       args = append(args, "go", "tool", "covdata")
        args = append(args, cmdline...)
        return b.Shell(a).runOut(a.Objdir, nil, args)
 }