Hi, I'm making my way through the WritingAnLLVMPass tutorial and hitting the following issue. $ opt -load ../../../Debug+Asserts/lib/LLVMHello.so -hello < hello.bc > /dev/null opt: symbol lookup error: ../../../Debug+Asserts/lib/LLVMHello.so: undefined symbol: AnnotateHappensAfter nm -g ../../../Debug+Asserts/lib/LLVMHello.so U AnnotateHappensAfter ... $ ldd ../../../Debug+Asserts/lib/LLVMHello.so linux-vdso.so.1 => (0x00007fffa87fe000) libz.so.1 => /lib64/libz.so.1 (0x00007f21b409e000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f21b3e80000) libtinfo.so.5 => /lib64/libtinfo.so.5 (0x00007f21b3c56000) libdl.so.2 => /lib64/libdl.so.2 (0x00007f21b3a52000) libm.so.6 => /lib64/libm.so.6 (0x00007f21b374a000) libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f21b3442000) libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f21b322c000) libc.so.6 => /lib64/libc.so.6 (0x00007f21b2e6c000) /lib64/ld-linux-x86-64.so.2 (0x0000003baaa00000) Am I not linking against some library I should have? Thanks, Akhi -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140709/da78c50c/attachment.html>
On 7/9/14, 1:56 AM, Akhi Singhania wrote:> Hi, > > I'm making my way through the WritingAnLLVMPass tutorial and hitting > the following issue. > > $ opt -load ../../../Debug+Asserts/lib/LLVMHello.so -hello < hello.bc > > /dev/null > opt: symbol lookup error: ../../../Debug+Asserts/lib/LLVMHello.so: > undefined symbol: AnnotateHappensAfterIf AnnotateHappensAfter is from one of the LLVM libraries, then you must make sure your pass links with that library. When you find the library that AnnotateHappensAfter lives in, be sure that library is included in the LINK_COMPONENTS or USED_LIBS variable in your Makefile. That's what I suspect the problem is, anyway. Regards, John Criswell> > nm -g ../../../Debug+Asserts/lib/LLVMHello.so > U AnnotateHappensAfter > ... > > $ ldd ../../../Debug+Asserts/lib/LLVMHello.so > linux-vdso.so.1 => (0x00007fffa87fe000) > libz.so.1 => /lib64/libz.so.1 (0x00007f21b409e000) > libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f21b3e80000) > libtinfo.so.5 => /lib64/libtinfo.so.5 (0x00007f21b3c56000) > libdl.so.2 => /lib64/libdl.so.2 (0x00007f21b3a52000) > libm.so.6 => /lib64/libm.so.6 (0x00007f21b374a000) > libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f21b3442000) > libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f21b322c000) > libc.so.6 => /lib64/libc.so.6 (0x00007f21b2e6c000) > /lib64/ld-linux-x86-64.so.2 (0x0000003baaa00000) > > Am I not linking against some library I should have? > > Thanks, > Akhi > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140709/5aa18c76/attachment.html>
Hi John, Thanks for the hints! After some grep and nm magic, it seems like I had to do the following: - Run configure in the root directory - Run make in ./lib/Support - Add 'USEDLIBS = LLVMSupport.a' in the Hello Makefile Now, I see: $ opt -load ../../../Debug+Asserts/lib/LLVMHello.so -hello < hello.bc > /dev/null Hello: main Another workaround was to turn off thread support by setting LLVM_ENABLE_THREADS to 0 in llvm-config.h. Not sure what the implications of this are though. I detail the changes needed above so that the llvm maintainers can consider updating the tutorial. As another side, the tutorial suggests that the output of opt command above will be following: $ opt -load ../../../Debug+Asserts/lib/Hello.so -hello < hello.bc > /dev/null Hello: __main Hello: puts Hello: main But hello.bc defines just one function: main so I see a different output. Another update that can be considered for the tutorial. Thanks, Akhi On 9 July 2014 16:57, John Criswell <jtcriswel at gmail.com> wrote:> On 7/9/14, 1:56 AM, Akhi Singhania wrote: > > Hi, > > I'm making my way through the WritingAnLLVMPass tutorial and hitting the > following issue. > > $ opt -load ../../../Debug+Asserts/lib/LLVMHello.so -hello < hello.bc > > /dev/null > opt: symbol lookup error: ../../../Debug+Asserts/lib/LLVMHello.so: > undefined symbol: AnnotateHappensAfter > > > If AnnotateHappensAfter is from one of the LLVM libraries, then you must > make sure your pass links with that library. When you find the library > that AnnotateHappensAfter lives in, be sure that library is included in the > LINK_COMPONENTS or USED_LIBS variable in your Makefile. > > That's what I suspect the problem is, anyway. > > Regards, > > John Criswell > > > nm -g ../../../Debug+Asserts/lib/LLVMHello.so > U AnnotateHappensAfter > ... > > $ ldd ../../../Debug+Asserts/lib/LLVMHello.so > linux-vdso.so.1 => (0x00007fffa87fe000) > libz.so.1 => /lib64/libz.so.1 (0x00007f21b409e000) > libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f21b3e80000) > libtinfo.so.5 => /lib64/libtinfo.so.5 (0x00007f21b3c56000) > libdl.so.2 => /lib64/libdl.so.2 (0x00007f21b3a52000) > libm.so.6 => /lib64/libm.so.6 (0x00007f21b374a000) > libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f21b3442000) > libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f21b322c000) > libc.so.6 => /lib64/libc.so.6 (0x00007f21b2e6c000) > /lib64/ld-linux-x86-64.so.2 (0x0000003baaa00000) > > Am I not linking against some library I should have? > > Thanks, > Akhi > > > _______________________________________________ > LLVM Developers mailing listLLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.eduhttp://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140709/d576b263/attachment.html>