Adriaan van Os wrote:
So, I now tried the testsuite with the gcc-3.4.3 based compiler. The result- several failures and crashes. I tried in C and reported it as a gcc bug http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19993.
The answer to my bug report, I believe, is nonsense.
: ------- Additional Comment [54]#1 From [55]Andrew Pinski 2005-02-16 : 02:01 ------- : First: : printf( "sin( 1.2345) = %.30f = %.30f\n", R, R); : : Is wrong, as R is pased as a two doubles (as this is the how 128bit long double : s are done in IBM's : 128bit format).
Indeed this C statement is wrong. One doesn't have to go into target specifics. The `%f' format expects an argument of type `double', as documented. Since `printf' is a varargs function, it doesn't do argument conversions (unlike Pascal's `WriteLn'), so passing any other type than `double' is wrong. So, this part of the answer is no nonsense.
: Second the following shows the correct result: : #include <stdio.h> : #include <math.h> : : int main( void ) : { : long double R; : R = sin( 1.2345); : printf( "sizeof( long double) = %d\n", sizeof( long double)); : printf( "sin( 1.2345) = %.30f = %.30f\n", (double)R, (double)R); : return 0; : }
This program is correct. However `sin' returns a `double' (this applies to your original test program as well), so all the program really does is convert a `double' to `long double' and back to `double' (both in the correct way, i.e. preserving values, not bit-patterns) and print this. (In C, `sin' is not a built-in, and it doesn't adapt to argument types, so it's just a plain function with one fixed argument and result type.) So, this part of the answer is not wrong, but not very meaningful, either.
BTW, to compute sine in `long double', you can use `sinl' if available. To print `long double', you can use `%Lf', again if available. It might be a GNU extension and not available at all on Mac OS X, or called differently there, though. And if it does, it might be questionable if the libc expects a 64 or 128 bit `long double' (since libc is fixed and doesn't know about the current compiler options).
The latter is probably also the problem with GPC. With `-mlong-double-128', you'll have to at least recompile the RTS with this option. (Then it won't work with 64 bit `long double' anymore, of course.)
Do I have to rebuild the gpc runtime library when using -mlong-double-128 ?
Yes, all libraries must be built with 128 bit support. I don't know the status of libc on this target, but for the GPC RTS you need to give this option, unless it's the default (I seem to understand it will be so in gcc-4.x).
By adding that option to CFLAGS in Makefile.in ?
CFLAGS also apply to building the compiler itself. I suppose this option won't hurt (if used througout, i.e. not just to recompile the frontend or so). Otherwise you could try RTSFLAGS (though I'm not sure if libgcc2.a needs it, so CFLAGS might be perferable). BTW, it's easier to set make options on the command line than changing the Makefiles.
Frank