From c196d38d5e1d35c5b1eb1b19648532ea91442979 Mon Sep 17 00:00:00 2001 From: Joel Sing Date: Fri, 29 Mar 2019 01:26:45 +1100 Subject: [PATCH] cmd/dist: pass cgotest linkmode via GOFLAGS 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 TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- src/cmd/dist/test.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go index ec78890f8c..3f8f12c9e9 100644 --- a/src/cmd/dist/test.go +++ b/src/cmd/dist/test.go @@ -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") -- 2.50.0