]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: declare runtime/cgo dependency for darwin/arm, darwin/arm64 tests
authorRuss Cox <rsc@golang.org>
Fri, 29 Sep 2017 19:42:01 +0000 (15:42 -0400)
committerRuss Cox <rsc@golang.org>
Fri, 29 Sep 2017 20:11:01 +0000 (20:11 +0000)
I don't know why these tests must import runtime/cgo
in _testmain.go, but if they must, they must also tell the
rest of the go command that they are doing so.

Should fix the newly-broken darwin/arm and darwin/arm64 builders.

Change-Id: I9b183f8c84c6f403bf3a90cbfc838d6ef428e16f
Reviewed-on: https://go-review.googlesource.com/67230
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
src/cmd/go/internal/test/test.go

index f7b520ca962e98f045402c7a456a48912cdd3ed3..bcb659b13115c95576923bafe0c8eb0e37398640 100644 (file)
@@ -885,10 +885,16 @@ func builderTest(b *work.Builder, p *load.Package) (buildAction, runAction, prin
                },
        }
 
-       // The generated main also imports testing, regexp, and os.
+       // The generated main also imports testing, regexp, os, and maybe runtime/cgo.
        stk.Push("testmain")
+       forceCgo := false
+       if cfg.BuildContext.GOOS == "darwin" {
+               if cfg.BuildContext.GOARCH == "arm" || cfg.BuildContext.GOARCH == "arm64" {
+                       forceCgo = true
+               }
+       }
        deps := testMainDeps
-       if cfg.ExternalLinkingForced() {
+       if cfg.ExternalLinkingForced() || forceCgo {
                deps = str.StringList(deps, "runtime/cgo")
        }
        for _, dep := range deps {
@@ -950,11 +956,7 @@ func builderTest(b *work.Builder, p *load.Package) (buildAction, runAction, prin
                recompileForTest(pmain, p, ptest, testDir)
        }
 
-       if cfg.BuildContext.GOOS == "darwin" {
-               if cfg.BuildContext.GOARCH == "arm" || cfg.BuildContext.GOARCH == "arm64" {
-                       t.NeedCgo = true
-               }
-       }
+       t.NeedCgo = forceCgo
 
        for _, cp := range pmain.Internal.Imports {
                if len(cp.Internal.CoverVars) > 0 {