Alexander E. Patrakov wrote:

> Archaic wrote:
>> I'm getting an undefined reference to ceilf in gpm compiling on ppc.
>> Haven't had a chance yet to find out why -lm isn't being pulled in, but
>> I'll get to it soon. Has anyone else seen this error?
> 
> That's normal. You have to pass -lm on ppc explicitly (but I can't say 
> this for 100% sure, I don't have that hardware).
> 
> On i386, gcc optimizes the ceilf() call into some FPU instructions, so 
> the libm library actually containing this function is not needed 
> (because the function is not actually called at all).

Um, sort of. What's actually happening (on x86) is that GCC decided to use
its own "builtin" version of ceil(). Gcc-3.4.x gained an absolute plethora
of these so called builtins (including ceil, ceilf, ceill etc, etc).

  http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/Other-Builtins.html

You can easily see what's going on by compiling this lame example:

#include <math.h>
int main()
{
  return ceil(1);
}

Compile it with:

gcc a.c -Wall -W -save-temps

and it will compile and link perfectly (ie: without resorting to -lm)

Now compile it with:

gcc a.c -Wall -W -save-temps -fno-builtin

and it will fail to link.

Inspecting the generated assembly reveals a call into the math library
hence the failed link.

What I don't understand is that GCC4 gives the same link failure on
x86 that Archaic sees on PPC. This time it's also the ceilf() function,
but strangely, the GPM source code only refers to ceil().

Bottom line is that -lm should be used for correctness (even tho' it's not
really necessary with gcc-3.4.x on x86). BLFS is correct in trying to add
-lm, but IMHO is doing it the wrong way (see forthcoming post to blfs-dev).

Regards
Greg
-- 
http://www.diy-linux.org/

-- 
http://linuxfromscratch.org/mailman/listinfo/blfs-support
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page

Reply via email to