<div dir="ltr">Hi Lang,<div><br></div><div>Thank you for your feedback on the blog post, please find below some additional inputs from my side on the comments you provided:</div><div><br></div><div>> Regarding emulated TLS deactivation: I've never looking into how/whether this works on Windows. If it doesn't make sense to have it on by default there we can change the default for Windows targets.</div><div><br></div><div>I'm really no expert, so you probably want to collect additional inputs/checks on this point, but yes, from my current perspective, it seems that it doesn't really work to try to use Emulated TLS in LLJIT on Windows, but one should keep in mind that this is when using the microsoft crt from Visual Studio (FYI, I'm using version 2017 for now, maybe it was different in previous versions too): I would expect things to be different if you are using another compiler as base (?) [I mean, if you change the default, this might then break previously working code that was based on mingw for instance... But not sure if this should be a concern or not for a not yet released version of LLVM ;-)]</div><div><br></div><div>> I think that anything that llvm-link can merge should, in theory, be safe to add to the JIT. This actually sounds like a bug. Are you able to share the full modules that you were merging?</div><div><br></div><div>Initially, the test I made on this point was using the Lest test framework as described in my post, but your feedback above got me thinking, and I could actually come up with a more simple setup without any C++ library dependency: this new test is simply based on a couple of C++ functions that are using exceptions. I used the attached lua script "exception3.lua" to generate the bitcode files and load the corresponding modules [of course I don't expect you to run lua scripts, but I thought that this could help understanding the code generation context anyway]. So with that script I generated the test_func1.bc/test_func2.bc/test_func1_and_func2.bc and the corresponding .ll file (generated from the .bc files using llvm-dis): all those files are attached to this email too.</div><div><br></div><div>=> So, I can load for instance the module corresponding to test_func1.bc in my main JITDylib, but then, if I try to load the test_func2 IR module in the same Dylib, I get the following error:</div><div><br></div><b>Duplicate definition of symbol '??_7exception@std@@6B@'</b><div><br></div><div>In all the .ll files you will find multiple references of that symbol... but unfortunately, my skills won't get me any further than that [=> ie. I have no idea what to think about the content of those files :-)].</div><div><br></div><div>But anyway, if you notice anything interesting yourself, or you have an idea you think I should try, or you need more info on anything here please let me know.</div><div><br></div><div>PS: I'm thinking maybe the command line arguments I'm providing to the compilerInvocation might also be important here so, just in case: here is the list of args I'm using currently:</div><div><br></div><div><div style="line-height:19px"><div style=""><font color="#073763">{    "-triple=x86_64-pc-windows-msvc19.16.27030",<br>    "-x", "c++",<br>    "-mrelax-all",<br>    "-mincremental-linker-compatible",<br>    "-disable-free",<br>    "-discard-value-names",<br>    "-mrelocation-model", "pic",<br>    "-pic-level", "2",<br>    "-mthread-model", "posix",<br>    "-mframe-pointer=none",<br>    "-relaxed-aliasing",<br>    "-fmath-errno",<br>    "-fno-rounding-math",<br>    "-mconstructor-aliases",<br>    "-munwind-tables",<br>    "-target-cpu", "x86-64",<br>    "-mllvm",<br>    "-x86-asm-syntax=intel",<br>    "-stack-protector","2",<br>    "-fcxx-exceptions",<br>    "-fexceptions",<br>    "-fexternc-nounwind",<br>    "-fms-volatile",<br>    "-fdiagnostics-format", "msvc",<br>    "-dwarf-column-info",<br>    "-Wall",<br>    "-std=c++17",<br>    "-fdeprecated-macro",<br>    "-ferror-limit","19",<br>    "-fmessage-length=174",<br>    "-fms-extensions",<br>    "-fms-compatibility",<br>    "-fms-compatibility-version=19.16.27030",<br>    "-fdelayed-template-parsing",<br>    "-fcolor-diagnostics",<br>    "-fobjc-runtime=gcc",<br>    "-faddrsig",<br>  }</font></div></div></div><div><br></div><div>Regards,</div><div>Manu.</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le lun. 27 avr. 2020 à 20:41, Lang Hames <<a href="mailto:lhames@gmail.com">lhames@gmail.com</a>> a écrit :<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">I was just reading the blog post -- very cool!</div><div dir="ltr"><div><br></div><div>Regarding Globals construction & destruction: There definitely has been a lot of churn in that area. There will probably be more before  LLVM 11 is released, but I can see light at the end of the tunnel. I think the Right Way to run initializers in a JITDylib is to treat it as equivalent to a dlopen operation (with extra allowances for the fact that new initializers can be added to a JITDylib at runtime). This is what the LLJIT::initialize method is doing. Now we just need to generalize it to support out-of-process JITs. That will at least require a new remote-target abstraction, and an RPC implementation for testing in-tree.</div><div><br></div><div>Regarding emulated TLS deactivation: I've never looking into how/whether this works on Windows. If it doesn't make sense to have it on by default there we can change the default for Windows targets.</div><div><br></div><div>Regarding merging of multiple modules:</div><div><br></div><div><div>"But of course this would not work because as soon as I try to load the second script, I get a duplicate symbol error from LLVM (and this completely makes sense):</div><div><br></div><div>[ERROR]: LLVM error: Duplicate definition of symbol '??_7success@lest@@6B@'"</div></div><div><br></div><div>I think that anything that llvm-link can merge should, in theory, be safe to add to the JIT. This actually sounds like a bug. Are you able to share the full modules that you were merging?</div><div><br></div><div>Regards,</div><div>Lang.</div><div><br></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Apr 27, 2020 at 11:11 AM David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@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">+Lang for LLVM Orc things<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Apr 27, 2020 at 3:34 AM Emmanuel Roche 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">Hello LLVM developers!<div><br></div><div>So, I'm continuing my journey with my toy C++ JIT compiler implementation, and I wrote another article on the issues/solutions I've been working on in the past few days, mainly:</div><div><br></div><div>- Precompiled header handling,</div><div>- Emulated TLS desactivation,</div><div>- Globals construction & destruction,</div><div>- C++ exceptions handling,</div><div>- Multi modules linking,</div><div><br></div><div>=> In case this could be helpful to anyone, you will find this article here: <a href="http://wiki.nervtech.org/doku.php?id=blog:2020:0425_jit_compiler_part5_improvements" target="_blank">http://wiki.nervtech.org/doku.php?id=blog:2020:0425_jit_compiler_part5_improvements</a></div><div><br></div><div>And of course, if you have any questions for me, just let me know.</div><div><br></div><div>Meanwhile, happy hacking everyone ;-)!</div><div><br></div><div>Best regards,</div><div>Manu.</div><div><br></div><div><br></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>
</blockquote></div>