From: Dmitriy Vyukov Date: Wed, 24 Sep 2014 21:49:04 +0000 (+0400) Subject: cmd/go: strip -fsanitize= flags when building cgo object X-Git-Tag: go1.4beta1~306 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=39cd39b0238b079227460448f298bdd097562e7e;p=gostls13.git cmd/go: strip -fsanitize= flags when building cgo object Fixes #8788. LGTM=iant R=iant CC=golang-codereviews https://golang.org/cl/142470043 --- diff --git a/src/cmd/go/build.go b/src/cmd/go/build.go index 2e52731529..27bd307378 100644 --- a/src/cmd/go/build.go +++ b/src/cmd/go/build.go @@ -2228,6 +2228,14 @@ func (b *builder) cgo(p *Package, cgoExe, obj string, pcCFLAGS, pcLDFLAGS, gccfi strings.HasSuffix(f, ".so"), strings.HasSuffix(f, ".dll"): continue + // Remove any -fsanitize=foo flags. + // Otherwise the compiler driver thinks that we are doing final link + // and links sanitizer runtime into the object file. But we are not doing + // the final link, we will link the resulting object file again. And + // so the program ends up with two copies of sanitizer runtime. + // See issue 8788 for details. + case strings.HasPrefix(f, "-fsanitize="): + continue default: bareLDFLAGS = append(bareLDFLAGS, f) }