Commit ae2c2b417c for golang
commit ae2c2b417c63c0a0071591e39355def111cb23dd
Author: Michael Matloob <matloob@golang.org>
Date: Thu Dec 3 14:21:06 2026 -0500
cmd/go/internal/work: clean up object files once packed
Once object files have been packed into the export archive,
we should delete them to reduce the amount of disk that we're
using at a time (which can grow significantly for long-running
tests).
For #15734
Change-Id: Ice920804aceeab36e1f8f83b1ba7fa656a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/869022
Reviewed-by: t hepudds <thepudds1460@gmail.com>
Reviewed-by: PJ Malloy <pjmalloy@google.com>
Reviewed-by: Michael Matloob <matloob@google.com>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go
index 98932ed888..4984824adc 100644
--- a/src/cmd/go/internal/work/exec.go
+++ b/src/cmd/go/internal/work/exec.go
@@ -1024,6 +1024,13 @@ func (b *Builder) buildObject(ctx context.Context, a *Action) error {
if err := BuildToolchain.pack(b, a, objpkg, objects); err != nil {
return err
}
+ if !cfg.BuildWork && !cfg.BuildN {
+ // We don't need the objects anymore now that they have been packed
+ // into the archive. Remove them to reduce filesystem pressure.
+ for _, f := range ep.objects {
+ os.Remove(f)
+ }
+ }
}
if err := b.updateBuildID(a, objpkg); err != nil {