Fix import from module with appending var, which cannot be imported. The
first fix is to remove an overly-aggressive error check.
The second fix is to deal with restructuring introduced to the module
linker yesterday in r254418. The handling in linkGlobalValueProto for
not linking in appending variables during function importing is coming
too late, when we are materializing decls. Add the same check to
linkIfNeeded. (Rafael, perhaps the checking in linkGlobalValueProto and
linkIfNeeded should be commoned? Also, I'm concerned about the case
where linkGlobalValueProto decides linkFromSrc==false and there is no
existing dest GV. Previously we would skip linking for that source GV,
but now we will create a decl in the dest module, as the early return
when "!LinkFromSrc && !DGV" has been removed from linkGlobalValueProto
due to the change in callsite. Are there other lurking issues?)
Test by Mehdi Amini.
Found another crash:
ModuleLinker::run() will start by iterating over all the variables in the module and call linkIfNeeded(GV). Your fix here only kicks in if there is no "DGV" (why?).
If the destination module already have a global_ctors, DGV won't be null. We may want to fix getLinkedToGlobal() as well.
All of this logic gets more and more complicate, this is a bit scary.