1
0
mirror of https://github.com/golang/go synced 2024-11-23 06:00:08 -07:00

cmd/go: if -msan, pass -fsanitize=memory to cgo builds

Also fix the msan_fail test.  It was bogus, since it always aborted one
way or another.

Change-Id: Ic693327d1bddb7bc5c7d859ac047fc93cb9b5b1c
Reviewed-on: https://go-review.googlesource.com/16172
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Ian Lance Taylor 2015-10-21 15:18:52 -07:00
parent 7df8ba136c
commit 029c760c7b
2 changed files with 7 additions and 1 deletions

View File

@ -13,7 +13,8 @@ void f(int32_t *p, int n) {
void g(int32_t *p, int n) {
if (p[4] != 1) {
abort();
// We shouldn't get here; msan should stop us first.
exit(0);
}
}
*/

View File

@ -2893,6 +2893,11 @@ func (b *builder) cgo(p *Package, cgoExe, obj string, pcCFLAGS, pcLDFLAGS, cgofi
cgoLDFLAGS = append(cgoLDFLAGS, "-lobjc")
}
if buildMSan && p.ImportPath != "runtime/cgo" {
cgoCFLAGS = append([]string{"-fsanitize=memory"}, cgoCFLAGS...)
cgoLDFLAGS = append([]string{"-fsanitize=memory"}, cgoLDFLAGS...)
}
// Allows including _cgo_export.h from .[ch] files in the package.
cgoCPPFLAGS = append(cgoCPPFLAGS, "-I", obj)