Charlene Wendling:

> > util.o: In function `tvstddev':
> > util.c:(.text+0x6f4): undefined reference to `sqrt'
> 
> The autoconf stuff really detects the need for`-lm' as seen in
> config.log: 'ac_cv_lib_m_sqrt=yes', but is not used anywhere at all.

No, we are preloading the autoconf cache with this and many other
results.  See infrastructure/db/config.site.  There is no actual
test for this in the configure script.

There _is_ a test whether -lm is required for pow(3),
"checking if libmath is mandatory".

If you run nm(1) on the compiled util.o on amd64, there is no
unresolved reference to sqrt().  What's happening here is that the
compiler inlines its own optimized sqrt(), instead of calling the
libm function.  The same happens for pow() in the configure test.
Or worse, I think the compiler notices that this lone pow() call
has no effect and just drops it, neutering the test.

If you compile with -ffreestanding, which is the ultimate hammer
to prevent such shenanigans, util.o has a reference to sqrt() and
the configure check for -lm actually works.  Anyway, that's not a
solution for the port.

Your solution is fine, but the comment needs to be tweaked.
Maybe like this?

# Requires libm: uses sqrt(3), inlined by the compiler on some archs

-- 
Christian "naddy" Weisgerber                          na...@mips.inka.de

Reply via email to