Subject: Re: Configure failure on Solaris 11.4

From: Steve Downey <[email-masked]>
Date: Mon, 9 May 2022 20:15:56 -0400

I don't have the full configure logs at hand. The build was with the Sun
Studio suite 12.6, and it builds successfully on Solaris 11.3, and fails
linking on 11.4.
Failure was:
CCLD temacs
Undefined first referenced
symbol in file
cos floatfns.o
exp floatfns.o
log floatfns.o
pow xfns.o
sin floatfns.o
tan floatfns.o
acos floatfns.o
asin floatfns.o
atan floatfns.o
ceil floatfns.o
fmod floatfns.o
powf pdumper.o
atan2 floatfns.o
floor xterm.o
ilogb floatfns.o
log10 xdisp.o
lround hbfont.o
scalbn floatfns.o
ld: fatal: symbol referencing errors

In 11.4, sqrt is defined in libc.so as an absolute symbol, so the test for
if -lm is necessary succeeds without it. I haven't disassembled the new
libc, but I suspect that you're right and they have a sqrt that is fast
enough either depends on a sqrt instruction or is otherwise "simple" for
some value of simple.

Was able to reproduce the build failure with SS12.4 on 11.4 as well.

This is the actual patch we're using:
--- emacs-27.2.orig/configure.ac
+++ emacs-27.2/configure.ac
@@ -1634,14 +1634,14 @@ AC_DEFUN([AC_TYPE_SIZE_T])
 # Likewise for obsolescent test for uid_t, gid_t; Emacs assumes them.
 AC_DEFUN([AC_TYPE_UID_T])

-# sqrt and other floating-point functions such as fmod and frexp
+# atan and other floating-point functions such as fmod and frexp
 # are found in -lm on many systems.
 OLD_LIBS=$LIBS
-AC_SEARCH_LIBS([sqrt], [m])
+AC_SEARCH_LIBS([atan], [m])
 if test "X$LIBS" = "X$OLD_LIBS"; then
   LIB_MATH=
 else
-  LIB_MATH=$ac_cv_search_sqrt
+  LIB_MATH=$ac_cv_search_atan
 fi
 LIBS=$OLD_LIBS

Reading elsethread, I totally understand Eli Zaretskii's concern about this
being fragile, but as near as I can tell this is still the unfortunate
state of the art in figuring out if libm is needed using autoconf, although
testing with trig functions does seem to be the mode these days.

On Mon, May 9, 2022 at 3:07 PM Paul Eggert <[email-masked]> wrote:

> Thanks for the bug report. The patch looks safe, since Emacs calls atan
> as well as sqrt. And it looks like an improvement, since I can imagine
> all sorts of reasons why sqrt would not need libm whereas atan would,
> starting with the fact that typical hardware nowadays has sqrt
> instructions but not atan instructions. (The 'configure' test itself
> relies on undefined behavior, so it's not strictly portable anyway.)
>
> Although it would be helpful to know how to reproduce the problem (which
> compiler? how configured? etc.) and which symbols were not found in
> temacs on Solaris 11.4, we don't need to know that to install the patch.
>