mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-09 13:33:39 +00:00
compiler: allow a global to be defined multiple times
This is only possible when using compiler directives like the magic _extern_ prefix on global variables.
This commit is contained in:
+4
-1
@@ -270,7 +270,10 @@ func (c *Compiler) Parse(mainPath string, buildTags []string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
global := llvm.AddGlobal(c.mod, llvmType, g.LinkName())
|
global := c.mod.NamedGlobal(g.LinkName())
|
||||||
|
if global.IsNil() {
|
||||||
|
global = llvm.AddGlobal(c.mod, llvmType, g.LinkName())
|
||||||
|
}
|
||||||
g.llvmGlobal = global
|
g.llvmGlobal = global
|
||||||
if !g.IsExtern() {
|
if !g.IsExtern() {
|
||||||
global.SetLinkage(llvm.InternalLinkage)
|
global.SetLinkage(llvm.InternalLinkage)
|
||||||
|
|||||||
Reference in New Issue
Block a user