From 1303f0d3d89729e9bb9c6a13027a137e42728245 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 19 Dec 2014 17:21:14 -0800 Subject: [PATCH] cmd/cgo: don't #include cgo_export.h in gccgo _cgo_main.c Instead of relying on the asm names declared in the gccgo version of cgo_export.h, just emit a dummy symbol with the right asm name. This is enough to let the _cgo_main link succeed, which is all that matters here. Fixes #9294. Change-Id: I803990705b6b226ed0adf17dc57b58a9f501b213 Reviewed-on: https://go-review.googlesource.com/1901 Reviewed-by: Minux Ma --- src/cmd/cgo/out.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/cmd/cgo/out.go b/src/cmd/cgo/out.go index 78ecfd3974a..2537c3b280e 100644 --- a/src/cmd/cgo/out.go +++ b/src/cmd/cgo/out.go @@ -835,8 +835,6 @@ func (p *Package) writeGccgoExports(fgo2, fc, fm io.Writer) { fmt.Fprintf(fgcc, "/* Created by cgo - DO NOT EDIT. */\n") fmt.Fprintf(fgcc, "#include \"_cgo_export.h\"\n") - fmt.Fprintf(fm, "#include \"_cgo_export.h\"\n") - for _, exp := range p.ExpFunc { fn := exp.Func fntype := fn.Type @@ -924,7 +922,8 @@ func (p *Package) writeGccgoExports(fgo2, fc, fm io.Writer) { fmt.Fprint(fgcc, "}\n") // Dummy declaration for _cgo_main.c - fmt.Fprintf(fm, "%s %s %s {}\n", cRet, goName, cParams) + fmt.Fprintf(fm, `char %s[1] __asm__("%s.%s");`, goName, gccgoSymbolPrefix, goName) + fmt.Fprint(fm, "\n") // For gccgo we use a wrapper function in Go, in order // to call CgocallBack and CgocallBackDone.