[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,


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.


AFAIK nobody works or plan to work on this issue. I cannot give a
promise but if I have a time I will take a look at this bug.

I see. Thank you, Simon.
I will look into this. I am just starting with lld, so this should help me get the initial vision of the lld's code while avoiding complicated lld stuff.

Warm wishes,