Commit 1303f0d3 authored by Ian Lance Taylor's avatar Ian Lance Taylor

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/1901Reviewed-by: 's avatarMinux Ma <minux@golang.org>
parent 1e65616e
......@@ -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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment