Bug #14862 undefined reference to `isinf' on SOLARIS - strings/strtod.c
Submitted: 11 Nov 2005 14:21 Modified: 26 Apr 2007 18:55
Reporter: Tim Berke
Status: Closed
Category:Server Severity:S3 (Non-critical)
Version:5.0.15 OS:Sun Solaris (Solaris 8 sparcv9, Solaris 10)
Assigned to: Magnus Blaudd Target Version:

[11 Nov 2005 14:21] Tim Berke
Description:
I get the following error on SOLARIS:
make[2]: Entering directory `/home/berke/download/gnu/mysql-5.0.15/extra'
/bin/bash ../libtool --preserve-dup-deps --mode=link gcc  -O3 -DDBUG_OFF    -D_F
ILE_OFFSET_BITS=64 -DHAVE_CURSES_H -I/home/berke/download/gnu/mysql-5.0.15/inclu
de -DHAVE_RWLOCK_T   -o comp_err  comp_err.o ../mysys/libmysys.a ../dbug/libdbug
.a ../strings/libmystrings.a -lpthread -lthread -lposix4 -lcrypt -lgen -lsocket 
-lnsl -lm  -lpthread -lthread 
gcc -O3 -DDBUG_OFF -D_FILE_OFFSET_BITS=64 -DHAVE_CURSES_H -I/home/berke/download
/gnu/mysql-5.0.15/include -DHAVE_RWLOCK_T -o comp_err comp_err.o  ../mysys/libmy
sys.a ../dbug/libdbug.a ../strings/libmystrings.a -lpthread -lthread -lposix4 -l
crypt -lgen -lsocket -lnsl -lm -lpthread -lthread
../strings/libmystrings.a(strtod.o): In function `my_strtod':
strtod.c:(.text+0x9c): undefined reference to `isinf'
collect2: ld returned 1 exit status
make[2]: *** [comp_err] Error 1
make[2]: Leaving directory `/home/berke/download/gnu/mysql-5.0.15/extra'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/berke/download/gnu/mysql-5.0.15'
make: *** [all] Error 2

How to repeat:
Compile on:

 ## --------- ##
## Platform. ##
## --------- ##

hostname = chipster
uname -m = sun4u
uname -r = 5.8
uname -s = SunOS
uname -v = Generic_117350-12

/usr/bin/uname -p = sparc
/bin/uname -X     = System = SunOS

./configure --prefix=/tools/packarch/public/mysql --enable-assembler --with-gnu-ld
--localstatedir=/tools/xircad/mysql/data --with-unix-socket-
path=/tools/packarch/public/mysql/tmp/mysql.sock

make

Suggested fix:
Add the following two lines to strings/strtod.c:
#include <ieeefp.h>
int isinf(double x) { return !finite(x) && x==x; }

I got this from the web:
 Why do I get isinf undefined when linking with libdps on Solaris 2.3?

That's a bug in libdps (fixed in 2.4). Sun compiles and links its
software with its own compilers. The isinf() function is shipped
with the SunPRO compilers, but not defined in any Solaris 2.3
library.

A workaround exists, and consists of adding the following to
your program:

#include <ieeefp.h>

int isinf(double x) { return !finite(x) && x==x; }
[15 Nov 2005 17:02] Valeriy Kravchuk
Thank you for a problem report. Sorry, but I was not able to repeat it on Solaris 9 (the
closest machine to yours we have here). I did the following:

cd mysql-5.0.15
export
PATH=/export/home/mysqldev/butch-64bit/bin:/opt/sfw/bin:/usr/sfw/bin:/usr/local/bin:/usr/bin:/usr/xpg4/bin:/usr/sbin:/usr/openwin/bin:/usr/dt/bin:/usr/ccs/bin:/usr/ucb:/opt/SUNWspro/bin
export LD_LIBRARY_PATH=/usr/lib:/usr/local/lib:/usr/local/lib/sparcv9
./configure --prefix=/users/vkravchuk/dbs/5.0-butch --enable-assembler
--with-gnu-ld     

(other your options seems irrelevant for me)

make -- no errors similar to yours
echo $? -- gave 0
make install
echo $? -- gave 0
cd ~/dbs/5.0-butch/
bin/mysqld_safe --socket=/users/vkravchuk/mysql5.sock --skip-networking &

Server started without any problems.

Then:

bash-2.05$ bin/mysql -V
bin/mysql  Ver 14.12 Distrib 5.0.15, for sun-solaris2.9 (sparc) using  EditLine
wrapper
bash-2.05$ file libexec/mysqld
libexec/mysqld: ELF 32-bit MSB executable SPARC Version 1, dynamically linked, not
stripped
bash-2.05$ uname -a
SunOS butch 5.9 Generic_118558-09 sun4u sparc SUNW,UltraAX-i2

Any ideas on how to repeat the problem you described are welcomed.
[15 Nov 2005 17:10] Tim Berke
It would seem there is a library (sun) differance between what I have and your later
SOLARIS version. Perhaps this is now included in the standard SOLARIS libraries or you
have the SUNPRO compiler installed.
This was really for anyone else who might need this hack. I found others on the web
trying to solve the same problems.
Thanx much,
tim
[15 Nov 2005 17:24] Valeriy Kravchuk
I had found another machine, with Solaris 8: 

Sun Sunfire v100 UltraSPARC-IIe 550 MHz 1 GB RAM Sun Solaris 8 (solaris2.8-sparc)

But it has Sun Studio 9 C/C++ 5.6 + gcc 3.3. 

In my test gcc was used, but on all our SPARCs Sun Studio or Sun Forte compilers are
installed. I can not change that. So, would you like me to try build on the machine
described above? Or can I simply close this report as can't repeat? Your hint is already
stored in our bugs database forever...
[15 Nov 2005 17:49] Tim Berke
Hi Valeriy,
 This sounds like a close as can't repeat.
I do not think this is worth trying to rebuild a sun.
Thanx,
tim
[15 Nov 2005 17:53] Valeriy Kravchuk
Closed as agreed with the bug reporter.
[29 Nov 2005 20:02] Jonathan Miner
Easily repeatable on Solaris 9 with GCC 4.0.2  I do not have SUN compilers installed.
[8 Dec 2005 7:10] Robert Cohen
I have also seen this problem on Solaris 9 with gcc 4.0.2
I don't get it with gcc 3.4.4

Normally isinf is handled by gcc as a built in function. I can use gcc 4.0.2 to compile
test programs with isinf without problem.

However something in the mysql compilation environment is stopping gcc from handling it
as a builtin function.
[9 Dec 2005 2:59] Robert Cohen
Actually after further playing I have discovered that even if you workaround the isinf
issue, the compilation blows up later with massive linking problems.

So I suspect that mysql and gcc 4.0.2 just don't get on. Chances are its a gcc bug/issue
since it works fine in gcc 3.4.x
[11 Dec 2005 9:53] Marcos Della
I too am running gcc 4.0.2 under Solaris 8 and have the exact same error and linking
problems.  I tried the workaround and managed to get past the error, however once past,
ran into the same issues with linker errors as well.  I've actually tried this compile
under Solaris 8, and Solaris 9 both under Sparc and x86 architectures and haven't gotten
it to work.  The next "step" is to downgrade the gcc compiler and see if that helps...
[11 Dec 2005 18:06] Marcos Della
Well, after a long evening of frustrating work, we managed to build a new solaris machine
w/o gcc on it and installed 3.4.2 (sunfreeware version) and did the same compile and
managed to get MySQL 5.0.16 to compile under Solaris_8_Sparc as well as Solaris_8_x86. 
Have not yet done the same thing with Solaris 9 or 10 yet (its a long process to do
this).

So as mentioned earlier, it does appear to be a compiler related interaction issue.  Is
there any specific dumps or outputs that anyone wants to demonstrate the issues?  I still
have a Solaris 8 machine with gcc 4.0.2 on it as well as (now) a set with gcc 3.4.2 on
them.
[24 Jan 2006 14:22] J Jans
I just tried to build mysql 4.1.16 and 5.0.18 using gcc 4.0.2 under Solaris 7.
The machine does not have the Sun compiler suite installed - just gcc 4.0.2.
I get the same error as described above. System information and compile flags can be
found below.

beheer$ uname -a
SunOS white 5.7 Generic_106541-07 sun4u sparc SUNW,Ultra-250 Solaris

beheer$ gcc -v
Using built-in specs.
Target: sparc-sun-solaris2.7
Configured with: ../gcc-4.0.2/configure --prefix=/opt/software/gcc-4.0.2 --disable-nls
--disable-multilib --with-gnu-as --with-as=/opt/local/bin/as --with-gnu-ld
--with-ld=/opt/local/bin/ld --with-cpu=ultrasparc --enable-languages=c,c++
Thread model: posix
gcc version 4.0.2

beheer$ ld -v
GNU ld version 2.16

beheer$ as -v
GNU assembler version 2.16 (sparc-sun-solaris2.7) using BFD version 2.16

beheer$ make -v
GNU Make 3.80
Copyright (C) 2002  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

beheer$ env | egrep "FLAG|PATH"
LD_LIBRARY_PATH=/opt/local/lib:/usr/lib:/usr/openwin/lib
MANPATH=/opt/local/man:/usr/man:/usr/local/man:/opt/gcc/man:/opt/perl5/man:/opt/tex/man
CPPFLAGS=-O3 -I/opt/local/include -fPIC -fomit-frame-pointer -m32 -mcpu=ultrasparc
LDFLAGS=-L/opt/local/lib -R/opt/local/lib
PATH=/opt/local/bin:/opt/local/sbin:/usr/bin:/usr/local/bin:/usr/ccs/bin:/usr/sbin:/usr/openwin/bin:/opt/perl5/bin:/opt/bdb/bin:/opt/tex/bin:/opt/mysql/bin:/opt/openssl/bin:.
CFLAGS=-O3 -I/opt/local/include -fPIC -fomit-frame-pointer -m32 -mcpu=ultrasparc

beheer$ ./configure --prefix=/opt/software/mysql-5.0.18 --with-gnu-ld
--with-mysqld-user=mysql --with-openssl=/opt/local --with-berkeley-db=/opt/local
--with-big-tables
<completes>

beheer$ make
... <snipped> ...
make[2]: Entering directory `/home/beheer/jja_build_env/build/mysql-5.0.18/extra'
if gcc -DHAVE_CONFIG_H -I. -I. -I.. -I../include -I../include -I../sql  -O3
-I/opt/local/include -fPIC -fomit-frame-pointer -m32 -mcpu=ultrasparc  -DDBUG_OFF -O3
-I/opt/local/include -fPIC -fomit-frame-pointer -m32 -mcpu=ultrasparc   -DHAVE_CURSES_H
-I/home/beheer/jja_build_env/build/mysql-5.0.18/include -DHAVE_RWLOCK_T -MT comp_err.o
-MD -MP -MF ".deps/comp_err.Tpo" -c -o comp_err.o comp_err.c; \
then mv -f ".deps/comp_err.Tpo" ".deps/comp_err.Po"; else rm -f ".deps/comp_err.Tpo";
exit 1; fi
/bin/ksh ../libtool --preserve-dup-deps --mode=link gcc  -DDBUG_OFF -O3
-I/opt/local/include -fPIC -fomit-frame-pointer -m32 -mcpu=ultrasparc   -DHAVE_CURSES_H
-I/home/beheer/jja_build_env/build/mysql-5.0.18/include -DHAVE_RWLOCK_T  -L/opt/local/lib
-R/opt/local/lib  -o comp_err  comp_err.o ../mysys/libmysys.a ../dbug/libdbug.a
../strings/libmystrings.a -lpthread -lthread -lposix4 -lcrypt -lgen -lsocket -lnsl -lm 
-lpthread -lthread 
mkdir .libs
gcc -DDBUG_OFF -O3 -I/opt/local/include -fPIC -fomit-frame-pointer -m32 -mcpu=ultrasparc
-DHAVE_CURSES_H -I/home/beheer/jja_build_env/build/mysql-5.0.18/include -DHAVE_RWLOCK_T
-o comp_err comp_err.o  -L/opt/local/lib ../mysys/libmysys.a ../dbug/libdbug.a
../strings/libmystrings.a -lpthread -lthread -lposix4 -lcrypt -lgen -lsocket -lnsl -lm
-lpthread -lthread -Wl,--rpath -Wl,/opt/local/lib
../strings/libmystrings.a(strtod.o): In function `my_strtod':
strtod.c:(.text+0xf8): undefined reference to `isinf'
collect2: ld returned 1 exit status
make[2]: *** [comp_err] Error 1
make[2]: Leaving directory `/home/beheer/jja_build_env/build/mysql-5.0.18/extra'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/beheer/jja_build_env/build/mysql-5.0.18'
make: *** [all] Error 2
[25 Jan 2006 15:39] J Jans
I found this piece of information on the web explaining some of the differences in how gcc
handles calls between version 3.x and 4.x

http://lists.ee.ethz.ch/rrd-developers/msg01552.html

Although this refers to rrd-tool my guess is the same problem shows up with MySQL.

----
The configure script checks isinf with <math.h> as following.

#include <math.h>
int
main ()
{
float f = 0.0; isinf(f)
  ;
  return 0;
}

Gcc-4.0.0 or later eliminates calls to pure functions whose return
value is not used.[1] So compilation of the above code is succeed and
the HAVE_ISINF macro is defined if the system does not have isinf().

Therefore, the following isinf(a) macro is not defined.

/* Solaris */
#if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASS))
#  define HAVE_ISINF 1
#  define isinf(a) (fpclass(a) == FP_NINF || fpclass(a) == FP_PINF)
#endif
----
[3 Jul 2006 10:47] Sveta Smirnova
We have duplicate bug #20602. Reporter gives idea how to repeat and fix it.

How to repeat:
1. Load gcc 4.1 sources
2. Compile they as recommended: CC=gcc CXX=g++ ./configure --with-gnu-as
--with-as=/usr/sfw/bin/gas --without-gnu-ld --with-ld=/usr/ccs/bin/ld --disable-multilib
--prefix=/opt/sfw/gcc-4.1
make
su
make install
3. cd to directory with MySQL sources
4. BUILD/autorun.sh
CC=/opt/sfw/gcc-4.1/bin/gcc CXX=/opt/sfw/gcc-4.1/bin/g++ ./configure
--prefix=/export/home/sveta/mysql-5.0gcc
make
....
make[2]: Entering directory `/export/home/sveta/Documents/src/mysql-5.0/extra'
if /opt/sfw/gcc-4.1/bin/gcc -DHAVE_CONFIG_H -I. -I. -I.. -I../include -I../include
-I../sql    -O3 -DDBUG_OFF    -DHAVE_RWLOCK_T -MT comp_err.o -MD -MP -MF
".deps/comp_err.Tpo" -c -o comp_err.o comp_err.c; \
then mv -f ".deps/comp_err.Tpo" ".deps/comp_err.Po"; else rm -f ".deps/comp_err.Tpo";
exit 1; fi
/bin/bash ../libtool --preserve-dup-deps --mode=link --tag=CC /opt/sfw/gcc-4.1/bin/gcc 
-O3 -DDBUG_OFF    -DHAVE_RWLOCK_T   -o comp_err  comp_err.o ../mysys/libmysys.a
../dbug/libdbug.a ../strings/libmystrings.a -lpthread -lthread -lposix4 -lgen -lsocket
-lnsl -lm  -lpthread -lthread
mkdir .libs
/opt/sfw/gcc-4.1/bin/gcc -O3 -DDBUG_OFF -DHAVE_RWLOCK_T -o comp_err comp_err.o 
../mysys/libmysys.a ../dbug/libdbug.a ../strings/libmystrings.a -lpthread -lthread
-lposix4 -lgen -lsocket -lnsl -lm -lpthread -lthread
Undefined                       first referenced
 symbol                             in file
isinf                               ../strings/libmystrings.a(strtod.o)
ld: fatal: Symbol referencing errors. No output written to comp_err
collect2: ld returned 1 exit status
make[2]: *** [comp_err] Error 1
make[2]: Leaving directory `/export/home/sveta/Documents/src/mysql-5.0/extra'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/export/home/sveta/Documents/src/mysql-5.0'
make: *** [all] Error 2

It is not repeatable on Linux.
[25 Aug 2006 2:13] Shea Lovan
I have duplicated the problem on a Solaris 10 Update 2 system (no Sun Pro compiler
installed) using GCC 4.1.1.  When I attempted the change to the configure script
referenced in bug 20626, the problem was *not* resolved.

As a workaround on that system, I undefined HAVE_ISINF in both config.h and
include/my_config.h.  This appears to have provided a functional binary.
[12 Sep 2006 15:48] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/11771

ChangeSet@1.2232, 2006-09-12 15:47:48+02:00, msvensson@shellback.(none) +1 -0
  Bug#14862 undefined reference to `isinf' on SOLARIS - strings/strtod.c
   - Change the configure test looking for 'isinf' so the value returned from isinf is
used. That avoids the call to isinf being optimized away.
[16 Sep 2006 0:20] Chad MILLER
Available in 5.1.12-beta.
[16 Sep 2006 1:30] Paul DuBois
No changelog entry needed.
[8 Jan 2007 21:18] Sergei Golubchik
if the latest comments in bug#20602 are correct - the fix is incomplete
[9 Feb 2007 22:33] Andy Fiddaman
My version of gcc on Solaris still optimises out the code in PHP 5.2.1 configure, it is
clever enough to work out that the function will always return 0 at -O3.

% gcc -v
Using built-in specs.
Target: sparcv9-sun-solaris2.9
Configured with: /data/src/build/gcc-4.1.1/configure --prefix=/opt/GNUgcc
--enable-languages=c,c++ --disable-nls sparcv9-sun-solaris2.9
Thread model: posix
gcc version 4.1.1

% cat c.c
#include <math.h>
int
main ()
{
  float f = 0.0; int r = isinf(f); return r;
  return 0;
}

Since Solaris doesn't have isinf() unless you link with libsunmath.so it
fails to compile.

% gcc -o c c.c
Undefined                       first referenced
 symbol                             in file
isinf                               /var/tmp//cc0nUdeU.o
ld: fatal: Symbol referencing errors. No output written to c
collect2: ld returned 1 exit status

Configure with CFLAGS=-O3 shows that I have isinf() though.

checking for isinf with <math.h>... yes

At -O3 it compiles ok.

% gcc -O3 -o c c.c
% ./c
zsh: exit 0     ./c

I've patched configure.in with this which fixes it for me.. it's enough to stop the
compiler from optimising the test.

--- configure.in.dist   2007-02-09 21:32:35.312086444 +0000
+++ configure.in        2007-02-09 21:32:47.211204683 +0000
@@ -1962,7 +1962,7 @@
 
 # isinf() could be a function or a macro (HPUX)
 AC_MSG_CHECKING(for isinf with <math.h>)
-AC_TRY_LINK([#include <math.h>], [float f = 0.0; int r = isinf(f); return r],
+AC_TRY_LINK([#include <math.h>], [float f = rand(10); int r = isinf(f); return r],
  AC_MSG_RESULT(yes)
  AC_DEFINE(HAVE_ISINF, [1], [isinf() macro or function]),
  AC_MSG_RESULT(no))
[9 Feb 2007 22:36] Andy Fiddaman
Please ignore the reference to PHP in the last post, I need some sleep. I'm compiling
5.0.33
[5 Apr 2007 18:14] James Coleman
This suggested fix (in configure isinf test):

   float f = 0.0; int r = isinf(f); return r; return 0;

Doesn't work for gcc 4.1.1 on solaris 10. (if -O3 is used, O3 is suggested in the
manual)

It is a bit weird as the compiler itself seems to know how to call isinf.
What I see is if the optimizer can determine that the calling value is fixed then the
function is optimized out.

So, anyway, either of the three below tests determine (for gcc 4.1.1 on solaris 10) that
isinf is not available:

   float f = 1 / 0.0; int r = isinf(f); return r;

   float f = 0.0; float i = f / f; int r = isinf(i); return r;

   #include <stdlib.h>
   float f = random(); int r = isinf(f); return r;
[12 Apr 2007 10:29] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/24366

ChangeSet@1.2440, 2007-04-12 10:29:22+02:00, msvensson@pilot.blaudden +1 -0
  Bug#14862 undefined reference to `isinf' on SOLARIS - strings/strtod.c
   - Rely only on HAVE_ISINF to determine if 'isinf' can be used.
[26 Apr 2007 13:35] Bugs System
Pushed into 5.0.42
[26 Apr 2007 13:37] Bugs System
Pushed into 5.1.18-beta
[26 Apr 2007 18:55] Paul DuBois
No changelog entry needed.
[21 May 2007 16:39] Philip Walker
I have the same problem on Solaris 10, AMD Sun Fire V40z.  GCC version=4.1.2 ld
version=Solaris Link Editors 5.10-1.482  trying to install 5.0.41 and 5.1.18-beta. If
patch has been included in 5.1.18-beta, it is not working for my case.
[21 May 2007 17:59] Philip Walker
tried MySQL 4.1.22 and it choked on the libmystrings.a (strtod.o) undefined isinf also. I
was still using GCC 4.1.2
[24 May 2007 15:32] Philip Walker
Loaded GCC 4.2.0 and tried to compile MySQL 4.1.22 again, got same error about
libmystrings.a
[24 May 2007 20:16] Magnus Blaudd
This problem was reported and fixed in MySQL 5.0 and higer. If you are having a problem in
4.1 you need to open a separate bug for that.