Skip to content

Commit 049eea1

Browse files
committed
cmd/cgo: document guarding of writing cgo symbols
1 parent 7ce5095 commit 049eea1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/cmd/cgo/out.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@ func (p *Package) writeDefs() {
168168
if *gccgo {
169169
fmt.Fprintf(fc, "extern byte *%s;\n", n.C)
170170
} else {
171+
// Only emit the following symbols if they are not for
172+
// a function pointer variable. The function symbol is already defined
173+
// and redefining it here as such will break compilation when
174+
// used in conjunction with link time optimization in external
175+
// linkers.
171176
if n.Kind != "fpvar" {
172177
fmt.Fprintf(fm, "extern char %s[];\n", n.C)
173178
fmt.Fprintf(fm, "void *_cgohack_%s = %s;\n\n", n.C, n.C)

0 commit comments

Comments
 (0)