As a recent bug pointed out, you really only want to link libraries you
actually need because the others could export functions that you don't
want and interfere. Rather than relying a GCC only feature, this takes
the good old fashioned approach: filtering out the libraries you don't
need.
Attached is a patch which applies this filtering to the backend and has
the same results as linking with --as-needed. I basically took the
filter list of libpq and altered it as follows:
libs removed: -lnsl -lresolv
libs added: -ldl -lm
Incidently, the libs removed don't appear to be needed by anything in
any file in the source, so I wonder if they're even required.
This probably needs a bit of testing on a few different architechtures
to make sure it works. I also only apply it to the non-windows, non-aix
case since the building requirements there are different enough that
someone with such a platforn should do it.
Have a nice day,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.