On Wed, 2008-02-13 at 05:54 +1100, Peter Jeremy wrote: > On Tue, Feb 12, 2008 at 06:23:18PM +0000, Tom Evans wrote: > >I've encountered a strange bug deploying one of our C++ applications on > >amd64. We tend to build most of our applications on i386, even if the > >deployment box is amd64, as we aren't 100% sure that our code is 64 bit > >clean yet. The boxes in question both run 6.2-RELEASE, at various kernel > >release patchsets: > ... > >With an i386 binary running on an amd64 host, when we write a small > >double, with value close to 0.1, to a C++ iostream, it is formatted > >incorrectly. > > See kern/102424 and amd64/112222. >
Thanks Peter! Going on the information in those PRs, I have made a patch to the libc/gdtoa/Makefile.inc which forces gdtoa_dtoa.c to be built with -fno-gcse. This corrects the formatting bug, and allows programs to execute correctly. The patch isn't quite to my liking, as it also changes how gdtoa_dtoa.c is compiled for the native 64-bit library, so ideally it would only include that additional target rule when cross-compiling the lib32 build, but I could not determine how to detect that scenario. Also, BSD make isn't my forté, is there a better way to add a CFLAG for a single target? Redefining the rules from share/mk/bsd.lib.mk seems fragile. I will update the PRs with my patch as well, but it is small enough to include here as well. Cheers Tom
--- /usr/src/lib/libc/gdtoa/Makefile.inc Fri Sep 29 16:17:22 2006 +++ /usr/src2/lib/libc/gdtoa/Makefile.inc Wed Feb 13 11:42:54 2008 @@ -16,3 +16,10 @@ gdtoa_${src}: ln -sf ${.CURDIR}/../../contrib/gdtoa/${src} ${.TARGET} .endfor + +gdtoa_dtoa.o: + ${CC} ${PO_FLAG} ${CFLAGS} -fno-gcse -c gdtoa_dtoa.c -o gdtoa_dtoa.o + +gdtoa_dtoa.So: + ${CC} ${PICFLAG} -DPIC ${CFLAGS} -fno-gcse -c gdtoa_dtoa.c -o gdtoa_dtoa.So +
signature.asc
Description: This is a digitally signed message part