[perl #34549] atan2() isn't IEEE compliant on OpenBSD/*BSD/Cygwin/Solaris

Andy Dougherty doughera at lafayette.edu
Tue Mar 31 14:31:07 UTC 2009


On Fri, 27 Mar 2009, Rolf Grossmann wrote:

> When I was building parrot to verify the fix actually works for parrot aswell,
> I found one small remaining problem. When using g++ as the linker, the
> values-xpg4 does not seem to have the expected effect. I've verified with -v
> that it is actually used, still atan2 is giving the wrong result. Can you
> verify that, and if so, do you have an idea what's causing it?

Thanks for trying that out.  I hadn't tried with parrot, just with a 
simple C program to directly test the atan2 function.

I see the same thing.  Running 'nm' on the values-xpg4 file reveals that 
it doesn't directly set _lib_version, but instead sets an external 
variable __xpg4.  Running 'nm' on /lib/libm.so, shows _lib_version is 
defined there as "WEAK".  If you link a test program with values-xpg4.o 
and -lm, then _lib_version gets set to -1.  If you link the test program 
with just values-xpg4.o and no -lm, then _lib_version gets set to +1.

Once you throw g++ into the mix, however, things change slightly.  At 
least on the version I have, the GNU libstdc++.so defines _lib_version, so 
the WEAK version in -lm doesn't get used.  However, libstdc++.so doesn't 
respect the __xpg4 global, so setting __xpg4 doesn't work.

Continuing on this route, the only fix for g++ seems to be to include a 
values*.o file that correctly and directly sets _lib_version to -1. If the 
user has Sun's compiler installed, then there's a values-xi.o file that 
does just this (and this is what the -xlibmieee flag does). If the user 
does not have Sun's compiler installed, then there is no such file.  We 
could, perhaps, create one, but I don't know what else, if anything, 
should be in that file.

I think, perhaps, the better route is to return to the atan2 op in parrot. 
Configure.pl could test whether the given compiler + flags give the 
correct behavior for the "exceptional" cases.  If so, do nothing.  If not, 
include code to handle those exceptional cases.

I think that route may ultimately be less work for parrot.

-- 
    Andy Dougherty		doughera at lafayette.edu


More information about the parrot-dev mailing list