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.
Этот коммит содержится в:
Ayke van Laethem 2018-09-17 15:13:11 +02:00
родитель 77934f364f
коммит b0aeaed635
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: E97FF5335DFDFDED

Просмотреть файл

@ -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)