Bug 17505 - [3.4 Regression] <cmath> calls acosf(), ceilf(), and other functions missing from system libraries
Summary: [3.4 Regression] <cmath> calls acosf(), ceilf(), and other functions missing ...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 3.4.2
: P2 normal
Target Milestone: 3.4.3
Assignee: roger
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2004-09-15 18:32 UTC by papadopo
Modified: 2005-07-23 22:49 UTC (History)
2 users (show)

See Also:
Host: sparc-sun-solaris2.8
Target: sparc-sun-solaris2.8
Build: sparc-sun-solaris2.8
Known to work: 4.0.0 3.3.3
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description papadopo 2004-09-15 18:32:31 UTC
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.
Comment 1 Andrew Pinski 2004-09-15 18:37:52 UTC
hmm, something is wrong. libstdc++ should have included that function, why it does not I do not 
know.
Comment 2 Paolo Carlini 2004-09-15 18:44:55 UTC
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!
Comment 3 Gabriel Dos Reis 2004-09-15 19:33:21 UTC
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
Comment 4 roger 2004-10-03 00:20:32 UTC
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?
Comment 5 Eric Botcazou 2004-10-03 06:59:45 UTC
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
Comment 6 Andrew Pinski 2004-10-03 18:53:33 UTC
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2004-10/msg00209.html>.
Comment 7 papadopo 2004-10-04 07:22:13 UTC
Ah right, my compiler is configured to use the GNU tools.
Comment 8 CVS Commits 2004-10-05 02:30:58 UTC
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

Comment 9 CVS Commits 2004-10-05 05:42:44 UTC
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

Comment 10 Andrew Pinski 2004-10-05 11:24:46 UTC
Fixed.