diff options
author | Damian Gryski <[email protected]> | 2023-03-09 07:49:57 -0800 |
---|---|---|
committer | Ron Evans <[email protected]> | 2023-03-19 17:45:43 +0100 |
commit | 0d65b4dd26a3ac31c443e48d93f21145708c9a5e (patch) | |
tree | 6dba4d4a25321897063b8bd1ba289fc8fe93dca8 /compiler | |
parent | 6a685b2a8d7e5c0432c9445196bee11caa01f160 (diff) | |
download | tinygo-0d65b4dd26a3ac31c443e48d93f21145708c9a5e.tar.gz tinygo-0d65b4dd26a3ac31c443e48d93f21145708c9a5e.zip |
compiler: only define the package path once
Adding https://github.com/tinygo-org/tinygo/pull/3534 by hand to avoid conflicts when I rebase.
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/interface.go | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/compiler/interface.go b/compiler/interface.go index cbebec824..128844c00 100644 --- a/compiler/interface.go +++ b/compiler/interface.go @@ -90,13 +90,16 @@ func (c *compilerContext) pkgPathPtr(pkgpath string) llvm.Value { pkgpathName = "reflect/types.type.pkgpath:" + pkgpath } - pkgpathInitializer := c.ctx.ConstString(pkgpath+"\x00", false) - pkgpathGlobal := llvm.AddGlobal(c.mod, pkgpathInitializer.Type(), pkgpathName) - pkgpathGlobal.SetInitializer(pkgpathInitializer) - pkgpathGlobal.SetAlignment(1) - pkgpathGlobal.SetUnnamedAddr(true) - pkgpathGlobal.SetLinkage(llvm.LinkOnceODRLinkage) - pkgpathGlobal.SetGlobalConstant(true) + pkgpathGlobal := c.mod.NamedGlobal(pkgpathName) + if pkgpathGlobal.IsNil() { + pkgpathInitializer := c.ctx.ConstString(pkgpath+"\x00", false) + pkgpathGlobal = llvm.AddGlobal(c.mod, pkgpathInitializer.Type(), pkgpathName) + pkgpathGlobal.SetInitializer(pkgpathInitializer) + pkgpathGlobal.SetAlignment(1) + pkgpathGlobal.SetUnnamedAddr(true) + pkgpathGlobal.SetLinkage(llvm.LinkOnceODRLinkage) + pkgpathGlobal.SetGlobalConstant(true) + } pkgPathPtr := llvm.ConstGEP(pkgpathGlobal.GlobalValueType(), pkgpathGlobal, []llvm.Value{ llvm.ConstInt(c.ctx.Int32Type(), 0, false), llvm.ConstInt(c.ctx.Int32Type(), 0, false), |