<div>Hello!</div><div>I created a new llvm module (<strong>A</strong>) - to create a 'glue' code.</div><div>I want to call some functions from another module (<strong>B</strong>);</div><div>I load module <strong>B</strong> withing the same LLVMContext, and create a function declaration in module A via:</div><div>    auto functionInAnotherModule = ModuleB.getFunction(callableName);</div><div>    auto functionType = functionInAnotherModule->getFunctionType();</div><div>    auto localFunction = llvm::Function::Create(functionType, llvm::GlobalValue::LinkageTypes::ExternalWeakLinkage, callableName, &ModuleA);</div><div> </div><div>    Function seems to be copied, together with complex types its using:</div><div>    ; ModuleID = 'JitModule'</div><div>    source_filename = "JitModule"   </div><div>    %struct._EN12RecordStreamE = type { %class.RecordStream }</div><div>    declare extern_weak void @_EN12RecordStream4InitEPTsN18_EN12RecordStreamEEPvv(%struct._EN12RecordStreamE*, i8*)</div><div>   </div><div>    ... But later I'm not able to link in ModuleB to ModuleA using linker.linkInModule(std::move(ModuleB));</div><div>    llvm says: Assertion failed: !(Pair.first != Ty && Pair.second == Ty) && "mapping to a source type",...</div><div> </div><div>    Could someone point me what conceptually I did wrong?</div>