aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2017-09-14 11:11:30 -0400
committerRuss Cox <rsc@golang.org>2017-09-22 20:08:23 +0000
commit6e3cb838fce8a77e22d78bad19917e4267a44684 (patch)
treecaa3493d1d040535a17791b14ed6c339c6f9f88b
parent39d24b6b6d3e25b4e3a5ad6c7b79891fc3020319 (diff)
downloadgo-6e3cb838fce8a77e22d78bad19917e4267a44684.tar.gz
go-6e3cb838fce8a77e22d78bad19917e4267a44684.zip
[dev.boringcrypto.go1.8] cmd/go: exclude SysoFiles when using -msan
There's no way for a *.syso file to be compiled to work both in normal mode and in msan mode. Assume they are compiled in normal mode and drop them in msan mode. Packages with syso files currently fail in -msan mode because the syso file calls out to a routine like memcmp which then falsely reports uninitialized memory. After this CL, they will fail in -msan with link errors, because the syso will not be used. But then it will at least be possible for package authors to write fallback code in the package that avoids the syso in -msan mode, so that the package with the syso can at least run in both modes. Without this CL, that's not possible. See #21884. Change-Id: I77340614c4711325032484e65fa9c3f8332741d5 Reviewed-on: https://go-review.googlesource.com/63917 Reviewed-by: Adam Langley <agl@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-on: https://go-review.googlesource.com/65488 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
-rw-r--r--src/cmd/go/go_test.go8
-rw-r--r--src/cmd/go/pkg.go6
2 files changed, 12 insertions, 2 deletions
diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go
index fa78578d12..d48791e77f 100644
--- a/src/cmd/go/go_test.go
+++ b/src/cmd/go/go_test.go
@@ -3497,8 +3497,8 @@ func TestBinaryOnlyPackages(t *testing.T) {
tg.grepStdout("false", "did not see BinaryOnly=false for p4")
}
-// Issue 16050.
-func TestAlwaysLinkSysoFiles(t *testing.T) {
+// Issue 16050 and 21884.
+func TestLinkSysoFiles(t *testing.T) {
tg := testgo(t)
defer tg.cleanup()
tg.parallel()
@@ -3517,6 +3517,10 @@ func TestAlwaysLinkSysoFiles(t *testing.T) {
tg.setenv("CGO_ENABLED", "0")
tg.run("list", "-f", "{{.SysoFiles}}", "syso")
tg.grepStdout("a.syso", "missing syso file with CGO_ENABLED=0")
+
+ tg.setenv("CGO_ENABLED", "1")
+ tg.run("list", "-msan", "-f", "{{.SysoFiles}}", "syso")
+ tg.grepStdoutNot("a.syso", "unexpected syso file with -msan")
}
// Issue 16120.
diff --git a/src/cmd/go/pkg.go b/src/cmd/go/pkg.go
index 575f187f3b..99073a3868 100644
--- a/src/cmd/go/pkg.go
+++ b/src/cmd/go/pkg.go
@@ -173,6 +173,12 @@ func (p *Package) copyBuild(pp *build.Package) {
p.SwigFiles = pp.SwigFiles
p.SwigCXXFiles = pp.SwigCXXFiles
p.SysoFiles = pp.SysoFiles
+ if buildMSan {
+ // There's no way for .syso files to be built both with and without
+ // support for memory sanitizer. Assume they are built without,
+ // and drop them.
+ p.SysoFiles = nil
+ }
p.CgoCFLAGS = pp.CgoCFLAGS
p.CgoCPPFLAGS = pp.CgoCPPFLAGS
p.CgoCXXFLAGS = pp.CgoCXXFLAGS