-Wl,--as-needed

Thiago Macieira thiago at kde.org
Sat Apr 23 23:28:57 BST 2005


George Staikos wrote:
>   This linker flag, -Wl,--as-needed, is causing some rather major
> problems for Kst build.

It's a flag turned on only if you give configure the option 
--enable-new-ldtags. It's like --enable-final, and we all know there are 
programs that don't work with --enable-final.

> If it's included, at least with my SuSE 9.2 
> install, it completely botches the GSL link and causes our plugins to
> crash when running. The only way to remove the flag (which makes it
> link properly), is to remove $(all_libraries), but that breaks compile
> on other platforms.  Does anyone know if there's a problem with SuSE
> 9.2's ld or gsl packages?  Or can we come up with a solution to
> optionally remove that flag?

See above.

But the problem you're reporting doesn't make sense. The only effect 
--as-needed has is remove unnecessary libraries from the ELF binaries. 
Whatever is needed will be pulled in normally. This indicates the problem 
is something else.

>   The details of the problem are that with the flag, when I link
> gslcblas and gsl into a plugin, it seems to drop gslcblas for no
> apparent reason.

Either it's an ld bug, or gslcblas isn't needed.

> It's definitely needed though.  The plugin crashes 
> due to missing symbol when running it without gslcblas linked in.

The linker adds the NEEDED symbol only for what the resulting binary 
requires *directly*. If your plugin doesn't need anything from gslcblas, 
it won't be listed in the NEEDED section. It doesn't matter if a library 
you use needs stuff from it --- the dependency isn't direct.

What probably is wrong is gsl and gslcblas themselves. I have seen many 
libraries that fail to link to their required dependencies, and in turn 
expect the final program to do that.

-- 
  Thiago Macieira  -  thiago (AT) macieira (DOT) info
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

3. Ac seo woruld wearð geborod, swá se Scieppend cweað "Gewurde Unix" and 
wundor fremede and him "Unix" genemned, þæt is se rihtendgesamnung.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20050423/10c3fdc7/attachment.sig>


More information about the kde-core-devel mailing list