]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: enable -G=3 by default
authorMatthew Dempsky <mdempsky@google.com>
Thu, 19 Aug 2021 22:53:13 +0000 (15:53 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Sat, 21 Aug 2021 00:24:02 +0000 (00:24 +0000)
This CL changes cmd/compile's -G flag's default from 0 to 3, which
enables use of the new types2 type checker and support for type
parameters. The old type checker is still available with
-gcflags=all=-G=0.

The CL also updates the regress test harness to account for the change
in default behavior (e.g., to expect known types2 changes/failures).
However, the -G=0 mode is still being tested for now.

Copy of CL 340914 by danscales@, minus the cmd/internal/objabi.AbsFile
change (handled instead by CL 343731) and rebased to master branch.

Updates #43651.

Change-Id: I1f62d6c0a3ff245e15c5c0e8f3d922129fdd4f29
Reviewed-on: https://go-review.googlesource.com/c/go/+/343732
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/base/flag.go
test/run.go
test/typeparam/smoketest.go

index b8b205f4127032f14abb8d1f3df39e5044ebe775..942659bcc0f1c6f8c1d55d80fbd6456c773de25a 100644 (file)
@@ -140,6 +140,7 @@ type CmdFlags struct {
 
 // ParseFlags parses the command-line flags into Flag.
 func ParseFlags() {
+       Flag.G = 3
        Flag.I = addImportDir
 
        Flag.LowerC = 1
index f5971d2d151323414167c977701e5e0571f1929f..22e94b767cae7434406e1562a0a9f65555d8ec9a 100644 (file)
@@ -32,6 +32,10 @@ import (
        "unicode"
 )
 
+// CompilerDefaultGLevel is the -G level used by default when not overridden by a
+// command-line flag
+const CompilerDefaultGLevel = 3
+
 var (
        verbose        = flag.Bool("v", false, "verbose. if set, parallelism is set to 1.")
        keep           = flag.Bool("k", false, "keep. keep temporary directory.")
@@ -340,13 +344,18 @@ type test struct {
 }
 
 // initExpectFail initializes t.expectFail based on the build+test
-// configuration. It should only be called for tests known to use
-// types2.
-func (t *test) initExpectFail() {
+// configuration.
+func (t *test) initExpectFail(hasGFlag bool) {
        if *force {
                return
        }
 
+       if t.glevel == 0 && !hasGFlag && !unifiedEnabled {
+               // tests should always pass when run w/o types2 (i.e., using the
+               // legacy typechecker, option -G=0).
+               return
+       }
+
        failureSets := []map[string]bool{types2Failures}
 
        // Note: gccgo supports more 32-bit architectures than this, but
@@ -581,14 +590,14 @@ func init() { checkShouldTest() }
 // over and over.
 func (t *test) goGcflags() string {
        flags := os.Getenv("GO_GCFLAGS")
-       if t.glevel != 0 {
+       if t.glevel != CompilerDefaultGLevel {
                flags = fmt.Sprintf("%s -G=%v", flags, t.glevel)
        }
        return "-gcflags=all=" + flags
 }
 
 func (t *test) goGcflagsIsEmpty() bool {
-       return "" == os.Getenv("GO_GCFLAGS") && t.glevel == 0
+       return "" == os.Getenv("GO_GCFLAGS") && t.glevel == CompilerDefaultGLevel
 }
 
 var errTimeout = errors.New("command exceeded time limit")
@@ -750,7 +759,7 @@ func (t *test) run() {
                        }
                }
 
-               if hasGFlag && t.glevel != 0 {
+               if hasGFlag && t.glevel != CompilerDefaultGLevel {
                        // test provides explicit -G flag already; don't run again
                        if *verbose {
                                fmt.Printf("excl\t%s\n", t.goFileName())
@@ -758,13 +767,7 @@ func (t *test) run() {
                        return false
                }
 
-               if t.glevel == 0 && !hasGFlag && !unifiedEnabled {
-                       // tests should always pass when run w/o types2 (i.e., using the
-                       // legacy typechecker).
-                       return true
-               }
-
-               t.initExpectFail()
+               t.initExpectFail(hasGFlag)
 
                switch tool {
                case Build, Run:
index 5243dc5c3c15f7d806f2c9f80942d81ce05e8671..f32b40062d6bc8ca75ae25ef5dbe64054ff5ea35 100644 (file)
@@ -1,4 +1,4 @@
-// compile -G
+// compile -G=1
 
 // Copyright 2020 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style