Re: RFC: -Wl,--as-needed by default

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Nov 27, 2017 at 09:21:16AM +0100, Dridi Boukelmoune wrote:
> On Mon, Nov 13, 2017 at 11:01 PM, Tomasz Kłoczko
> <kloczko.tomasz@xxxxxxxxx> wrote:
> > On 13 November 2017 at 10:52, Björn 'besser82' Esser
> > <besser82@xxxxxxxxxxxxxxxxx> wrote:
> <snip>
> > However AFAIK only reason of any issues related to use -Wl,--as-needed
> > is using WRONG list -l<foo> parameters (lack of some -l<foo>) and this
> > needs to be not treated by apply some workaround but but by apply
> > necessary fixes in -l<foo> linking parameters.
> 
> Off the top of my head I can see glibc leading to "over" linking: if
> upstream is not GNU/Linux-only it may need -lm, -lrt, -lsocket, -lnls
> etc for other platforms. For autotools-based projects depending on how
> you do the functions detection it may or may not add the -l* flags to
> $LIBS if provided by the libc.

There are several problems with forceful --as-needed:
1) forcing it everywhere is a workaround to broken tools that add -l*
options just in case (like auto*, libtool, pkg-config)
2) until recently, there was no way to enable the option for just one
library and restore it afterwards, so many spots, including, but not limited
to, gcc driver itself, do --as-needed -lgcc_s --no-as-needed, which if
somebody forces --as-needed at the start of the linker command line has the
effect that everything up to the -lgcc_s on the command line behaves
--as-needed, and everything after it doesn't.  Since 3 years ago ld
offers the --push-state/--pop-state options, so one can use
--push-state --as-needed -lgcc_s --pop-state instead and that at the end
restores the previous --as-needed behavior.  So, before turning it by
default, you'd need to check everywhere where --no-as-needed is used and
see if it is something where --push-state/--pop-state should be used.
3) forcing --as-needed breaks some legitimate uses where some work is done
e.g. in the constructors of some library, but there is no need to use any
symbols, or if you know some library needs to be initialized early but will
be used only from dlopened libraries (e.g. AddressSanitizer and
ThreadSanitizer can be examples of this), or the library extends the binary
and provides necessary symbols for a plugin that will be dlopened.

	Jakub
_______________________________________________
devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]
  Powered by Linux