ssa: prog.linkname; abi llvm.LinkOnceAnyLinkage always

This commit is contained in:
visualfc
2024-08-20 21:11:27 +08:00
parent 7eeca21a05
commit 2feb3e1d7a
18 changed files with 66 additions and 61 deletions

View File

@@ -431,9 +431,7 @@ func (b Builder) loadType(t types.Type) Global {
prog := b.Prog
g = pkg.doNewVar(name, prog.AbiTypePtrPtr())
g.InitNil()
if pub {
g.impl.SetLinkage(llvm.LinkOnceAnyLinkage)
}
g.impl.SetLinkage(llvm.LinkOnceAnyLinkage)
pkg.abiTypeInit(g, t, pub)
}
return g

View File

@@ -191,6 +191,7 @@ type aProgram struct {
sigljmpTy *types.Signature
paramObjPtr_ *types.Var
linkname map[string]string // pkgPath.nameInPkg => linkname
ptrSize int
@@ -227,6 +228,7 @@ func NewProgram(target *Target) Program {
ctx: ctx, gocvt: newGoTypes(),
target: target, td: td, is32Bits: is32Bits,
ptrSize: td.PointerSize(), named: make(map[string]llvm.Type), fnnamed: make(map[string]int),
linkname: make(map[string]string),
}
}
@@ -245,6 +247,15 @@ func (p Program) SetTypeBackground(fullName string, bg Background) {
p.gocvt.typbg[fullName] = bg
}
func (p Program) SetLinkname(name, link string) {
p.linkname[name] = link
}
func (p Program) Linkname(name string) (link string, ok bool) {
link, ok = p.linkname[name]
return
}
func (p Program) runtime() *types.Package {
if p.rt == nil {
p.rt = p.rtget()