Subject: Re: Optimizer bug in NetBSD/SPARC64 1.5?
To: None <port-sparc64@netbsd.org>
From: Greg Earle <earle@isolar.DynDNS.ORG>
List: port-sparc64
Date: 02/15/2001 09:17:39
> This smacks of weirdness in /usr/src/gnu/dist/gawk/builtin.c::format_tree(),
> maybe in the "unsigned long" stuff in the handlers for "%d"/"%i"? I tried
> to run (g)awk under GDB, but attempts to print out variables at breakpoints
> give me "Error accessing memory address 0x7NN: Invalid argument." errors.)
[Moving this to port-sparc64. I thought both mailing lists were the same,
obviously they aren't. Sorry folks. Mea culpa. I've joined the port-sparc64
list now, which I should've done as soon as I got the Ultra 5+. Sorry!]
OK, I think this is the key problem. It looks like pretty much exactly the
opposite of Andrei Petrov's problem with converting from u_int64_t to double:
(Reduced example from gawk's format_tree())
netbsd4me# uname -mr
1.5 sparc64
netbsd4me# cat unsignedlongcastbug.c
#include <stdio.h>
main()
{
double tmpval = 1;
int dval;
long lval;
unsigned long uval;
dval = (int) tmpval;
lval = (long) tmpval;
uval = (unsigned long) tmpval;
(void) printf("tmpval/dval/lval/uval == %e, %d, %ld, %lu\n",
tmpval, dval, lval, uval);
(void) exit(0);
}
netbsd4me# cc -o unsignedlongcastbug unsignedlongcastbug.c
netbsd4me# unsignedlongcastbug
tmpval/dval/lval/uval == 1.000000e+00, 1, 1, 13830554455654793216
[Later on]
I went to the port-sparc64 mailing list archives and noticed that Matt said:
"there are known issues with 'float and 'double' support on sparc64. you
should compile with -msoft-quad-float."
Well now, lookie here:
netbsd4me# cc -msoft-quad-float -o unsignedfloatbug unsignedfloatbug.c
netbsd4me# ./unsignedfloatbug
tmpval/dval/lval/uval == 1.000000e+00, 1, 1, 1
I just looked at the -current "gawk" Makefile and see that this was added:
*** 19 ****
--- 20,23 ----
+
+ .if (${MACHINE_ARCH} == "sparc64")
+ CFLAGS+= -msoft-quad-float
+ .endif
Looks like you damn guys are ahead of me already :-)
(Wonder if there should be a code check in the tree to look for double/quad
references, and flag 'em so that they'll all be built with "-msoft-quad-float"
when being built under NetBSD/SPARC64?)
Whee! Aren't 64-bit issues *fun*? :-)
- Greg