Talin
2012-Jan-03 02:50 UTC
[LLVMdev] Using llvm command line functions from within a plugin?
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>
Duncan Sands
2012-Jan-03 08:42 UTC
[LLVMdev] Using llvm command line functions from within a plugin?
Hi Talin,> 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 namespaceare you sure you built opt and your plugin using the same LLVM build? You can get this kind of thing if (eg) opt is from a Release build, but your plugin was built against a Debug build. Ciao, Duncan.> 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 > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Talin
2012-Jan-04 08:26 UTC
[LLVMdev] Using llvm command line functions from within a plugin?
On Tue, Jan 3, 2012 at 12:42 AM, Duncan Sands <baldrick at free.fr> wrote:> Hi Talin, > > > 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 > > are you sure you built opt and your plugin using the same LLVM build? You > can > get this kind of thing if (eg) opt is from a Release build, but your > plugin was > built against a Debug build. > > Ah, that would explain it. You see, I normally link against the debugversion of LLVM, but because opt, llc, and clang are quite slow in debug builds I generally copy just those three programs over to the install dir's 'bin' directory. This cuts my overall project build time by about 2/3. I didn't realize that would be a problem.> Ciao, Duncan. > > > 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 > > > > > > _______________________________________________ > > LLVM Developers mailing list > > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-- -- Talin -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120104/915d9b12/attachment.html>