LinkLists

From Mu2eWiki
Jump to navigation Jump to search

Link Lists

Fixme: define a link list and talk about the conventions in our scons world.

Removing Unneeded Libaries from Link Lists

If you suspect that a link list contains unnecessary libraries, the following procedure will identify which libraries are actually needed; you can then remove other libraries from the link list.

  1. Link the shared libraries using the -Wl,--as-needed option; this tells the linker to ignore libraries that are not required to resolve any linker symbols. Since Sept 2, 2019 this has been the default in Mu2e Offline.
  2. Issue the following command on each library:
    1. readelf -d libMine.so | egrep 'NEEDED'

This will print a list of libraries that are actually linked into each shared library. Use this information to prune unnecessary libraries from the link list that was used to make the library.

One caution: in some cases we make multiple libraries from a single link list; for example all modules in one subdirectory are usually made using a common link list. In such a case you have two choices:

  1. Choose to use separate link lists for each library.
  2. Continue to use a single list list that is the union of the libraries identified for the above procedure for all libaries built by that link list.