From 8a28085a0fdfea041ff923353c7e482455322c2e Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 8 May 2013 06:28:33 -0700 Subject: [PATCH] cmd/cgo: pass -Wsystem-headers when looking for errors This works around a bug in GCC 4.8.0. Fixes #5118. R=golang-dev, r, minux.ma CC=golang-dev https://golang.org/cl/9120045 --- src/cmd/cgo/gcc.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/cmd/cgo/gcc.go b/src/cmd/cgo/gcc.go index 8288a490ac..bc7a6472f3 100644 --- a/src/cmd/cgo/gcc.go +++ b/src/cmd/cgo/gcc.go @@ -809,6 +809,15 @@ func (p *Package) gccDefines(stdin []byte) string { func (p *Package) gccErrors(stdin []byte) string { // TODO(rsc): require failure args := p.gccCmd() + + // GCC 4.8.0 has a bug: it sometimes does not apply + // -Wunused-value to values that are macros defined in system + // headers. See issue 5118. Adding -Wsystem-headers avoids + // that problem. This will produce additional errors, but it + // doesn't matter because we will ignore all errors that are + // not marked for the cgo-test file. + args = append(args, "-Wsystem-headers") + if *debugGcc { fmt.Fprintf(os.Stderr, "$ %s <