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:
Ayke van Laethem
2018-09-17 15:13:11 +02:00
parent 77934f364f
commit b0aeaed635
+4 -1
View File
@@ -270,7 +270,10 @@ func (c *Compiler) Parse(mainPath string, buildTags []string) error {
if err != nil {
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
if !g.IsExtern() {
global.SetLinkage(llvm.InternalLinkage)