Why using -Wl,--as-needed

  |   Source

Today I was preparing a new package for Debian, pinot, a Xapian (and other engines) based full-text search engine, when I noticed of the real difference in generated dependencies passing -Wl,--as-needed to the linker (via LDFLAGS) or not. Here it is a table which summarizes the result:

  <th>
    LDFLAGS="-Wl,--as-needed"
  </th>
</tr>

<tr>
  <td>
    libatk1.0-0 (>= 1.20.0)
  </td>

  <td>
  </td>
</tr>

<tr>
  <td>
    libc6 (>= 2.7-1)
  </td>

  <td>
    libc6 (>= 2.7-1)
  </td>
</tr>

<tr>
  <td>
    libcairo2 (>= 1.4.0)
  </td>

  <td>
  </td>
</tr>

<tr>
  <td>
    libcairomm-1.0-1 (>= 1.4.0)
  </td>

  <td>
  </td>
</tr>

<tr>
  <td>
    libcomerr2 (>= 1.33-3)
  </td>

  <td>
  </td>
</tr>

<tr>
  <td>
    libcurl3 (>= 7.16.2-1)
  </td>

  <td>
    libcurl3 (>= 7.16.2-1)
  </td>
</tr>

<tr>
  <td>
    libdbus-1-3 (>= 1.1.1)
  </td>

  <td>
    libdbus-1-3 (>= 1.1.1)
  </td>
</tr>

<tr>
  <td>
    libdbus-glib-1-2 (>= 0.74)
  </td>

  <td>
    libdbus-glib-1-2 (>= 0.74)
  </td>
</tr>

<tr>
  <td>
    libfontconfig1 (>= 2.4.0)
  </td>

  <td>
  </td>
</tr>

<tr>
  <td>
    libfreetype6 (>= 2.3.5)
  </td>

  <td>
  </td>
</tr>

<tr>
  <td>
    libgcc1 (>= 1:4.1.1-21)
  </td>

  <td>
    libgcc1 (>= 1:4.1.1-21)
  </td>
</tr>

<tr>
  <td>
    libglib2.0-0 (>= 2.12.0)
  </td>

  <td>
    libglib2.0-0 (>= 2.12.0)
  </td>
</tr>

<tr>
  <td>
    libglibmm-2.4-1c2a (>= 2.14.0)
  </td>

  <td>
    libglibmm-2.4-1c2a (>= 2.14.0)
  </td>
</tr>

<tr>
  <td>
    libgmime-2.0-2
  </td>

  <td>
    libgmime-2.0-2
  </td>
</tr>

<tr>
  <td>
    libgtk2.0-0 (>= 2.12.0)
  </td>

  <td>
    libgtk2.0-0 (>= 2.12.0)
  </td>
</tr>

<tr>
  <td>
    libgtkmm-2.4-1c2a (>= 2.12.0)
  </td>

  <td>
    libgtkmm-2.4-1c2a (>= 2.12.0)
  </td>
</tr>

<tr>
  <td>
    libidn11 (>= 0.5.18)
  </td>

  <td>
  </td>
</tr>

<tr>
  <td>
    libkrb53 (>= 1.6.dfsg.2)
  </td>

  <td>
  </td>
</tr>

<tr>
  <td>
    libldap-2.4-2 (>= 2.4.7)
  </td>

  <td>
  </td>
</tr>

<tr>
  <td>
    libpango1.0-0 (>= 1.19.3)
  </td>

  <td>
  </td>
</tr>

<tr>
  <td>
    libpng12-0 (>= 1.2.13-4)
  </td>

  <td>
  </td>
</tr>

<tr>
  <td>
    libsigc++-2.0-0c2a (>= 2.0.2)
  </td>

  <td>
    libsigc++-2.0-0c2a (>= 2.0.2)
  </td>
</tr>

<tr>
  <td>
    libsqlite3-0 (>= 3.5.4)
  </td>

  <td>
    libsqlite3-0 (>= 3.5.4)
  </td>
</tr>

<tr>
  <td>
    libssh2-1
  </td>

  <td>
  </td>
</tr>

<tr>
  <td>
    libssl0.9.8 (>= 0.9.8f-5)
  </td>

  <td>
    libssl0.9.8 (>= 0.9.8f-5)
  </td>
</tr>

<tr>
  <td>
    libstdc++6 (>= 4.2.1-4)
  </td>

  <td>
    libstdc++6 (>= 4.2.1-4)
  </td>
</tr>

<tr>
  <td>
    libtag1c2a (>= 1.4)
  </td>

  <td>
    libtag1c2a (>= 1.4)
  </td>
</tr>

<tr>
  <td>
    libtextcat0
  </td>

  <td>
    libtextcat0
  </td>
</tr>

<tr>
  <td>
    libx11-6
  </td>

  <td>
  </td>
</tr>

<tr>
  <td>
    libxapian15
  </td>

  <td>
    libxapian15
  </td>
</tr>

<tr>
  <td>
    libxml++2.6-2 (>= 2.20.0)
  </td>

  <td>
    libxml++2.6-2 (>= 2.20.0)
  </td>
</tr>

<tr>
  <td>
    libxml2 (>= 2.6.27)
  </td>

  <td>
    libxml2 (>= 2.6.27)
  </td>
</tr>

<tr>
  <td>
    libxrender1
  </td>

  <td>
  </td>
</tr>

<tr>
  <td>
    zlib1g
  </td>

  <td>
    zlib1g
  </td>
</tr>

<tr>
  <td align="center">
    <b>34</b>
  </td>

  <td align="center">
    <b>20</b>
  </td>
</tr>

LDFLAGS=""

We removed 14 useless dependencies!

Comments powered by Disqus
Contents © 2013 David Paleino - Powered by Nikola