From: David Chase Date: Wed, 2 Nov 2022 21:21:09 +0000 (-0400) Subject: cmd/compile: tweak compiler concurrency X-Git-Tag: go1.20rc1~419 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=b725622ceb3d537334e1a3bb1723b1e939a40823;p=gostls13.git cmd/compile: tweak compiler concurrency 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 Reviewed-by: Keith Randall Run-TryBot: David Chase Reviewed-by: Keith Randall --- diff --git a/src/cmd/compile/internal/base/flag.go b/src/cmd/compile/internal/base/flag.go index 6d2847bc06..eb346e29fc 100644 --- a/src/cmd/compile/internal/base/flag.go +++ b/src/cmd/compile/internal/base/flag.go @@ -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 {