[LLVMdev] Issues with flag namespace

Cristianno Martins cristiannomartins at gmail.com
Wed Mar 21 06:26:13 PDT 2012


Hello Dmitry, 

First of all, thank you for your reply. Because of it, I focused in create the lib that helped me.

Second, I realize that actually there was one thing different between the machines: due to a more frequent use of the iMac, I have a group of environment variables that are set to my developer folder; and the $PATH is one of those.

Furthermore, it seems that my default compiler for OSX (llvm-gcc 4.2.1) is not able to link opt when the --enable-shared flag is used for configure, but the latest version of clang + llvm (both from the git repo) is. So, if I compile a release version of clang+llvm, and use this version to compile my development version (Debug+Asserts and with shared enabled), I can generate the libLLVM-3.1svn.dylib. Finally, I was able to run MyPass when importing this lib.

Oh, and just for the record, the default behavior in OSX for the linker seems to be the same as Linux with the flag rdynamic on =)

Thanks again, 

-- 
Cristianno Martins
PhD Student of Computer Science
University of Campinas
cmartins at ic.unicamp.br


On Tuesday, 20 de March de 2012 at 14:08, Dmitry N. Mikushin wrote:

> Hi Cristianno,
> 
> I never worked with Mac, but maybe some general insight below still
> might be helpful. First of all, this error
> 
> > Symbol not found: __ZN4llvm17DominatorTreeBaseINS_10BasicBlockEEC1Eb
> > Referenced from:
> > /Users/cmartins/Developer/llvm/Debug+Asserts/lib/mypass.dylib
> > 
> 
> 
> says something like "dlopen loaded the symbol from you dynamic
> library, but this symbol in turn depends on some other function, which
> is not available in this particular library or libraries it refers
> to".
> 
> To my understanding, in Linux this may happen in two cases. First,
> your shared library was not linked against its dependencies
> (DominatorTreeBase is something in standard llvm passes, right? = then
> try to link -lLLVM-3.1svn when building mypass.dylib). Second, in
> Linux there is a special link-time flag "-rdynamic" that allows
> lazily-loaded dynamic library to successfully resolve its dependency,
> if the parent application has already resolved the same dependency.
> 
> - D.
> 
> 2012/3/20 Cristianno Martins <cristiannomartins at gmail.com (mailto:cristiannomartins at gmail.com)>:
> > Hello everyone,
> > 
> > I'm trying to create a plugin as a dynamic loadable library for opt.
> > Therefore, I'm facing some interesting issues.
> > First, I'm running OS X Lion, and i686-apple-darwin11-llvm-gcc-4.2 (GCC
> > 4.2.1) as my default compiler. Basically, I'm creating a
> > DominatorTree<BasicBlock> directly as an attribute from one of my classes.
> > Curiously, I'm encountering some kind of error related to "flat namespace"
> > (the dump from this error can be seen below).
> > 
> > Well, I have already found some emails in this list about some similar
> > problems, but here comes the curious part: I "fixed" this problem in my iMac
> > (omitting the -flat-namespace flag on Makefile.rules, and using "./configure
> > && make"), where now I'm capable of load and execute my pass, but the issue
> > still persists when running on my MacBook (one important detail is that the
> > environment is fundamentally the same -- same OS version, same compilers
> > infrastructure, same code being compiled).
> > 
> > I've already tried to use --enable-shared as an argument for the configure
> > script, but I get an even worse problem here: somehow the opt executable
> > could not be linked (and this happens in both cases: with or without the
> > -flat-namespace flag).
> > 
> > Is there someone who faced this problem before? Or could I be doing
> > something wrong?
> > 
> > Thanks in advance,
> > 
> > --
> > Cristianno Martins
> > PhD Student of Computer Science
> > University of Campinas
> > cmartins at ic.unicamp.br (mailto:cmartins at ic.unicamp.br)
> > 
> > 
> > dyld: lazy symbol binding failed: Symbol not found:
> > __ZN4llvm17DominatorTreeBaseINS_10BasicBlockEEC1Eb
> >   Referenced from:
> > /Users/cmartins/Developer/llvm/Debug+Asserts/lib/mypass.dylib
> >   Expected in: flat namespace
> > 
> > dyld: Symbol not found: __ZN4llvm17DominatorTreeBaseINS_10BasicBlockEEC1Eb
> >   Referenced from:
> > /Users/cmartins/Developer/llvm/Debug+Asserts/lib/mypass.dylib
> >   Expected in: flat namespace
> > 
> > 0  opt               0x0000000108680cb5 _ZL15PrintStackTracePv + 53
> > 1  opt               0x0000000108681329 _ZL13SignalHandleri + 361
> > 2  libsystem_c.dylib 0x00007fff8c883cfa _sigtramp + 26
> > 3  libsystem_c.dylib 0x00007fff67b6f208 _sigtramp + 18446744073091855656
> > 4  libsystem_c.dylib 0x00007fff67b75948 _sigtramp + 18446744073091882088
> > 5  libdyld.dylib     0x00007fff9507b716 dyld_stub_binder_ + 13
> > 6  mypass.dylib        0x0000000109613040 global constructors keyed to a +
> > 27056
> > 7  mypass.dylib        0x00000001096027c5 (anonymous
> > namespace)::LDSCC::LDSCC(llvm::Loop*, llvm::PostDominatorTree*) + 37
> > 8  mypass.dylib        0x0000000109601873 (anonymous
> > namespace)::MyPass::runOnLoop(llvm::Loop*, llvm::LPPassManager&) + 531
> > 9  opt               0x00000001082f44a6
> > llvm::LPPassManager::runOnFunction(llvm::Function&) + 1254
> > 10 opt               0x00000001085e2561
> > llvm::FPPassManager::runOnFunction(llvm::Function&) + 497
> > 11 opt               0x00000001085e28cd
> > llvm::FPPassManager::runOnModule(llvm::Module&) + 125
> > 12 opt               0x00000001085e2b52
> > llvm::MPPassManager::runOnModule(llvm::Module&) + 546
> > 13 opt               0x00000001085e32ac
> > llvm::PassManagerImpl::run(llvm::Module&) + 172
> > 14 opt               0x00000001085e34e1
> > llvm::PassManager::run(llvm::Module&) + 33
> > 15 opt               0x0000000107f8321f main + 6975
> > 16 opt               0x0000000107f719d4 start + 52
> > 17 opt               0x0000000000000006 start + 18446744069280949862
> > Stack dump:
> > 0. Program arguments: ../llvm/Debug+Asserts/bin/opt -load
> > ../llvm/Debug+Asserts/lib/mypass.dylib -mypass -debug main.bc
> > 1. Running pass 'Function Pass Manager' on module 'main.bc'.
> > 2. Running pass 'Loop Pass Manager' on function '@main'
> > 3. Running pass 'MyPass Pass' on basic block '%while.cond'
> > Segmentation fault: 11
> > 
> > 
> > 
> > _______________________________________________
> > 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/20120321/7e2ff323/attachment.html>


More information about the llvm-dev mailing list