diff --git a/misc/cgo/test/issue1635.go b/misc/cgo/test/issue1635.go index 6bfe110fdf40bb..cc4be9093d1a07 100644 --- a/misc/cgo/test/issue1635.go +++ b/misc/cgo/test/issue1635.go @@ -14,6 +14,11 @@ void scatter() { printf("scatter = %p\n", p); } +// Adding this explicit extern declaration makes this a test for +// https://gcc.gnu.org/PR68072 aka https://golang.org/issue/13344 . +// It used to cause a cgo error when building with GCC 6. +extern int hola; + // this example is in issue 3253 int hola = 0; int testHola() { return hola; } diff --git a/src/cmd/cgo/gcc.go b/src/cmd/cgo/gcc.go index 5a9a3c22920d77..ed121dad810662 100644 --- a/src/cmd/cgo/gcc.go +++ b/src/cmd/cgo/gcc.go @@ -491,6 +491,11 @@ func (p *Package) loadDWARF(f *File, names []*Name) { name, _ := e.Val(dwarf.AttrName).(string) typOff, _ := e.Val(dwarf.AttrType).(dwarf.Offset) if name == "" || typOff == 0 { + if e.Val(dwarf.AttrSpecification) != nil { + // Since we are reading all the DWARF, + // assume we will see the variable elsewhere. + break + } fatalf("malformed DWARF TagVariable entry") } if !strings.HasPrefix(name, "__cgo__") {