]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: strip -fsanitize= flags when building cgo object
authorDmitriy Vyukov <dvyukov@google.com>
Wed, 24 Sep 2014 21:49:04 +0000 (01:49 +0400)
committerDmitriy Vyukov <dvyukov@google.com>
Wed, 24 Sep 2014 21:49:04 +0000 (01:49 +0400)
Fixes #8788.

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/142470043

src/cmd/go/build.go

index 2e52731529178a6bf01560ca02e73c853afc0670..27bd307378c33bfe97e65b23dfc84de0a6d982cb 100644 (file)
@@ -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)
                }