[llvm-dev] Opt plugin linkage
Zhang via llvm-dev
llvm-dev at lists.llvm.org
Tue Apr 16 13:35:53 PDT 2019
I spent sometime debugging this, it seems like editing ``llvm/tools/opt.cpp`` and move ``cl::ParseCommandLineOptions(argc, argv,
"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
------------------ Original ------------------
From: "Viktor Was BSc via llvm-dev"<llvm-dev at lists.llvm.org>;
Date: Wed, Apr 17, 2019 03:09 AM
To: "llvm-dev"<llvm-dev at lists.llvm.org>;
Subject: Re: [llvm-dev] Opt plugin linkage
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.
Also there is basically no documentation for the custom cmake commands.
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?
On Apr 16, 2019, at 05:38, Viktor Was BSc via llvm-dev <llvm-dev at lists.llvm.org> wrote: Hi,
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).
It uses the ExecutionEngine.
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'."
For a minimal example add set(LLVM_LINK_COMPONENTS Core) to the CMakeLists.txt of the Hello llvm pass.
There is no error or warning at any point when linking or loading a plugin linked against some libs.
How do I find out which llvm libs I can't link with a dynamically loaded plugin?
How can I use the EngineBuilder in my plugin with proper symbol resolution?
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
Hope someone can help me out.
LLVM Developers mailing list
llvm-dev at lists.llvm.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev