newsGNU Scientific Library - News

 
 

GNU Scientific Library dependencies and linking with --as-needed

Item posted by -Deleted Account- <bjg> on Mon 09 Feb 2009 05:57:54 PM UTC.

Many distributions are starting to link every application with the GNU Linker's --as-needed flag, to avoid loading libraries that are specified on the command-line but not actually used.

While this is a good thing, it caused a problem for applications using GSL because the main library needs to call an external library for vector operations (BLAS).  These BLAS functions are typically not called from the user's object file directly, and they were being discarded by --as-needed causing numerous "unresolved reference" errors.  The problem arises because --as-needed does not follow references recursively, except for direct shared library dependencies specified by the ELF DT_NEEDED field (i.e libraries explicitly defined as a dependency in libtool).

In the case of GSL we are not able to specify the dependency on the external library explicitly--we do not know which BLAS library will be used.  We want people to be able to choose different BLAS libraries when they link their applications.

Now thanks to Alan Modra there is a enhancement to binutils [1,2] which allows --as-needed to search recursively, ensuring that libraries which are used both directly and indirectly will be linked, and only those with no references at all will be discarded.  The next release of binutils should resolve the problems encountered using GSL with --as-needed.

[1] http://sourceware.org/ml/binutils/2009-01/msg00399.html
[2] http://sourceware.org/ml/binutils/2009-01/msg00413.html


Back to the top

Powered by Savane 3.13-3230.
Corresponding source code