]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: honor user-specified -c=N
authorXiangdong Ji <jixiangdong@bytedance.com>
Thu, 2 Feb 2023 06:20:16 +0000 (14:20 +0800)
committerGopher Robot <gobot@golang.org>
Tue, 7 Feb 2023 22:22:37 +0000 (22:22 +0000)
User-specified '-c=N' options should take precedence over the default one generated
by cmd/go.

Change-Id: I9021440b4a4286f8d6f92acb745a777cf234a82b
Reviewed-on: https://go-review.googlesource.com/c/go/+/465095
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/cmd/go/internal/work/gc.go
src/cmd/go/testdata/script/build_gcflags_order.txt

index ded751f4d4f03705707dc631c23e2a497bab5095..1193a5bbfdff83351f43b64885486cf18cd44fdb 100644 (file)
@@ -169,7 +169,7 @@ 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))
+               defaultGcFlags = append(defaultGcFlags, fmt.Sprintf("-c=%d", c))
        }
 
        args := []any{cfg.BuildToolexec, base.Tool("compile"), "-o", ofile, "-trimpath", a.trimpath(), defaultGcFlags, gcflags}
index 0ffe1570f6c6e40c062f318f6cf046a568d0f032..3725c89eb39231056fb52d1c0d177f529dd36567 100644 (file)
@@ -4,6 +4,8 @@
 cd m
 go build -n -gcflags=-lang=go1.17
 stderr ' -lang=go1.16.* -lang=go1.17'
+! go build -gcflags='-c 0'
+stderr 'compile: -c must be at least 1, got 0'
 
 -- m/go.mod --
 module example.com