On Wed, 28 Mar 2018, Lisandro Dalcin wrote:
>> I don't know where the --as-needed flags come from. Is this added by Python
>> distutils or by gcc?
>> I am using Python 3.6.4 and gcc 7.3.1.
>
> Not sure.
If I remember correctly, this flag was added to the Ubuntu toolchain from
Ubuntu 14.04 on or somewhere around that time. The motivation was to
dramatically improve application startup times by not linking libraries
from which no symbols are used.
I'm not sure whether the decision was really backed by benchmarks, but the
consensus was that it is really worth it. Anyways, it did cause many
problems down the line for pathological cases where for example plugins
were backlinked to the library that was supposed to load them to be able
to access its symbols instead of defining a proper API, etc. or weird
cases like yours, when the library was actually meant to be preloaded and
authors were relying on dynamic linking instead of LD_PRELOAD.
Of course, from there on, it propagates to the rest of the system. If one
uses system Python form Debian package, then distutils pick up the
compiler and linker flags with which the package was compiled...
--
Sincerely yours,
Yury V. Zaytsev