<div dir="ltr">Hi Lang,<div><br></div><div>Thanks for the response.</div><div><br></div><div>I'm using a custom JIT that was copied from LLJIT and then slightly edited.</div><div>It's jitting to memory that is shared with a child process and the child process runs the 'code'.</div><div>I assume this generator won't work as the symbols won't be in the current process.</div><div><br></div><div>My recollection is that LLVM used to have remote process support but has since deprecated it. Is that correct?</div><div><br></div><div>My working model was that clang would create all the symbols that are used (both from a user code file and from system library), these would go into the IR, and then the JIT would turn these into executable code.</div><div>This doesn't seem to be correct given that the library symbols aren't being found. (Is this because I'm not statically linking the system libs? I'll check this out.)</div><div><br></div><div>I'm not sure whether I'm misunderstanding the clang side, the LLVM side, something else, or some combination of the above!</div><div>I'll have another look at the IR now and see if I can work anything out but any light you (or anyone else) can shed on the matter would be greatly appreciated.</div><div><br></div><div>All the best,</div><div>Andrew</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 21 Nov 2019 at 19:56, Lang Hames <<a href="mailto:lhames@gmail.com">lhames@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi Andrew,<div><br></div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">1) I get multiple warnings for the system headers (e.g. stdlib) of the form:<br>"warning: macro expansion producing 'defined' has undefined behavior"<br>Is there a way to prevent these warnings? Preferably only for the system libraries.<br>I tried -Wno-expansion-to-defined, -fms-extensions, -fms-compatibility-fms, -compatibility-version=14.16.27023. I also tried to reference the system library folder by -isystem, -internal-isystem and -c-isystem</blockquote></div><div><br></div><div>I'm afraid I don't have any insight on this. If nobody chimes in on this list it may be worth asking this on the clang-dev mailing list.</div><div><br></div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">2) Disregarding the warnings, I also get the following error message:<br>"JIT session error: Symbols not found: { malloc }"</blockquote></div><div><br></div><div>How is your JIT set up? Are you using LLJIT, or a custom JIT class?</div><div><br></div><div>Either way, the key is to make sure that process symbols are added to a JITDylib so that they can be found by JIT'd code. As an example, the code to do this in LLVM's lli tool is:</div><div><br></div><div><div><font face="monospace">J->getMainJITDylib().addGenerator(</font></div><div><font face="monospace">      ExitOnErr(orc::DynamicLibrarySearchGenerator::GetForCurrentProcess(</font></div><div><font face="monospace">          J->getDataLayout().getGlobalPrefix())));</font></div></div><div><br></div><div>Cheers,</div><div>Lang.</div><div><br></div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Nov 12, 2019 at 12:48 PM Andrew Reece via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi all,<div><br></div><div>First of all, I want to say that I really appreciate all the work that's gone into LLVM, clang and the ORC API. I would be very unlikely to be doing my current project if they weren't available.  <br></div><div><br></div><div>I'm using the ORC API to JIT some C code (soon to be C++) on Windows. </div><div><div>(I was on LLVM 8.0.0 but it didn't handle the 'allocator' attribute so I upgraded to LLVM 9.0.0.)</div><div></div></div><div><br></div><div>The JIT compiling works well for simple files, #included local files and object files.</div><div>As soon as I start trying to use system libraries with functions, things start to fall down.</div><div>I think this is largely just due to my ignorance of clang in general, but any guidance would be greatly appreciated.</div><div><br></div><div><br></div><div>1) I get multiple warnings for the system headers (e.g. stdlib) of the form:</div><div>"warning: macro expansion producing 'defined' has undefined behavior"</div><div><br></div><div>Is there a way to prevent these warnings? Preferably only for the system libraries.</div><div>I tried -Wno-expansion-to-defined, -fms-extensions, -fms-compatibility-fms, -compatibility-version=14.16.27023. I also tried to reference the system library folder by -isystem, -internal-isystem and -c-isystem</div><div><br></div><div><br></div><div>2) Disregarding the warnings, I also get the following error message:</div><div>"JIT session error: Symbols not found: { malloc }"<br></div><div><br></div><div>I assumed this might be because I wasn't linking the standard library, so I tried appending "msvcrt.lib" and "-stdlib=msvcrt.lib" but to no avail. Can you use .lib files with clang on Windows?</div><div><br></div><div>How do I make sure that the symbols defined in the standard libraries are available to my JIT?</div><div><br></div><div><br></div><div>Thanks for any help you can give!</div><div>All the best,</div><div>Andrew</div></div>
_______________________________________________<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="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>
</blockquote></div>