On Tue, Jan 3, 2012 at 12:42 AM, Duncan Sands <span dir="ltr"><<a href="mailto:baldrick@free.fr">baldrick@free.fr</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Hi Talin,<br>
<div class="im"><br>
> After a several-month hiatus, I've returned to working on my main LLVM project.<br>
> However, after checking out the latest LLVM head I'm encountering a new problem.<br>
> When I attempt to load my custom plugin pass into opt, I'm getting this error<br>
> message:<br>
><br>
> dyld: lazy symbol binding failed: Symbol not found:<br>
> __ZN4llvm2cl3optIbLb0ENS0_6parserIbEEE4doneEv<br>
>    Referenced from: /Users/talin/Projects/tart/build-eclipse/linker/libgc.dylib<br>
>    Expected in: flat namespace<br>
<br>
</div>are you sure you built opt and your plugin using the same LLVM build?  You can<br>
get this kind of thing if (eg) opt is from a Release build, but your plugin was<br>
built against a Debug build.<br>
<br></blockquote><div>Ah, that would explain it. You see, I normally link against the debug version 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.</div>

<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Ciao, Duncan.<br>
<div class="im"><br>
> It appears to be due to the fact that I'm using LLVM's command-line functions<br>
> from within my plugin:<br>
><br>
>     cl::opt<bool> optShowGC("show-gc", cl::desc("Print debugging output from GC<br>
>     strategy"));<br>
><br>
> (when I remove the option from the source, everything works fine.)<br>
><br>
> Now, I recognize the 'flat namespace' phrase from my build file, which passes<br>
> "-Wl -flat_namespace -Wl -undefined -Wl suppress" to the linker when building<br>
> the plugin. I remember that someone gave me this magic formula (or perhaps I got<br>
> it off a search result) - I certainly don't understand what it means. I remember<br>
> it had to do with creating the plugin in such a way as to resolve undefined<br>
> symbols against the main program when loaded, instead of giving an error for<br>
> each undefined symbol. (This appears to be specific to OS X, the linker on Linux<br>
> doesn't require these flags.)<br>
><br>
> A more general question is this - I've never really found a good reference or<br>
> tutorial for building plugin libraries, in particular the kinds used with LLVM.<br>
> I don't expect LLVM's docs to teach me how to compile and link a shared library,<br>
> but it seems like there's a fair amount of non-obvious esoterica involved here,<br>
> and it would be nice to have a pointer to some doc that would make it all less<br>
> mysterious :)<br>
><br>
> --<br>
> -- Talin<br>
><br>
><br>
</div>> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>-- Talin<br>