]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/base: keep Ctxt.Flag_optimize in sync with Flag.N
authorThan McIntosh <thanm@google.com>
Mon, 11 Sep 2023 16:15:48 +0000 (12:15 -0400)
committerThan McIntosh <thanm@google.com>
Tue, 12 Sep 2023 17:01:03 +0000 (17:01 +0000)
This patch fixes an inconsistency in compiler flag handling introduced
accidentally in CL 521699. In the compiler we have both base.Flag.N
(which records whether the user has supplied the "-N" flag to disable
optimization) and base.Ctxt.Flag_optimize (which tracks whether
optimization is turned on). In this case Flag.N was updated without a
corresponding change to Ctxt.Flag_optimize, which led to problems with
DWARF generation for the runtime.

This CL doesn't include a regression test; a test will be added later
in the x/debug repo in a subsequent CL.

Updates #62523.

Change-Id: I0c383bb43ec0a0e7c12e7e2852c0590731416d6f
Reviewed-on: https://go-review.googlesource.com/c/go/+/527319
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Alessandro Arzilli <alessandro.arzilli@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/cmd/compile/internal/base/flag.go

index 8ffb41b16d446fc9a80eaa1ed7c7a463cec5b509..0e44deae71f51e22ae4d9206b2a522350d80712b 100644 (file)
@@ -334,6 +334,7 @@ func ParseFlags() {
                // It is not possible to build the runtime with no optimizations,
                // because the compiler cannot eliminate enough write barriers.
                Flag.N = 0
+               Ctxt.Flag_optimize = true
 
                // Runtime can't use -d=checkptr, at least not yet.
                Debug.Checkptr = 0