On 21.01.25 22:01, Colin Watson wrote:
On Tue, Jan 21, 2025 at 10:31:29AM -0500, Theodore Ts'o wrote:
A question about --as-needed as an upstream developer who wants to
care about more than just Debian or Linux.  Am I correct in assuming
this will work on any system using GNU binutils?  And it doesn't
matter whether you are using gcc, clang, etc.  What about other OS's
such as *BSD, MacOS, etc.?

--as-needed has been there forever. The --push-state/--pop-state options are implemented in binutils 2014 (ld), and binutils 2016 (gold). I didn't look at other linkers.

Using these in libtool still seems to be a problem, as libtool has it's own idea about how to re-sort command line options and libraries.

I often consult Gnulib for lore on this kind of thing.
https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob;f=m4/lib-ignore.m4
seems to have some useful hints, with comments for those not fluent in
m4.

This also seems to be a standalone file, so if your project is using
Autoconf but not Gnulib, then you should be able to copy it into your
project's local macro directory, add gl_IGNORE_UNUSED_LIBRARIES to
configure.ac, and add $(IGNORE_UNUSED_LIBRARIES_CFLAGS) etc. to whatever
*_LDFLAGS variable is appropriate.


Reply via email to