<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Hi Philip,</p>
<p>unfortunately in the case of ExecutionEngine it doesn't have the
symbols needed. I was hoping to be able to do this by linking
ExecutionEngine privately (target_link_libraries( pluginName
PRIVATE LLVMExecutionEngine )), for testing purposes at least. How
does the plugin loading work that the symbols are seemingly
omitted/stripped/inaccessible?<br>
</p>
<p>Cheers,</p>
<p>Viktor<br>
</p>
<p><br>
</p>
<div class="moz-cite-prefix">On 4/19/19 12:13 PM, Philip Pfaffe
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAHe691Fowto-=grkRCtSeP2FgX=NvyU_tFy44s54+106PtipJA@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div class="gmail_quote">
<div>Hi Viktor, </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div bgcolor="#FFFFFF">
<p>Though, I feel like this should also be possible with
statically linking the ExecutionEngine into the plugin
shared object.</p>
</div>
</blockquote>
<div>Unfortunately it won't. In general, you don't link any
LLVM libraries into opt plugins because opt already has all
the symbols you need. If you were to link in the libraries,
all sorts of problems arise, most of them because we have
lot's of global state everywhere. With dynamic linking, most
of the problems can be avoided because the dependencies
won't be loaded twice.</div>
<div><br>
</div>
<div>Cheers,</div>
<div>Philip</div>
<div><br>
</div>
<div><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 bgcolor="#FFFFFF">
<p>I don't quite understand how the concrete
Interpreter/MCJIT linking via
llvm/ExecutionEngine/Interpreter.h and
llvm/ExecutionEngine/MCJIT.h works. So far I was only
using ExecutionEngine.h without Interpreter or MCJIT, so
that could have been the problem why static linking
didn't work.<br>
</p>
<p>After playing around with Zhangs solution I've found
out that I get the same undefined symbol to
llvm::EngineBuilder error when omitting the MCJIT header
and lib (since I actually only need an interpreter), my
guess is that this is due to Interpreter.h missing the
getenv trick used in MCJIT.h to prevent it being
optimized away by the compiler? I might take a closer
look at this at some point, right now I'm just happy to
finally be able to work on my opt pass.<br>
</p>
<p><br>
</p>
<p>Thanks,</p>
<p>Viktor<br>
</p>
<p><br>
</p>
<div class="gmail-m_6517503528706480469moz-cite-prefix">On
4/18/19 7:38 PM, John Brawn wrote:<br>
</div>
<blockquote type="cite">
<div class="gmail-m_6517503528706480469WordSection1">
<p class="MsoNormal"><span
style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">The
fundamental problem here is that opt doesn’t use
ExecutionEngine (because it has no need to), so
trying</span></p>
<p class="MsoNormal"><span
style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">to
use ExecutionEngine (or any other bit of llvm that
opt doesn’t use for that matter) in an opt plugin
isn’t</span></p>
<p class="MsoNormal"><span
style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">going
to work.</span></p>
<p class="MsoNormal"><span
style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"> </span></p>
<p class="MsoNormal"><span
style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">The
solution I’d go with would be to build llvm with
shared libraries (use –DBUILD_SHARED_LIBS=ON on
the</span></p>
<p class="MsoNormal"><span
style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">cmake
command) then link the plugin against
ExecutionEngine. That shouldn’t require any
changes anywhere</span></p>
<p class="MsoNormal"><span
style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">(when
I gave it a quick try it seemed to work).</span></p>
<p class="MsoNormal"><span
style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"> </span></p>
<p class="MsoNormal"><span
style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">John</span></p>
<p class="MsoNormal"><span
style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"> </span></p>
<div
style="border-top:none;border-right:none;border-bottom:none;border-left:1.5pt
solid blue;padding:0cm 0cm 0cm 4pt">
<div>
<div
style="border-right:none;border-bottom:none;border-left:none;border-top:1pt
solid rgb(181,196,223);padding:3pt 0cm 0cm">
<p class="MsoNormal"><b><span
style="font-size:10pt;font-family:Tahoma,sans-serif"
lang="EN-US">From:</span></b><span
style="font-size:10pt;font-family:Tahoma,sans-serif"
lang="EN-US"> llvm-dev [<a
class="gmail-m_6517503528706480469moz-txt-link-freetext"
href="mailto:llvm-dev-bounces@lists.llvm.org" target="_blank"
moz-do-not-send="true">mailto:llvm-dev-bounces@lists.llvm.org</a>]
<b>On Behalf Of </b>Zhang via llvm-dev<br>
<b>Sent:</b> 16 April 2019 22:04<br>
<b>To:</b> Viktor Was BSc; llvm-dev<br>
<b>Subject:</b> Re: [llvm-dev] Opt plugin
linkage</span></p>
</div>
</div>
<p class="MsoNormal"> </p>
<div>
<p class="MsoNormal">Just another follow-up, seems
like ExecutionEngine is still not usable without
editing CMakeLists, on my setup I had to edit
CMakeLists.txt as well to get the example
working.</p>
</div>
<div>
<p class="MsoNormal">Below is the modifications I
made:</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">Modified Hello.cpp for
testing:</p>
</div>
<div>
<p class="MsoNormal">```</p>
</div>
<div>
<div>
<p class="MsoNormal"> bool
runOnFunction(Function &F) override {</p>
</div>
<div>
<p class="MsoNormal"> ++HelloCounter;</p>
</div>
<div>
<p class="MsoNormal"> std::string errStr;</p>
</div>
<div>
<p class="MsoNormal"> EngineBuilder eb;</p>
</div>
<div>
<p class="MsoNormal">
eb.setErrorStr(&errStr);</p>
</div>
<div>
<p class="MsoNormal">
eb.setEngineKind(EngineKind::Kind::JIT);</p>
</div>
<div>
<p class="MsoNormal"> ExecutionEngine*
ee=eb.create();</p>
</div>
<div>
<p class="MsoNormal">
errs()<<"ExecutionEngine:"<<ee<<"
Error:"<<errStr<<"\n";</p>
</div>
<div>
<p class="MsoNormal"> delete ee;</p>
</div>
<div>
<p class="MsoNormal"> errs() <<
"Hello: ";</p>
</div>
<div>
<p class="MsoNormal">
errs().write_escaped(F.getName()) <<
'\n';</p>
</div>
<div>
<p class="MsoNormal"> return false;</p>
</div>
<div>
<p class="MsoNormal"> }</p>
</div>
</div>
<div>
<p class="MsoNormal">```</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">Modified opt's
CMakeLists.txt:</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">```</p>
</div>
<div>
<div>
<div>
<p class="MsoNormal">set(LLVM_LINK_COMPONENTS</p>
</div>
<div>
<p class="MsoNormal">
${LLVM_TARGETS_TO_BUILD}</p>
</div>
<div>
<p class="MsoNormal"> AggressiveInstCombine</p>
</div>
<div>
<p class="MsoNormal"> Analysis</p>
</div>
<div>
<p class="MsoNormal"> BitWriter</p>
</div>
<div>
<p class="MsoNormal"> CodeGen</p>
</div>
<div>
<p class="MsoNormal"> Core</p>
</div>
<div>
<p class="MsoNormal"> MC</p>
</div>
<div>
<p class="MsoNormal"> MCJIT</p>
</div>
<div>
<p class="MsoNormal"> Object</p>
</div>
<div>
<p class="MsoNormal"> OrcJIT</p>
</div>
<div>
<p class="MsoNormal"> Interpreter</p>
</div>
<div>
<p class="MsoNormal"> RuntimeDyld</p>
</div>
<div>
<p class="MsoNormal"> Coroutines</p>
</div>
<div>
<p class="MsoNormal"> IPO</p>
</div>
<div>
<p class="MsoNormal"> IRReader</p>
</div>
<div>
<p class="MsoNormal"> InstCombine</p>
</div>
<div>
<p class="MsoNormal"> Instrumentation</p>
</div>
<div>
<p class="MsoNormal"> MC</p>
</div>
<div>
<p class="MsoNormal"> ObjCARCOpts</p>
</div>
<div>
<p class="MsoNormal"> ScalarOpts</p>
</div>
<div>
<p class="MsoNormal"> Support</p>
</div>
<div>
<p class="MsoNormal"> Target</p>
</div>
<div>
<p class="MsoNormal"> TransformUtils</p>
</div>
<div>
<p class="MsoNormal"> Vectorize</p>
</div>
<div>
<p class="MsoNormal"> Passes</p>
</div>
<div>
<p class="MsoNormal"> ExecutionEngine</p>
</div>
<div>
<p class="MsoNormal"> )</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"># Support plugins.</p>
</div>
<div>
<p class="MsoNormal">set(LLVM_NO_DEAD_STRIP 1)</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">add_llvm_tool(opt</p>
</div>
<div>
<p class="MsoNormal"> AnalysisWrappers.cpp</p>
</div>
<div>
<p class="MsoNormal"> BreakpointPrinter.cpp</p>
</div>
<div>
<p class="MsoNormal"> Debugify.cpp</p>
</div>
<div>
<p class="MsoNormal"> GraphPrinters.cpp</p>
</div>
<div>
<p class="MsoNormal"> NewPMDriver.cpp</p>
</div>
<div>
<p class="MsoNormal"> PassPrinters.cpp</p>
</div>
<div>
<p class="MsoNormal"> PrintSCC.cpp</p>
</div>
<div>
<p class="MsoNormal"> opt.cpp</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> DEPENDS</p>
</div>
<div>
<p class="MsoNormal"> intrinsics_gen</p>
</div>
<div>
<p class="MsoNormal"> )</p>
</div>
<div>
<p class="MsoNormal">export_executable_symbols(opt)</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">if(WITH_POLLY AND
LINK_POLLY_INTO_TOOLS)</p>
</div>
<div>
<p class="MsoNormal">
target_link_libraries(opt PRIVATE Polly)</p>
</div>
<div>
<p class="MsoNormal">endif(WITH_POLLY AND
LINK_POLLY_INTO_TOOLS)</p>
</div>
<div>
<p class="MsoNormal">target_link_libraries(opt
PUBLIC LLVMExecutionEngine)</p>
</div>
</div>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">```</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">Modified opt's LLVMBuild.txt:</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">```</p>
</div>
<div>
<div>
<p class="MsoNormal">;===-
./tools/opt/LLVMBuild.txt
--------------------------------*- Conf
-*--===;</p>
</div>
<div>
<p class="MsoNormal">;</p>
</div>
<div>
<p class="MsoNormal">; The
LLVM Compiler Infrastructure</p>
</div>
<div>
<p class="MsoNormal">;</p>
</div>
<div>
<p class="MsoNormal">; This file is distributed
under the University of Illinois Open Source</p>
</div>
<div>
<p class="MsoNormal">; License. See LICENSE.TXT
for details.</p>
</div>
<div>
<p class="MsoNormal">;</p>
</div>
<div>
<p class="MsoNormal">;===------------------------------------------------------------------------===;</p>
</div>
<div>
<p class="MsoNormal">;</p>
</div>
<div>
<p class="MsoNormal">; This is an LLVMBuild
description file for the components in this
subdirectory.</p>
</div>
<div>
<p class="MsoNormal">;</p>
</div>
<div>
<p class="MsoNormal">; For more information on
the LLVMBuild system, please see:</p>
</div>
<div>
<p class="MsoNormal">;</p>
</div>
<div>
<p class="MsoNormal">; <a
class="gmail-m_6517503528706480469moz-txt-link-freetext"
href="http://llvm.org/docs/LLVMBuild.html"
target="_blank" moz-do-not-send="true">http://llvm.org/docs/LLVMBuild.html</a></p>
</div>
<div>
<p class="MsoNormal">;</p>
</div>
<div>
<p class="MsoNormal">;===------------------------------------------------------------------------===;</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">[component_0]</p>
</div>
<div>
<p class="MsoNormal">type = Tool</p>
</div>
<div>
<p class="MsoNormal">name = opt</p>
</div>
<div>
<p class="MsoNormal">parent = Tools</p>
</div>
<div>
<p class="MsoNormal">required_libraries =</p>
</div>
<div>
<p class="MsoNormal"> AsmParser</p>
</div>
<div>
<p class="MsoNormal"> BitReader</p>
</div>
<div>
<p class="MsoNormal"> BitWriter</p>
</div>
<div>
<p class="MsoNormal"> CodeGen</p>
</div>
<div>
<p class="MsoNormal"> IRReader</p>
</div>
<div>
<p class="MsoNormal"> IPO</p>
</div>
<div>
<p class="MsoNormal"> Instrumentation</p>
</div>
<div>
<p class="MsoNormal"> Scalar</p>
</div>
<div>
<p class="MsoNormal"> ObjCARC</p>
</div>
<div>
<p class="MsoNormal"> Passes</p>
</div>
<div>
<p class="MsoNormal"> ExecutionEngine</p>
</div>
<div>
<p class="MsoNormal"> Interpreter</p>
</div>
<div>
<p class="MsoNormal"> MCJIT</p>
</div>
<div>
<p class="MsoNormal"> Native</p>
</div>
<div>
<p class="MsoNormal"> NativeCodeGen</p>
</div>
<div>
<p class="MsoNormal"> all-targets</p>
</div>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">```</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">On top of that I also added
these lines to the beginning of main function in
opt.cpp to force linking ExecutionEngine:</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">```</p>
</div>
<div>
<div>
<p class="MsoNormal"> if(argc==-1){</p>
</div>
<div>
<p class="MsoNormal"> EngineBuilder eb;</p>
</div>
<div>
<p class="MsoNormal"> ExecutionEngine*
ee=eb.create();</p>
</div>
<div>
<p class="MsoNormal"> delete ee;</p>
</div>
<div>
<p class="MsoNormal"> }</p>
</div>
</div>
<div>
<p class="MsoNormal">```</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">as well as force linking
MCJIT and Interpreter by including headers in
opt:</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">```</p>
</div>
<div>
<div>
<p class="MsoNormal">#include
"llvm/ExecutionEngine/ExecutionEngine.h"</p>
</div>
<div>
<p class="MsoNormal">#include
"llvm/ExecutionEngine/Interpreter.h"</p>
</div>
<div>
<p class="MsoNormal">#include
"llvm/ExecutionEngine/MCJIT.h"</p>
</div>
</div>
<div>
<p class="MsoNormal">```</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">Moving
cl::parseCommandLineOptions doesn't seem to be
related to the issue, my previous assumption was
wrong.</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">Those modifications works at
least on my setup with the following output:</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">```</p>
</div>
<div>
<div>
<p class="MsoNormal">λ : >>> bin/opt
-load lib/LLVMHello.dylib hw.ll -hello</p>
</div>
<div>
<p class="MsoNormal">WARNING: You're attempting
to print out a bitcode file.</p>
</div>
<div>
<p class="MsoNormal">This is inadvisable as it
may cause display problems. If</p>
</div>
<div>
<p class="MsoNormal">you REALLY want to taste
LLVM bitcode first-hand, you</p>
</div>
<div>
<p class="MsoNormal">can force output with the
`-f' option.</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">Assertion failed: (M
&& "Module is null?"), function Init,
file
/Users/naville/Development/Hikari/lib/ExecutionEngine/ExecutionEngine.cpp,
line 80.</p>
</div>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">```</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">Which is due to i didn't
initialize the EEBuilder properly, but at least
the pass now loads and executes properly</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">Zhang</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<div>
<p class="MsoNormal"><span>------------------ Original ------------------</span></p>
</div>
<div>
<div
id="gmail-m_6517503528706480469menu_sender">
<p class="MsoNormal"
style="background:rgb(239,239,239)"><b><span
style="font-size:9pt;color:black">From:
</span></b><span
style="font-size:9pt;color:black"> "Zhang
via llvm-dev"<a
class="gmail-m_6517503528706480469moz-txt-link-rfc2396E"
href="mailto:llvm-dev@lists.llvm.org"
target="_blank" moz-do-not-send="true"><llvm-dev@lists.llvm.org></a>;</span></p>
</div>
<div>
<p class="MsoNormal"
style="background:rgb(239,239,239)"><b><span
style="font-size:9pt;color:black">Date:
</span></b><span
style="font-size:9pt;color:black"> Wed,
Apr 17, 2019 04:35 AM</span></p>
</div>
<div>
<p class="MsoNormal"
style="background:rgb(239,239,239)"><b><span
style="font-size:9pt;color:black">To:
</span></b><span
style="font-size:9pt;color:black"> "Viktor
Was BSc"<a
class="gmail-m_6517503528706480469moz-txt-link-rfc2396E"
href="mailto:gs15m015@technikum-wien.at" target="_blank"
moz-do-not-send="true"><gs15m015@technikum-wien.at></a>;
"llvm-dev"<a
class="gmail-m_6517503528706480469moz-txt-link-rfc2396E"
href="mailto:llvm-dev@lists.llvm.org"
target="_blank" moz-do-not-send="true"><llvm-dev@lists.llvm.org></a>;
</span></p>
</div>
<div>
<p class="MsoNormal"
style="background:rgb(239,239,239)"><b><span
style="font-size:9pt;color:black">Subject:
</span></b><span
style="font-size:9pt;color:black"> Re:
[llvm-dev] Opt plugin linkage</span></p>
</div>
</div>
<div>
<p class="MsoNormal"><span style="color:black"> </span></p>
</div>
<div>
<div>
<p class="MsoNormal"><span
style="color:black">Hey:</span></p>
</div>
<div>
<p class="MsoNormal"><span
style="color:black">I spent sometime
debugging this, it seems like editing
``llvm/tools/opt.cpp`` and move
``cl::ParseCommandLineOptions(argc,
argv,</span></p>
</div>
<div>
<p class="MsoNormal"><span
style="color:black"> "llvm .bc ->
.bc modular optimizer and analysis
printer\n");`` to the beginning of
main() solved it for me. I'm not sure if
this is a bug on LLVM side</span></p>
</div>
<div>
<p class="MsoNormal"><span
style="color:black"> </span></p>
</div>
<div>
<p class="MsoNormal"><span
style="color:black"> </span></p>
</div>
<div>
<p class="MsoNormal"><span
style="color:black">Zhang</span></p>
</div>
<div>
<div>
<p class="MsoNormal"><span
style="color:black"> </span></p>
</div>
<div>
<p class="MsoNormal"><span
style="color:black"> </span></p>
</div>
<div>
<div>
<p class="MsoNormal"><span>------------------
Original ------------------</span></p>
</div>
<div>
<div
id="gmail-m_6517503528706480469menu_sender">
<p class="MsoNormal"
style="background:rgb(239,239,239)"><b><span
style="font-size:9pt;color:black">From: </span></b><span
style="font-size:9pt;color:black"> "Viktor
Was BSc via llvm-dev"<a
class="gmail-m_6517503528706480469moz-txt-link-rfc2396E"
href="mailto:llvm-dev@lists.llvm.org" target="_blank"
moz-do-not-send="true"><llvm-dev@lists.llvm.org></a>;</span></p>
</div>
<div>
<p class="MsoNormal"
style="background:rgb(239,239,239)"><b><span
style="font-size:9pt;color:black">Date: </span></b><span
style="font-size:9pt;color:black"> Wed,
Apr 17, 2019 03:09 AM</span></p>
</div>
<div>
<p class="MsoNormal"
style="background:rgb(239,239,239)"><b><span
style="font-size:9pt;color:black">To: </span></b><span
style="font-size:9pt;color:black"> "llvm-dev"<a
class="gmail-m_6517503528706480469moz-txt-link-rfc2396E"
href="mailto:llvm-dev@lists.llvm.org"
target="_blank"
moz-do-not-send="true"><llvm-dev@lists.llvm.org></a>;
</span></p>
</div>
<div>
<p class="MsoNormal"
style="background:rgb(239,239,239)"><b><span
style="font-size:9pt;color:black">Subject: </span></b><span
style="font-size:9pt;color:black"> Re:
[llvm-dev] Opt plugin linkage</span></p>
</div>
</div>
<div>
<p class="MsoNormal"><span
style="color:black"> </span></p>
</div>
<div>
<div>
<p class="MsoNormal"><span
style="color:black">How come the
hello pass example is so totally
useless as a starting point? Why
is this not using any
library/compontent which could
conflict with opt or clang and
showing how to handle this? I have
no clue as to how I have to setup
llvm to get this to work or why it
doesn't work in the first place
with the setup described in
"Getting started" and "writing an
llvm pass" pages etc. </span></p>
</div>
<div>
<p class="MsoNormal"
style="margin-bottom:12pt"><span
style="color:black">Also there is
basically no documentation for the
custom cmake commands. </span></p>
</div>
<div>
<p class="MsoNormal"
style="margin-bottom:12pt"><span
style="color:black">Can please
somebody help me with this issue?
How do I get dynamically loaded
llvm pass plugins to work? Am I
the only one ever having this
issue? </span></p>
</div>
<div>
<p class="MsoNormal"><span
style="color:black">Thanks </span></p>
</div>
<div>
<p class="MsoNormal"><span
style="color:black">Viktor </span></p>
</div>
<div>
<p class="MsoNormal"><span
style="color:black">On Apr 16,
2019, at 05:38, Viktor Was BSc via
llvm-dev <<a
href="mailto:llvm-dev@lists.llvm.org"
target="_blank"
moz-do-not-send="true">llvm-dev@lists.llvm.org</a>>
wrote:</span></p>
<div>
<p class="MsoNormal"><span
style="color:black">Hi,</span></p>
</div>
<div>
<p class="MsoNormal"><span
style="color:black">I have a
dynamically loaded llvm pass
built in-tree with ninja
(generated with cmake, basically
a copy of the hallo pass plugin,
linux, llvm/clang version
6.0.1).</span></p>
</div>
<div>
<p class="MsoNormal"><span
style="color:black">It uses the
ExecutionEngine.</span></p>
</div>
<div>
<p class="MsoNormal"><span
style="color:black">Building it
without linking against
LLVMExecutionEngine library
results in an undefined symbol
to the vtable of the
EngineBuilder when loaded to
opt. Linking the plugin with
LLVMExecutionEngine results in
the pass simply not being
executable with giving "opt:
Unkown command line argument
'-passArg'." </span></p>
</div>
<div>
<p class="MsoNormal"
style="margin-bottom:12pt"><span
style="color:black">For a
minimal example add
set(LLVM_LINK_COMPONENTS Core)
to the CMakeLists.txt of the
Hello llvm pass. </span></p>
</div>
<div>
<p class="MsoNormal"><span
style="color:black">There is no
error or warning at any point
when linking or loading a plugin
linked against some libs. </span></p>
</div>
<div>
<p class="MsoNormal"><span
style="color:black">How do I
find out which llvm libs I can't
link with a dynamically loaded
plugin?</span></p>
</div>
<div>
<p class="MsoNormal"
style="margin-bottom:12pt"><span
style="color:black">How can I
use the EngineBuilder in my
plugin with proper symbol
resolution?</span></p>
</div>
<div>
<p class="MsoNormal"><span
style="color:black">For
reproductivity:</span></p>
</div>
<div>
<p class="MsoNormal"
style="margin-bottom:12pt"><span
style="color:black">cmake -G
"Sublime Text 2 - Ninja"
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
-DLLVM_EXPORT_SYMBOLS_FOR_PLUGINS=ON -DLLVM_BUILD_TESTS=ON
-DLLVM_BUILD_EXAMPLES=ON
-DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra"
-DLLVM_TOOL_CLANG_BUILD=ON
-DLLVM_TOOL_CLANG_TOOLS_EXTRA=ON
-DLLVM_OPTIMIZED_TABLEGEN=ON
-DCLANG_BUILD_EXAMPLES=ON
-DCLANG_PLUGIN_SUPPORT=ON</span></p>
</div>
<div>
<p class="MsoNormal"><span
style="color:black">Hope someone
can help me out.</span></p>
</div>
<div>
<p class="MsoNormal"><span
style="color:black">Viktor</span></p>
</div>
<pre style="text-align:center"><span style="color:black"><hr width="100%" size="2" align="center"></span></pre>
<pre><span style="color:black">
LLVM Developers mailing list
<a class="gmail-m_6517503528706480469moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org" target="_blank" moz-do-not-send="true">llvm-dev@lists.llvm.org</a>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank" moz-do-not-send="true">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a></span></pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank"
moz-do-not-send="true">llvm-dev@lists.llvm.org</a><br>
<a
href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev"
rel="noreferrer" target="_blank" moz-do-not-send="true">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote>
</div>
</div>
</blockquote>
</body>
</html>