]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/dist: pass cgotest linkmode via GOFLAGS
authorJoel Sing <joel@sing.id.au>
Thu, 28 Mar 2019 14:26:45 +0000 (01:26 +1100)
committerIan Lance Taylor <iant@golang.org>
Thu, 28 Mar 2019 18:26:43 +0000 (18:26 +0000)
cgotest attempts to exercise various linkmodes, however with recent refactoring
TestCrossPackageTests is no longer running tests with these linkmodes. Specifying
the linkmode via GOFLAGS restores previous behaviour.

Note that the -ldflags="-linkmode=external -s" case cannot be passed through
as GOFLAGS does not permit spaces in values and -ldflags can only be specified
once.

Fixes #31083.

Change-Id: I2ce6c60da3f3d60495af283ea9122fb68a7a4f41
Reviewed-on: https://go-review.googlesource.com/c/go/+/169779
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/dist/test.go

index ec78890f8c200a9dc7903ac0b5e145405358ffe1..3f8f12c9e9f4a8811c0081be14285ee0929a16c1 100644 (file)
@@ -1002,10 +1002,12 @@ func (t *tester) runHostTest(dir, pkg string) error {
 }
 
 func (t *tester) cgoTest(dt *distTest) error {
-       t.addCmd(dt, "misc/cgo/test", t.goTest(), "-ldflags", "-linkmode=auto")
+       cmd := t.addCmd(dt, "misc/cgo/test", t.goTest())
+       cmd.Env = append(os.Environ(), "GOFLAGS=-ldflags=-linkmode=auto")
 
        if t.internalLink() {
-               t.addCmd(dt, "misc/cgo/test", t.goTest(), "-tags=internal", "-ldflags", "-linkmode=internal")
+               cmd := t.addCmd(dt, "misc/cgo/test", t.goTest(), "-tags=internal")
+               cmd.Env = append(os.Environ(), "GOFLAGS=-ldflags=-linkmode=internal")
        }
 
        pair := gohostos + "-" + goarch
@@ -1017,8 +1019,11 @@ func (t *tester) cgoTest(dt *distTest) error {
                if !t.extLink() {
                        break
                }
-               t.addCmd(dt, "misc/cgo/test", t.goTest(), "-ldflags", "-linkmode=external")
-               t.addCmd(dt, "misc/cgo/test", t.goTest(), "-ldflags", "-linkmode=external -s")
+               cmd := t.addCmd(dt, "misc/cgo/test", t.goTest())
+               cmd.Env = append(os.Environ(), "GOFLAGS=-ldflags=-linkmode=external")
+
+               cmd = t.addCmd(dt, "misc/cgo/test", t.goTest(), "-ldflags", "-linkmode=external -s")
+
        case "aix-ppc64",
                "android-arm",
                "dragonfly-amd64",
@@ -1026,9 +1031,10 @@ func (t *tester) cgoTest(dt *distTest) error {
                "linux-386", "linux-amd64", "linux-arm", "linux-ppc64le", "linux-s390x",
                "netbsd-386", "netbsd-amd64":
 
-               cmd := t.addCmd(dt, "misc/cgo/test", t.goTest(), "-ldflags", "-linkmode=external")
+               cmd := t.addCmd(dt, "misc/cgo/test", t.goTest())
+               cmd.Env = append(os.Environ(), "GOFLAGS=-ldflags=-linkmode=external")
                // A -g argument in CGO_CFLAGS should not affect how the test runs.
-               cmd.Env = append(os.Environ(), "CGO_CFLAGS=-g0")
+               cmd.Env = append(cmd.Env, "CGO_CFLAGS=-g0")
 
                t.addCmd(dt, "misc/cgo/testtls", t.goTest(), "-ldflags", "-linkmode=auto")
                t.addCmd(dt, "misc/cgo/testtls", t.goTest(), "-ldflags", "-linkmode=external")