Skip to content

Commit cf42b78

Browse files
matloobgopherbot
authored andcommitted
cmd/cgo: run recordTypes for each of the debugs at the end of Translate
Save the debug information in a slice and then process all of them at the end of the loop. For golang#75167 Change-Id: I6a6a6964dffa784b0aa776334562333ecf247023 Reviewed-on: https://go-review.googlesource.com/c/go/+/699019 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Michael Matloob <[email protected]> Auto-Submit: Michael Matloob <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Reviewed-by: Michael Pratt <[email protected]>
1 parent 5e6296f commit cf42b78

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/cmd/cgo/gcc.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,7 @@ func (p *Package) Translate(f *File) {
192192
cref.Name.C = cname(cref.Name.Go)
193193
}
194194

195-
var conv typeConv
196-
conv.Init(p.PtrSize, p.IntSize)
197-
195+
var debugs []*debug // debug data from iterations of gccDebug
198196
ft := fileTypedefs{typedefs: make(map[string]bool)}
199197
numTypedefs := -1
200198
for len(ft.typedefs) > numTypedefs {
@@ -213,8 +211,7 @@ func (p *Package) Translate(f *File) {
213211
}
214212
needType := p.guessKinds(f)
215213
if len(needType) > 0 {
216-
d := p.loadDWARF(f, &ft, needType)
217-
p.recordTypes(f, d, &conv)
214+
debugs = append(debugs, p.loadDWARF(f, &ft, needType))
218215
}
219216

220217
// In godefs mode we're OK with the typedefs, which
@@ -224,6 +221,12 @@ func (p *Package) Translate(f *File) {
224221
break
225222
}
226223
}
224+
225+
var conv typeConv
226+
conv.Init(p.PtrSize, p.IntSize)
227+
for _, d := range debugs {
228+
p.recordTypes(f, d, &conv)
229+
}
227230
p.prepareNames(f)
228231
if p.rewriteCalls(f) {
229232
// Add `import _cgo_unsafe "unsafe"` after the package statement.

0 commit comments

Comments
 (0)