components/golang/patches/0059-release-branch.go1.5-cmd-cgo-ignore-vars-with-no-nam.patch
author Shawn Walker-Salas <shawn.walker@oracle.com>
Wed, 30 Mar 2016 13:33:31 -0700
changeset 5682 94c0ca64c022
parent 5331 9c955076ffe3
permissions -rw-r--r--
15558602 TCL_LD_SEARCH_FLAGS is wrongly defined in tclConfig.sh 22228656 remove redundant declarations and additions from makefiles 22252545 simplify build rules for components from common upstream 22378457 tclConfig.sh compiler settings are too specific 22727315 httping curses gui missing 22750630 procmail ignores userland cflags and may use private strstr function 22758725 wdiff uses diff from PATH instead of /usr/gnu/bin/diff 22926847 cloog Makefile typo when setting ASLR_MODE 22935090 tk config script has wrong linker flags

From bebbc624029d13a7c81957d971a2dce9d3bad1fb Mon Sep 17 00:00:00 2001
From: Ian Lance Taylor <[email protected]>
Date: Fri, 20 Nov 2015 13:53:18 -0800
Subject: [PATCH 59/63] [release-branch.go1.5] cmd/cgo: ignore vars with no
 name or type if they have a AttrSpecification

Fixes #13344.

Change-Id: I33c6721fd33d144c85c87840ddf27ce15aa72328
Reviewed-on: https://go-review.googlesource.com/17151
Run-TryBot: Ian Lance Taylor <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Minux Ma <[email protected]>
Reviewed-on: https://go-review.googlesource.com/17145
Reviewed-by: Ian Lance Taylor <[email protected]>
---
 misc/cgo/test/issue1635.go | 5 +++++
 src/cmd/cgo/gcc.go         | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/misc/cgo/test/issue1635.go b/misc/cgo/test/issue1635.go
index 6bfe110..cc4be90 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 b64849a..e0b89ec 100644
--- a/src/cmd/cgo/gcc.go
+++ b/src/cmd/cgo/gcc.go
@@ -490,6 +490,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__") {
-- 
2.6.1