From: Ian Lance Taylor Date: Thu, 18 Jul 2013 01:02:21 +0000 (-0700) Subject: cmd/cgo: don't emit #pragma declarations when using gccgo X-Git-Tag: go1.2rc2~1015 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=c5c52f072b3d33f1a40ffda6d5334d38d0a11fa5;p=gostls13.git cmd/cgo: don't emit #pragma declarations when using gccgo Update #5905 Don't emit #pragma cgo_ldflag and cgo_import_static declarations that gccgo doesn't understand and can't use. R=golang-dev, rsc, bradfitz CC=golang-dev https://golang.org/cl/11490043 --- diff --git a/src/cmd/cgo/out.go b/src/cmd/cgo/out.go index 20f5afd5c7..f5618e3e8a 100644 --- a/src/cmd/cgo/out.go +++ b/src/cmd/cgo/out.go @@ -32,7 +32,7 @@ func (p *Package) writeDefs() { fflg := creat(*objDir + "_cgo_flags") for k, v := range p.CgoFlags { fmt.Fprintf(fflg, "_CGO_%s=%s\n", k, strings.Join(v, " ")) - if k == "LDFLAGS" { + if k == "LDFLAGS" && !*gccgo { for _, arg := range v { fmt.Fprintf(fc, "#pragma cgo_ldflag %q\n", arg) } @@ -105,7 +105,10 @@ func (p *Package) writeDefs() { fmt.Fprintf(fm, "extern char %s[];\n", n.C) fmt.Fprintf(fm, "void *_cgohack_%s = %s;\n\n", n.C, n.C) - fmt.Fprintf(fc, "#pragma cgo_import_static %s\n", n.C) + if !*gccgo { + fmt.Fprintf(fc, "#pragma cgo_import_static %s\n", n.C) + } + fmt.Fprintf(fc, "extern byte *%s;\n", n.C) cVars[n.C] = true