cl: compile cgo

This commit is contained in:
Li Jie
2024-11-13 16:33:08 +08:00
parent ea654ef235
commit ec38943c53
7 changed files with 725 additions and 3 deletions

View File

@@ -412,6 +412,15 @@ const (
llgoAtomicUMax = llgoAtomicOpBase + llssa.OpUMax
llgoAtomicUMin = llgoAtomicOpBase + llssa.OpUMin
llgoCgoBase = llgoInstrBase + 0x30
llgoCgoCString = llgoCgoBase + 0x0
llgoCgoCBytes = llgoCgoBase + 0x1
llgoCgoGoString = llgoCgoBase + 0x2
llgoCgoGoStringN = llgoCgoBase + 0x3
llgoCgoGoBytes = llgoCgoBase + 0x4
llgoCgoCMalloc = llgoCgoBase + 0x5
llgoCgoCheckPointer = llgoCgoBase + 0x6
llgoAtomicOpLast = llgoAtomicOpBase + int(llssa.OpUMin)
)
@@ -423,6 +432,17 @@ func (p *context) funcName(fn *ssa.Function, ignore bool) (*types.Package, strin
p.ensureLoaded(pkg)
orgName = funcName(pkg, origin, true)
} else {
fname := fn.Name()
if fname == "_cgoCheckPointer" {
return nil, fname, llgoInstr
}
if strings.HasPrefix(fname, "_Cfunc_") {
if _, ok := llgoInstrs[fname]; ok {
return nil, fname, llgoInstr
}
fname = fname[7:]
return nil, fname, cFunc
}
if fnPkg := fn.Pkg; fnPkg != nil {
pkg = fnPkg.Pkg
} else {