libtool
[Top][All Lists]
Advanced

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

libtool C++ link bug with -lm functions with Sun Workshop compiler


From: Tim Mooney
Subject: libtool C++ link bug with -lm functions with Sun Workshop compiler
Date: Wed, 19 Mar 2008 19:03:38 -0500 (CDT)
User-agent: Alpine 1.10 (SOC 962 2008-03-14)


I think I have discovered a bug in libtool's link behavior with the
Sun Workshop C++ compiler when creating a C++ library that requires libm.
I observed it on x86_64-sun-solaris2.10, but it may also affect the
Workshop C++ compiler on Linux too.  I found it when trying to build
GNU aspell 0.60.5.

If you have a configure.ac that calls AC_LANG([C++]), any subsequent
AC_CHECK_FUNCS will result in a link that uses the C++ compiler.  Because
the C++ compiler initiates the link, it automatically adds some libraries
to the final call to ld.  Which libraries it adds depends on what flags
CC was passed (arguments like -library=stlport4 change what C++ libraries
are automatically added).  The C++ compiler appears to always add `-lm
-lc' after the C++ libraries, though.

That means that doing something like


AC_INIT(lttest, 0.60.5)
AC_CONFIG_SRCDIR(configure.ac)
AC_PROG_CXX
AC_LANG([C++])

AC_CHECK_FUNCS(sqrt)
AC_OUTPUT


will always detect sqrt(), because the C++ compiler added `-lm -lc'
behind the scenes.

When libtool is called to generate a C++ library on Solaris, it doesn't
add -lm, though.  It only adds -lc.  That will result in link failures
if functions like sqrt(), floor(), etc. from libm are used by the C++
library.

Is the correct fix to just add -lm to the postdeps for Solaris and Linux
when using the Workshop compiler, or is there some other method that
should be used?  I'm talking about changing all instances of

      _LT_AC_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'

to

      _LT_AC_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun -lm'

Tim
--
Tim Mooney                              address@hidden
Information Technology Services         (701) 231-1076 (Voice)
Room 242-J6, IACC Building              (701) 231-8541 (Fax)
North Dakota State University, Fargo, ND 58105-5164




reply via email to

[Prev in Thread] Current Thread [Next in Thread]