Zhang
> _______________________________________________
> LLVM Developers mailing list
> llvm...@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
The fundamental problem here is that opt doesn’t use ExecutionEngine (because it has no need to), so trying
to use ExecutionEngine (or any other bit of llvm that opt doesn’t use for that matter) in an opt plugin isn’t
going to work.
The solution I’d go with would be to build llvm with shared libraries (use –DBUILD_SHARED_LIBS=ON on the
cmake command) then link the plugin against ExecutionEngine. That shouldn’t require any changes anywhere
(when I gave it a quick try it seemed to work).
John
Hi John,
Thanks for the suggestion, will definitely try it out, seems like
the cleanest and least invasive way to do this.
Though, I feel like this should also be possible with statically linking the ExecutionEngine into the plugin shared object.
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.
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.
Thanks,
Viktor
Though, I feel like this should also be possible with statically linking the ExecutionEngine into the plugin shared object.
_______________________________________________
Hi Philip,
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?
Cheers,
Viktor