Skip to content

Commit 9ce601d

Browse files
committed
cmd/go: move gc concurrency level computation near gcflags
So after constructing "args" variable, "gcflags" is not used anywhere. It makes the code easier to maintain, and prevent subtle bug like #48490. Change-Id: I41653536480880a8a6f9fbf6cfa8a461b6fb3208 Reviewed-on: https://go-review.googlesource.com/c/go/+/351849 Reviewed-by: Bryan C. Mills <bcmills@google.com> Reviewed-by: Jay Conrod <jayconrod@google.com> Reviewed-by: Russ Cox <rsc@golang.org> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
1 parent aa878ee commit 9ce601d

File tree

1 file changed

+4
-5
lines changed
  • src/cmd/go/internal/work

1 file changed

+4
-5
lines changed

src/cmd/go/internal/work/gc.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ func (gcToolchain) gc(b *Builder, a *Action, archive string, importcfg, embedcfg
156156
}
157157
}
158158
}
159+
// Add -c=N to use concurrent backend compilation, if possible.
160+
if c := gcBackendConcurrency(gcflags); c > 1 {
161+
gcflags = append(gcflags, fmt.Sprintf("-c=%d", c))
162+
}
159163

160164
args := []interface{}{cfg.BuildToolexec, base.Tool("compile"), "-o", ofile, "-trimpath", a.trimpath(), defaultGcFlags, gcflags}
161165
if p.Internal.LocalPrefix != "" {
@@ -181,11 +185,6 @@ func (gcToolchain) gc(b *Builder, a *Action, archive string, importcfg, embedcfg
181185
args = append(args, "-asmhdr", objdir+"go_asm.h")
182186
}
183187

184-
// Add -c=N to use concurrent backend compilation, if possible.
185-
if c := gcBackendConcurrency(gcflags); c > 1 {
186-
args = append(args, fmt.Sprintf("-c=%d", c))
187-
}
188-
189188
for _, f := range gofiles {
190189
f := mkAbs(p.Dir, f)
191190

0 commit comments

Comments
 (0)