LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 20976 - The -Bstatic / -Bdynamic switches should be compatible with GNU ld
Summary: The -Bstatic / -Bdynamic switches should be compatible with GNU ld
Status: RESOLVED FIXED
Alias: None
Product: lld
Classification: Unclassified
Component: All Bugs (show other bugs)
Version: unspecified
Hardware: PC Linux
: P normal
Assignee: Davide Italiano
URL:
Keywords:
Depends on:
Blocks: 23214
  Show dependency tree
 
Reported: 2014-09-17 09:33 PDT by Oleg Ranevskyy
Modified: 2015-10-12 17:28 PDT (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Oleg Ranevskyy 2014-09-17 09:33:32 PDT
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 at all, whereas -Bstatic applies static linkage on the output file level. The output file is considered static and 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.
Comment 1 emaste 2015-09-29 14:46:53 PDT
http://reviews.llvm.org/D13238
Comment 2 Davide Italiano 2015-10-12 17:28:38 PDT
Fixed in ELF2.