New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sample clang plugin crashes #7173
Comments
This appears to be broken by r100249. |
Ok, I'll take a look at this. |
How do I build the example if I've built clang with objdir != srcdir? |
You can turn on the CLANG_BUILD_EXAMPLES cmake option to build the clang examples: from tools/clang/CMakeLists.txt: option(CLANG_BUILD_EXAMPLES "Build CLANG example programs." OFF) |
How do I do this with the non-cmake build? |
The problem is that the static registrators are statically linked into both llvm itself and the plugin... when you load the plugin the options collide as they're registered for the second time. Just don't link to all those libs: Index: CMakeLists.txt--- CMakeLists.txt (revision 104780) set(LLVM_NO_RTTI 1) -set(LLVM_USED_LIBS
-set( LLVM_LINK_COMPONENTS
add_clang_library(PrintFunctionNames PrintFunctionNames.cpp) set_target_properties(PrintFunctionNames |
Oh, also you want set_target_properties(PrintFunctionNames (note the PREFIX bit) so that PrintFunctionNames.so, not libPrintFunctionNames.so gets built... this way it matches the docs. |
I've committed Troy's fixes for the CMake build system here: http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20100607/031065.html along with tweaks to make it work properly on Darwin. These changes still need to be replicated in the make-based build system. |
Last comment indicates this was fixed, except for the since removed make build |
Extended Description
Build the PrintFunctionNames sample plugin in tools/clang/examples/PrintFunctionNames/, then run:
$ clang -cc1 -load path/to/PrintFunctionNames.so -plugin print-fns t.cc
where t.cc has content:
int f() {
return 1;
}
and clang will crash:
Two passes with the same argument (-preverify) attempted to be registered!
UNREACHABLE executed at include/llvm/Support/PassNameParser.h:74!
0 clang 0x00000000012975ce
1 clang 0x00000000012974b5
2 libpthread.so.0 0x00007f9a507e3580
3 libc.so.6 0x00007f9a4ff98da5 gsignal + 53
4 libc.so.6 0x00007f9a4ff9a750 abort + 272
5 clang 0x00000000012bd928 llvm::FoldingSetNodeID::AddPointer(void const*) + 0
6 clang 0x0000000001213bb1 llvm::PassNameParser::passRegistered(llvm::PassInfo const*) + 229
7 clang 0x0000000001211c36 llvm::PassInfo::registerPass() + 140
8 clang 0x0000000000aecde3 llvm::PassInfo::PassInfo(char const*, char const*, long, llvm::Pass* (*)(), bool, bool) + 145
9 PrintFunctionNames.so 0x00007f9a4ef3b965
10 PrintFunctionNames.so 0x00007f9a4ef3c99a
11 PrintFunctionNames.so 0x00007f9a4ef3cb19
12 PrintFunctionNames.so 0x00007f9a4ef9ae36
Stack dump:
0. Program arguments: clang -cc1 -load path/to/PrintFunctionNames.so -plugin print-fns t.cc
Aborted
The text was updated successfully, but these errors were encountered: