<div dir="ltr">For the curious: The relocation issue is one of two known incompatibilities between OrcMCJIT and MCJIT. I'm working on an ORC refactor that should eliminate both, at which point we can try this out again (with OrcMCJITReplacement properly #included this time). <div><br></div><div>Cheers,</div><div>Lang. </div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 13, 2017 at 6:03 AM, Pavel Labath via lldb-commits <span dir="ltr"><<a href="mailto:lldb-commits@lists.llvm.org" target="_blank">lldb-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: labath<br>
Date: Mon Nov 13 06:03:17 2017<br>
New Revision: 318039<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=318039&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=318039&view=rev</a><br>
Log:<br>
Revert "[lldb] Use OrcMCJITReplacement rather than MCJIT as the underlying JIT for LLDB"<br>
<br>
This commit really did not introduce any functional changes (for most<br>
people) but it turns out it's not for the reason we thought it was.<br>
<br>
The reason wasn't that Orc is a perfect drop-in replacement for MCJIT,<br>
but it was because we were never using Orc in the first place, as it was<br>
not initialized.<br>
<br>
Orc's initialization relies on a global constructor in the LLVMOrcJIT.a.<br>
Since this archive does not expose any symbols referenced from other<br>
object files, it does not get linked into liblldb when linking against<br>
llvm components statically. However, in an LLVM_LINK_LLVM_DYLIB=On<br>
build, LLVMOrcJit.a is linked into libLLVM.so using --whole-archive, so<br>
the global constructor does end up firing.<br>
<br>
The result of using Orc jit is pr34194, where lldb fails to evaluate<br>
even very simple expressions. This bug can be reproduced in<br>
non-LLVM_LINK_LLVM_DYLIB builds by making sure Orc jit is linked into<br>
liblldb, for example by #including<br>
llvm/ExecutionEngine/<wbr>OrcMCJITReplacement.h in IRExecutionUnit.cpp (and<br>
adding OrcJIT as a dependency to the relevant CMakeLists.txt file). The<br>
bug reproduces (at least) on linux and osx.<br>
<br>
The root cause of the bug seems to be related to relocation processing.<br>
It seems Orc processes relocations earlier than the system it is<br>
replacing. This means the relocation processing happens before we have<br>
had a chance to remap section load addresses to reflect their address in<br>
the target process memory, so they end up pointing to locations in the<br>
lldb's address space instead.<br>
<br>
I am not sure whether this is a bug in Orc jit, or in how we are using<br>
it from lldb, but in any case it is preventing us from using Orc right<br>
now. Reverting this fixes LLVM_LINK_LLVM_DYLIB build, and makes it clear<br>
that we are in fact *not* using Orc, and we never really were.<br>
<br>
This reverts commit r279327.<br>
<br>
Modified:<br>
    lldb/trunk/source/Expression/<wbr>IRExecutionUnit.cpp<br>
<br>
Modified: lldb/trunk/source/Expression/<wbr>IRExecutionUnit.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRExecutionUnit.cpp?rev=318039&r1=318038&r2=318039&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lldb/trunk/source/<wbr>Expression/IRExecutionUnit.<wbr>cpp?rev=318039&r1=318038&r2=<wbr>318039&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lldb/trunk/source/Expression/<wbr>IRExecutionUnit.cpp (original)<br>
+++ lldb/trunk/source/Expression/<wbr>IRExecutionUnit.cpp Mon Nov 13 06:03:17 2017<br>
@@ -277,8 +277,7 @@ void IRExecutionUnit::<wbr>GetRunnableInfo(St<br>
       .setRelocationModel(<wbr>relocModel)<br>
       .setMCJITMemoryManager(<br>
           std::unique_ptr<MemoryManager><wbr>(new MemoryManager(*this)))<br>
-      .setOptLevel(llvm::CodeGenOpt:<wbr>:Less)<br>
-      .setUseOrcMCJITReplacement(<wbr>true);<br>
+      .setOptLevel(llvm::CodeGenOpt:<wbr>:Less);<br>
<br>
   llvm::StringRef mArch;<br>
   llvm::StringRef mCPU;<br>
<br>
<br>
______________________________<wbr>_________________<br>
lldb-commits mailing list<br>
<a href="mailto:lldb-commits@lists.llvm.org">lldb-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/lldb-commits</a><br>
</blockquote></div><br></div>