]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: tweak compiler concurrency
authorDavid Chase <drchase@google.com>
Wed, 2 Nov 2022 21:21:09 +0000 (17:21 -0400)
committerDavid Chase <drchase@google.com>
Fri, 4 Nov 2022 20:29:32 +0000 (20:29 +0000)
Default concurrency is now GOMAXPROCS, though this is normally
reduced to 4 by the go build commmand.

If compiler flags don't permit concurrency, silently
turn it down instead of failing the compilation.

Change-Id: Id26cc3214e0ca402d60f915e98276a58d809e097
Reviewed-on: https://go-review.googlesource.com/c/go/+/447358
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
src/cmd/compile/internal/base/flag.go

index 6d2847bc066e894497b5a44deb547d3ee91849f8..eb346e29fc2713b9150a2b9df153b6fd1eb23990 100644 (file)
@@ -147,7 +147,7 @@ type CmdFlags struct {
 func ParseFlags() {
        Flag.I = addImportDir
 
-       Flag.LowerC = 1
+       Flag.LowerC = runtime.GOMAXPROCS(0)
        Flag.LowerD = objabi.NewDebugFlag(&Debug, DebugSSA)
        Flag.LowerP = &Ctxt.Pkgpath
        Flag.LowerV = &Ctxt.Debugvlog
@@ -267,8 +267,8 @@ func ParseFlags() {
        if Flag.LowerC < 1 {
                log.Fatalf("-c must be at least 1, got %d", Flag.LowerC)
        }
-       if Flag.LowerC > 1 && !concurrentBackendAllowed() {
-               log.Fatalf("cannot use concurrent backend compilation with provided flags; invoked as %v", os.Args)
+       if !concurrentBackendAllowed() {
+               Flag.LowerC = 1
        }
 
        if Flag.CompilingRuntime {