]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: move gc concurrency level computation near gcflags
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Thu, 23 Sep 2021 16:40:58 +0000 (23:40 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Fri, 24 Sep 2021 04:32:28 +0000 (04:32 +0000)
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>

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

index 4e4a1d84514fa3810416900c6cfc8285a1ffc5c8..fe0a45ec2a42afe6c813b5d0dd586522b09a99f8 100644 (file)
@@ -156,6 +156,10 @@ func (gcToolchain) gc(b *Builder, a *Action, archive string, importcfg, embedcfg
                        }
                }
        }
+       // Add -c=N to use concurrent backend compilation, if possible.
+       if c := gcBackendConcurrency(gcflags); c > 1 {
+               gcflags = append(gcflags, fmt.Sprintf("-c=%d", c))
+       }
 
        args := []interface{}{cfg.BuildToolexec, base.Tool("compile"), "-o", ofile, "-trimpath", a.trimpath(), defaultGcFlags, gcflags}
        if p.Internal.LocalPrefix != "" {
@@ -181,11 +185,6 @@ func (gcToolchain) gc(b *Builder, a *Action, archive string, importcfg, embedcfg
                args = append(args, "-asmhdr", objdir+"go_asm.h")
        }
 
-       // Add -c=N to use concurrent backend compilation, if possible.
-       if c := gcBackendConcurrency(gcflags); c > 1 {
-               args = append(args, fmt.Sprintf("-c=%d", c))
-       }
-
        for _, f := range gofiles {
                f := mkAbs(p.Dir, f)