mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/cgo: split cgo_export into cgo_export_static and cgo_export_dynamic
Also emit cgo_ldflag pragmas. R=golang-dev, remyoudompheng, iant CC=golang-dev https://golang.org/cl/7530043
This commit is contained in:
parent
56d1faa8b6
commit
fb59aed60b
7 changed files with 65 additions and 23 deletions
|
|
@ -31,7 +31,12 @@ func (p *Package) writeDefs() {
|
|||
|
||||
fflg := creat(*objDir + "_cgo_flags")
|
||||
for k, v := range p.CgoFlags {
|
||||
fmt.Fprintf(fflg, "_CGO_%s=%s\n", k, v)
|
||||
fmt.Fprintf(fflg, "_CGO_%s=%s\n", k, strings.Join(v, " "))
|
||||
if k == "LDFLAGS" {
|
||||
for _, arg := range v {
|
||||
fmt.Fprintf(fc, "#pragma cgo_ldflag %q\n", arg)
|
||||
}
|
||||
}
|
||||
}
|
||||
fflg.Close()
|
||||
|
||||
|
|
@ -100,6 +105,7 @@ 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)
|
||||
fmt.Fprintf(fc, "extern byte *%s;\n", n.C)
|
||||
|
||||
cVars[n.C] = true
|
||||
|
|
@ -651,8 +657,9 @@ func (p *Package) writeExports(fgo2, fc, fm *os.File) {
|
|||
if fn.Recv != nil {
|
||||
goname = "_cgoexpwrap" + cPrefix + "_" + fn.Recv.List[0].Names[0].Name + "_" + goname
|
||||
}
|
||||
fmt.Fprintf(fc, "#pragma cgo_export %s\n", goname)
|
||||
fmt.Fprintf(fc, "#pragma cgo_export_dynamic %s\n", goname)
|
||||
fmt.Fprintf(fc, "extern void ·%s();\n\n", goname)
|
||||
fmt.Fprintf(fc, "#pragma cgo_export_static _cgoexp%s_%s\n", cPrefix, exp.ExpName)
|
||||
fmt.Fprintf(fc, "#pragma textflag 7\n") // no split stack, so no use of m or g
|
||||
fmt.Fprintf(fc, "void\n")
|
||||
fmt.Fprintf(fc, "_cgoexp%s_%s(void *a, int32 n)\n", cPrefix, exp.ExpName)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue