[cfe-dev] Trying to run clang example

Sergey Martynov martynovs at gmail.com
Tue Oct 5 06:40:41 PDT 2010


Hi all,

I'm trying to compile and run PrintFunctionNames example,
here is build file that I use:
-----------
#!/bin/bash

EXAMPLE=PrintFunctionNames

CLANG_MODULES=( AST Analysis Basic Checker CodeGen Driver Frontend
FrontendTool Index Lex Parse Rewrite Sema Serialization )
for mod in ${CLANG_MODULES[@]}
do
  CLANG_LIBS="-lclang$mod $CLANG_LIBS"
done

g++ `llvm-config --cxxflags` -c $EXAMPLE.cpp \
&&
g++ `llvm-config --ldflags --libs` $CLANG_LIBS -shared -o lib$EXAMPLE.dylib
$EXAMPLE.o

rm $EXAMPLE.o
-----------

But when I'm trying to execute clang with this plugin it crashes with
assert:
-----------
Assertion failed: (Inserted && "Pass registered multiple times!"), function
registerPass, file PassRegistry.cpp, line 101.
0  clang                       0x00000001011ba593 PrintStackTrace(void*) +
38
1  clang                       0x00000001011bab4e SignalHandler(int) + 254
2  libSystem.B.dylib           0x00007fff86d2635a _sigtramp + 26
3  libSystem.B.dylib           0x00007fff5fc404a0 _sigtramp + 3639714144
4  clang                       0x0000000100027a71 raise + 29
5  clang                       0x0000000100027a81 abort + 14
6  clang                       0x0000000100027b0e
__gnu_cxx::new_allocator<std::pair<void (*)(void*), void*>
>::new_allocator() + 0
7  clang                       0x0000000100021c53
llvm::PassRegistry::registerPass(llvm::PassInfo const&) + 183
8  clang                       0x000000010001bcbd
llvm::PassInfo::PassInfo(char const*, char const*, void const*, llvm::Pass*
(*)(), bool, bool) + 169
9  clang                       0x000000010001ffdf
llvm::RegisterPass<llvm::DominatorTree>::RegisterPass(char const*, char
const*, bool, bool) + 83
10 libPrintFunctionNames.dylib 0x000000010580185b
__static_initialization_and_destruction_0(int, int) + 157
11 libPrintFunctionNames.dylib 0x00000001058018c5 global constructors keyed
to _ZN4llvm13DominatorTree2IDE + 19
12 libPrintFunctionNames.dylib 0x00007fff5fc0d500 global constructors keyed
to _ZN4llvm13DominatorTree2IDE + 1514191950
13 libPrintFunctionNames.dylib 0x00007fff5fc0bcec global constructors keyed
to _ZN4llvm13DominatorTree2IDE + 1514185786
14 libPrintFunctionNames.dylib 0x00007fff5fc0bda6 global constructors keyed
to _ZN4llvm13DominatorTree2IDE + 1514185972
15 libPrintFunctionNames.dylib 0x00007fff5fc08fbb global constructors keyed
to _ZN4llvm13DominatorTree2IDE + 1514174217
16 libSystem.B.dylib           0x00007fff86ccc2c0 dlopen + 61
17 clang                       0x00000001011b0457
llvm::sys::DynamicLibrary::LoadLibraryPermanently(char const*, std::string*)
+ 33
18 clang                       0x0000000100032c12
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 508
19 clang                       0x00000001000288a3 cc1_main(char const**,
char const**, char const*, void*) + 879
20 clang                       0x000000010002fda6 main + 450
21 clang                       0x0000000100028138 start + 52
Stack dump:
0. Program arguments: clang -cc1 -load libPrintFunctionNames.dylib -plugin
print-fns PrintFunctionNames.cpp
Illegal instruction
-----------

clang is compiled from svn:
clang version 2.9 (trunk 115408)
Target: x86_64-apple-darwin10
Thread model: posix

This example is working when I compile it using provided Makefile, so the
problem is in my build script.
But I don't want to use default Makefile because in this way plugin should
be located inside clang source tree.

Please advice me how can I resolve this issue.

Thank you.

------
With best wishes,
Sergey Martynov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20101005/3e5d389d/attachment.html>


More information about the cfe-dev mailing list