Hi, The following doesn't link on Solaris 8: $ cat > foo.cc #include <cmath> int main() { float f = 0.0; f = std::acos(f); } $ g++ foo.cc /tmp/ccEWrnML.o(.gnu.linkonce.t._ZSt4acosf+0xc): In function `std::acos(float)': : undefined reference to `acosf' $ While the following does link on the same Solaris 8: $ cat > foo.cc #include <cmath> int main() { float f = 0.0; f = ::acos(f); } $ g++ foo.cc $ This looks like a regression, I am able to reproduce the problem with gcc 3.4.2 and 3.4.1, but not gcc 3.3.4. Maybe it is related to this paragraph in the release notes: Many C math library functions are now recognized as built-ins and optimized.
hmm, something is wrong. libstdc++ should have included that function, why it does not I do not know.
I'm pretty sure it started with this commit: 2003-11-15 Roger Sayle <roger@eyesopen.com> * include/c_std/std_cmath.h: Don't import C99's float transcendentals into the __gnu_cxx::__c99_binding namespace. (acos, asin, atan, atan2, ceil, cosh, exp, floor, fmod, frexp, ldexp, log, log10, modf, pow, sinh, tan, tanh): Implement using GCC's math builtins, i.e. __builtin_foo. * libmath/stubs.c (acosf, acosl, asinf, asinl, atanf, atanl, ceilf, ceill, floorf, floorl, fmodf, fmodl, frexpf, frexpl, ldexpf, ldexpl, modff, modfl): Provide stub implementations. Roger, can you please have a look? Thanks!
Subject: Re: <cmath> calls acosf(), ceilf(), and other functions missing from system libraries "pinskia at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes: | hmm, something is wrong. libstdc++ should have included that | function, why it does not I do not know. It is time for GCC to ship his versions of those functions in libgcc -- usable by all other front-ends. Sadly, a patch to that effect is not appropriate for 3.4.x. -- Gaby
My apologies for taking so long to analyse this problem. My conclusions are that this is some strange solaris shared library thing. Adding "-static" to the command line resolves the problem. Indeed, so it should as we provide an implementation of "acosf" in libstdc++-3/libmath/stubs.o [indeed my patch that added an implementation is mentioned in comment #2]. The problem appears to be weak symbols on Solaris? nm objdir/sparc-sun-solaris2.8/libstdc++-v3/src/.libs/libstdc++.a | grep acos U acos 00000000 T acosf 00000028 T acosl nm clean/sparc-sun-solaris2.8/libstdc++-v3/src/.libs/libstdc++.so | grep acos U acos@@SUNW_1.1 0009b9bc t acosf 0009b9e4 t acosl So the symbols have global linkage in libstdc++.a but only local linkage in libstdc++.so. Does this ring a bell for anyone?
The symbols are properly exported if the compiler was configured to use the Sun tools. The symbols are indeed not exported if the compiler was configured to use the GNU tools. Declaring them in config/linker-map.gnu might have helped :-) gax% nm libstdc++.a | grep cosf 00000000 T acosf 000002dc T cosf gax% nm libstdc++.so | grep cosf 000a24cc t acosf 000a27a8 T cosf
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2004-10/msg00209.html>.
Ah right, my compiler is configured to use the GNU tools.
Subject: Bug 17505 CVSROOT: /cvs/gcc Module name: gcc Changes by: sayle@gcc.gnu.org 2004-10-05 02:30:49 Modified files: libstdc++-v3 : ChangeLog libstdc++-v3/config: linker-map.gnu Log message: PR libstdc++/17505 * config/linker-map.gnu: Synchronize the current list of stub functions from libmath. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/ChangeLog.diff?cvsroot=gcc&r1=1.2680&r2=1.2681 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/config/linker-map.gnu.diff?cvsroot=gcc&r1=1.70&r2=1.71
Subject: Bug 17505 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: sayle@gcc.gnu.org 2004-10-05 05:42:33 Modified files: libstdc++-v3 : ChangeLog libstdc++-v3/config: linker-map.gnu Log message: PR libstdc++/17505 * config/linker-map.gnu: Synchronize the current list of stub functions from libmath. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.2224.2.183&r2=1.2224.2.184 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/config/linker-map.gnu.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.52.4.10&r2=1.52.4.11
Fixed.