[LLVMdev] Weird behavior of llvm-ld

Bram Adams bram.adams at ugent.be
Wed Aug 16 13:41:14 PDT 2006


Op 16-aug-06, om 18:59 heeft Reid Spencer het volgende geschreven:

>> llvm-ld: warning: Supposed library 'SOME_OTHER_LIB' isn't a library.
> The -l option is used to link libraries into the resulting executable.
> I'm hoping "SOME_OTHER_LIB" is not the actual name and you're just
> paraphrasing the actual command line. Note that native libraries  
> are not
> supported by llvm-ld at this time. It is expecting a bytecode library
> that it can link into the program, hence the warning.

Are there any workarounds (using other LLVM-tools) to link a native  
library with LLVM-bytecode?

> The -l option is used to specify a library to be linked with, not for
> dependent symbols your loadable module requires. The loaded module  
> must
> be fully linked with all libraries it depends on.  So, no, your usage
> isn't correct here.


>>       * What's the meaning of RunOptimizations? This name is only
>>         mentioned in the code snippet above and in the llvm-ld docs,
>>         but nowhere else. Both opt1.so and opt2.so do show up using
>>         opt, so it seems there is some incompatibility between opt  
>> and
>>         llvm-ld. llvm-link apparently offers no alternative.
> Yes, there is. The opt tool can run into symbol redefinition and
> undefined references using its current mechanism of simply using  
> static
> constructors to define the passes to be run. llvm-ld takes a different
> approach: it defines an interface function (RunOptimizations) that is
> called by llvm-ld to transform the module. This gives the  
> implementer of
> the loaded module much more latitude in how the module is transformed.
> Since the PassManager is passed to the RunOptimizations function as  
> the
> first argument, that function can alter the PassManager in any way it
> pleases. Generally, it will add its own passes to the PassManager  
> which
> will then be run (later) by llvm-ld.

That's interesting! So, one only needs to add a 2-arg function called  
RunOptimizations to the module (can't check it right now)?

> Please note that llvm-ld is an unfinished tool and you are working at
> the edge of its functionality.

I like living at the edge ;-)

> I plan to complete this tool sometime
> this year, but I have other higher priority things to work on.  
> Also, the
> LTO work may factor into a future redesign of this tool.


> Hope this helps.

It sure did!

Kind regards,

Bram Adams
GH-SEL, INTEC, Ghent University (Belgium)

More information about the llvm-dev mailing list