Skip to content

Commit

Permalink
[dev.boringcrypto] cmd/go: exclude SysoFiles when using -msan
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
rsc committed Sep 18, 2017
1 parent 9f025cb commit 32dc9b2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/cmd/go/go_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3614,8 +3614,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()
Expand All @@ -3634,6 +3634,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.
Expand Down
6 changes: 6 additions & 0 deletions src/cmd/go/internal/load/pkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@ func (p *Package) copyBuild(pp *build.Package) {
p.SwigFiles = pp.SwigFiles
p.SwigCXXFiles = pp.SwigCXXFiles
p.SysoFiles = pp.SysoFiles
if cfg.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
Expand Down

0 comments on commit 32dc9b2

Please sign in to comment.