<div dir="ltr">Ahh. It is the <i>other</i> in-process-symbol-lookup gotcha.<div><br></div><div>I will think about adding a convenience option for that.</div><div><br></div><div>Thanks Alex!</div><div><br></div><div>-- Lang.</div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Jun 28, 2018 at 1:49 PM Frank Winter via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Alex,<br>
<br>
loading the symbols explicitly helped. With this the build process <br>
doesn't need any additional linker flags. Very nice.<br>
<br>
Thanks,<br>
Frank<br>
<br>
<br>
On 06/28/2018 04:38 PM, Alex Denisov wrote:<br>
> Hi Frank,<br>
><br>
> If I am not mistaken it doesn't look in the whole process space by default.<br>
> Please, try loading all the symbols explicitly:<br>
><br>
> sys::DynamicLibrary::LoadLibraryPermanently(nullptr);<br>
><br>
> If it doesn't help, then you may try compiling your host program with -rdynamic, otherwise dlsym may not see all the symbols. At least it was the case for me on Linux.<br>
><br>
> I hope it helps.<br>
><br>
> Cheers,<br>
> Alex.<br>
><br>
>> On 28. Jun 2018, at 21:40, Frank Winter via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
>><br>
>> I am upgrading our JIT application to use LLVM 6.0.0, and with this transition I am making the move to use the new MCJIT facility.<br>
>><br>
>> A problem I am encountering is that the math functions from libm are not resolved/found. I am using the lambda resolver from the KaleidoscopeJIT class which first searches the present modules and, if that is unsuccessful, continues the search in the whole process space.<br>
>><br>
>> The generated modules would declare external functions like<br>
>><br>
>> declare float @cosf(float)<br>
>><br>
>> and would call it like:<br>
>><br>
>> %17 = call float @cosf(float %16)<br>
>><br>
>> The datalayout is set to<br>
>><br>
>> target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"<br>
>><br>
>> The code snippet that adds the module is pretty much from the JIT tutorial:<br>
>><br>
>> auto Resolver = llvm::orc::createLambdaResolver(<br>
>> [&](const std::string &Name) {<br>
>> if (auto Sym = CompileLayer.findSymbol(Name, false))<br>
>> return Sym;<br>
>> return llvm::JITSymbol(nullptr);<br>
>> },<br>
>> [](const std::string &Name) {<br>
>> if (auto SymAddr =<br>
>> llvm::RTDyldMemoryManager::getSymbolAddressInProcess(Name))<br>
>> return llvm::JITSymbol(SymAddr, llvm::JITSymbolFlags::Exported);<br>
>> return llvm::JITSymbol(nullptr);<br>
>> });<br>
>><br>
>> cantFail(CompileLayer.addModule(std::move(M),<br>
>> std::move(Resolver)));<br>
>><br>
>> When running the program I receive the following error:<br>
>><br>
>> LLVM ERROR: Program used external function 'cosf' which could not be resolved!<br>
>><br>
>> This is on an Intel i7 CPU with LLVM targets configured as "X86".<br>
>><br>
>> Adding the '-lm' and '-ldl' option to the linker command that links the final program doesn't help. (I even called the 'cosf' function by hand in the host code to make sure it is mapped - didn't change the behavior of the MCJIT resolver.)<br>
>><br>
>> Any ideas?<br>
>><br>
>><br>
>> Best wishes,<br>
>><br>
>> Frank<br>
>><br>
>><br>
>><br>
>> _______________________________________________<br>
>> LLVM Developers mailing list<br>
>> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
>> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>