Trying to run clang example

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Trying to run clang example

Sergey Martynov
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


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Trying to run clang example

Anton Korobeynikov
> Please advice me how can I resolve this issue.
You linked LLVM twice: into your dylib and into clang.

--
With best regards, Anton Korobeynikov
Faculty of Mathematics and Mechanics, Saint Petersburg State University
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Trying to run clang example

Sergey Martynov
How can I disable linking with LLVM?
I tough -shared option tell compiler to link dynamically with libraries.
If I remove --libs from llvm-config then compiler can not find required symbols.
And I don't know other ways to skip linking.

How it done in LLVM?

On Tue, Oct 5, 2010 at 18:21, Anton Korobeynikov <[hidden email]> wrote:
> Please advice me how can I resolve this issue.
You linked LLVM twice: into your dylib and into clang.

--
With best regards, Anton Korobeynikov
Faculty of Mathematics and Mechanics, Saint Petersburg State University



--
With best wishes,
Sergey Martynov
Tel: +7 921 342 58 54
E-mail: [hidden email]
Skype: martynov.sergey


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev