[LLVMdev] Using llvm command line functions from within a plugin?
Talin
viridia at gmail.com
Mon Jan 2 18:50:42 PST 2012
After a several-month hiatus, I've returned to working on my main LLVM
project. However, after checking out the latest LLVM head I'm encountering
a new problem. When I attempt to load my custom plugin pass into opt, I'm
getting this error message:
dyld: lazy symbol binding failed: Symbol not found:
__ZN4llvm2cl3optIbLb0ENS0_6parserIbEEE4doneEv
Referenced from:
/Users/talin/Projects/tart/build-eclipse/linker/libgc.dylib
Expected in: flat namespace
It appears to be due to the fact that I'm using LLVM's command-line
functions from within my plugin:
cl::opt<bool> optShowGC("show-gc", cl::desc("Print debugging output from GC
strategy"));
(when I remove the option from the source, everything works fine.)
Now, I recognize the 'flat namespace' phrase from my build file, which
passes "-Wl -flat_namespace -Wl -undefined -Wl suppress" to the linker when
building the plugin. I remember that someone gave me this magic formula (or
perhaps I got it off a search result) - I certainly don't understand what
it means. I remember it had to do with creating the plugin in such a way as
to resolve undefined symbols against the main program when loaded, instead
of giving an error for each undefined symbol. (This appears to be specific
to OS X, the linker on Linux doesn't require these flags.)
A more general question is this - I've never really found a good reference
or tutorial for building plugin libraries, in particular the kinds used
with LLVM. I don't expect LLVM's docs to teach me how to compile and link a
shared library, but it seems like there's a fair amount of non-obvious
esoterica involved here, and it would be nice to have a pointer to some doc
that would make it all less mysterious :)
--
-- Talin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120102/9e78c7af/attachment.html>
More information about the llvm-dev
mailing list