[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: -Wl,--as-needed considered possibly harmful



On Sun, Dec 09, 2007 at 07:23:00PM +0100, Josselin Mouette wrote:
> Hi,
> 
> Le dimanche 09 décembre 2007 à 19:11 +0100, Bernhard R. Link a écrit :
> > Just curing the symptoms instead of the problems will not help to get
> > there any sooner.
> 
> What if there is no problem?
> 
> For example, pkg-config --libs gtk+-x11-2.0 will return, among others,
> -lglib-2.0 and -lm. And this is perfectly intentional. The former is
> here because you can assume glib functions are available when doing
> "#include <gtk/gtk.h>". The latter is here because some macros need math
> functions. Still, many binaries using it don't need glib, and most of
> them don't need libm. There is nothing that can be done to avoid that,
> the only way is a check that removes the dependency if it isn't actually
> needed.

I can't seem to find any example of a macro calling a math functions?
I also can't find any header that includes <math.h>.  I do see
that libgtk-x11-2.0.so uses symbols from libm, like log10, atan2, sin,
cos, tan, pow, ceil.  But I can't find anything in the header files
that would use them.

It's gdk-pixbuf-2.0.pc and cairo.pc that have -lm in them.

Anyway, I think it is bad style to use macro's in public header
files that call functions from another library.  It's also easy
to replace them with real functions.  If there are such functions
being called I suggest you replace them.

What might be harder is avoiding the includes from other libraries
because you use types from the other library.  It would be great
if you didn't have to do that, and there are some ways to avoid that.


Kurt



Reply to: