make use of ld --as-needed

From: Neil Conway <neilc(at)samurai(dot)com>
To: pgsql-patches(at)postgresql(dot)org
Subject: make use of ld --as-needed
Date: 2005-05-05 03:48:05
Message-ID: 42799775.7070907@samurai.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

The issue has been raised in the past that our build system links each
executable against the maximal set of libraries it might need. So for
example, if one executable requires `libreadline', all executables are
linked against it.

The easiest fix is to make use of GNU ld's --as-needed flag, which
ignores linker arguments that are not actually needed by the specified
object files. The attached patch modifies configure to check for this
flag (when using GNU ld), and if ld supports it, adds the flag to
LDFLAGS (we need to do the check since only relatively recent versions
of GNU ld support this capability). The patch only checks for GNU ld:
does anyone know if any other linkers support this capability, and if
so, what flags need to be specified to enable it?

I haven't had a chance to test this on a non-GNU-ld system, but I will
do so before applying. Barring any objections, I'll apply this tomorrow.

-Neil

Attachment Content-Type Size
ld_as_needed-1.patch text/x-patch 4.4 KB

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2005-05-05 04:02:05 Re: make use of ld --as-needed
Previous Message Bruce Momjian 2005-05-05 03:25:07 Re: Cleaning up unreferenced table files