Commit ea3a594cb2 for golang
commit ea3a594cb2d41790b6ac548c835aacf629d40eb9
Author: Michael Matloob <matloob@golang.org>
Date: Mon Nov 30 14:43:08 2026 -0500
cmd/dist: omit debug info in dist test -compile-only
We already omit debug info when the go command
builds the test binaries it will run (except
for go test -c). So dist test is doing
more building work for -compile-only when running
go test -c than a go test would. Skip producing them.
For #82617
Change-Id: Ifbc0e8ec6341ac2d43117d0b51466b426a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/867587
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Michael Matloob <matloob@google.com>
diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go
index fc748ecfe8..d6cb839a91 100644
--- a/src/cmd/dist/test.go
+++ b/src/cmd/dist/test.go
@@ -534,8 +534,17 @@ func (opts *goTest) buildArgs(t *tester) (build, run, pkgs, testFlags []string,
if opts.gcflags != "" {
build = append(build, "-gcflags=all="+opts.gcflags)
}
+ var ldflags []string
if opts.ldflags != "" {
- build = append(build, "-ldflags="+opts.ldflags)
+ ldflags = append(ldflags, opts.ldflags)
+ }
+ if t.compileOnly || opts.compileOnly() {
+ // Omit debug information in compileOnly mode. We don't need it and it
+ // slows down the builds.
+ ldflags = append(ldflags, "-s", "-w")
+ }
+ if len(ldflags) > 0 {
+ build = append(build, "-ldflags="+strings.Join(ldflags, " "))
}
if t.asmflags != "" {
build = append(build, "-asmflags="+t.asmflags)