Oleg Ranevskyy
2014-Sep-17 12:30 UTC
[LLVMdev] [lld] -Bstatic / -Bdynamic switches handling
Hello LLD developers! Lld is claimed to be compatible with the existing linker options. However, there is a discrepancy in how the -Bstatic switch (disable linking against shared libs) is treated by lld and GNU ld. According to the GNU ld docs, the switch affects library searching for -l options *which follow it*. This means -Bstatic can be used multiple times in the command line to disable dynamic linking for particular -l options. For example: ld -Bstatic -lslib1 -lslib2 -Bdynamic -ldlib1 -Bstatic -lslib3... Even though the GNU linker won't search for so-files for slib1, slib2 and slib3, so-file for dlib1 will still be considered as it is preceded by -Bdynamic. Lld behaves differently. -Bdynamic is not recognized yet, whereas -Bstatic applies static linkage on the binary level, i.e. it's no longer possible to link against any shared lib. Lld looks for static archives only if -Bstatic is met in the command line. Is this intentional behaviour or this functionality just hasn't been fully implemented yet? Thank you! Kind regards, Oleg -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140917/9b7aeaf2/attachment.html>
Simon Atanasyan
2014-Sep-17 13:52 UTC
[LLVMdev] [lld] -Bstatic / -Bdynamic switches handling
Hi, This functionality is implemented say incompletely. Now -Bdynamic is not recognized at all. -Bstatic and -Bshareable are aliases for -static and -shared options respectively. The linker uses the last option specified in a command line just to select type of output file. Simon On Wed, Sep 17, 2014 at 4:30 PM, Oleg Ranevskyy <llvm.mail.list at gmail.com> wrote:> Hello LLD developers! > > Lld is claimed to be compatible with the existing linker options. > However, there is a discrepancy in how the -Bstatic switch (disable > linking against shared libs) is treated by lld and GNU ld. > > According to the GNU ld docs, the switch affects library searching for -l > options *which follow it*. > This means -Bstatic can be used multiple times in the command line to > disable dynamic linking for particular -l options. For example: > > ld -Bstatic -lslib1 -lslib2 -Bdynamic -ldlib1 -Bstatic -lslib3... > > Even though the GNU linker won't search for so-files for slib1, slib2 and > slib3, so-file for dlib1 will still be considered as it is preceded by > -Bdynamic. > > Lld behaves differently. > -Bdynamic is not recognized yet, whereas -Bstatic applies static linkage > on the binary level, i.e. it's no longer possible to link against any > shared lib. Lld looks for static archives only if -Bstatic is met in the > command line. > > Is this intentional behaviour or this functionality just hasn't been fully > implemented yet? > > Thank you! > > Kind regards, > Oleg > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-- Simon Atanasyan -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140917/158842ab/attachment.html>
Oleg Ranevskyy
2014-Sep-17 14:17 UTC
[LLVMdev] [lld] -Bstatic / -Bdynamic switches handling
Hi Simon, Thank you for the info. Do you know if there are any plans to add -Bdynamic support and make -Bstatic/-Bdynamic compatible with GNU ld? I am giving lld a try building the Boost libraries and this is a real show stopper. Boost.Build passes both -Bstatic and -Bdynamic to the linker which makes lld think the output file is static, so it totally ignores shared libraries. This breaks the build as some libs do not have static counterparts and the linker fails with the "library not found" error. Oleg On 17.09.2014 17:52, Simon Atanasyan wrote:> Hi, > > This functionality is implemented say incompletely. Now -Bdynamic is > not recognized at all. -Bstatic and -Bshareable are aliases for > -static and -shared options respectively. The linker uses the last > option specified in a command line just to select type of output file. > > Simon > > On Wed, Sep 17, 2014 at 4:30 PM, Oleg Ranevskyy > <llvm.mail.list at gmail.com <mailto:llvm.mail.list at gmail.com>> wrote: > > Hello LLD developers! > > Lld is claimed to be compatible with the existing linker options. > However, there is a discrepancy in how the -Bstatic switch > (disable linking against shared libs) is treated by lld and GNU ld. > > According to the GNU ld docs, the switch affects library searching > for -l options *which follow it*. > This means -Bstatic can be used multiple times in the command line > to disable dynamic linking for particular -l options. For example: > > ld -Bstatic -lslib1 -lslib2 -Bdynamic -ldlib1 -Bstatic -lslib3... > > Even though the GNU linker won't search for so-files for slib1, > slib2 and slib3, so-file for dlib1 will still be considered as it > is preceded by -Bdynamic. > > Lld behaves differently. > -Bdynamic is not recognized yet, whereas -Bstatic applies static > linkage on the binary level, i.e. it's no longer possible to link > against any shared lib. Lld looks for static archives only if > -Bstatic is met in the command line. > > Is this intentional behaviour or this functionality just hasn't > been fully implemented yet? > > Thank you! > > Kind regards, > Oleg > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu <mailto:LLVMdev at cs.uiuc.edu> > http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > > > > -- > Simon Atanasyan-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140917/cd4bc477/attachment.html>