Date: Thu, 16 Aug 2007 16:42:00 GMT From: Simun Mikecin <numisemis@yahoo.com> To: freebsd-gnats-submit@FreeBSD.org Subject: amd64/115581: [fix] -mfancy-math-387 has no effect Message-ID: <200708161642.l7GGg0Vu056249@www.freebsd.org> Resent-Message-ID: <200708161650.l7GGo13e052994@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 115581 >Category: amd64 >Synopsis: [fix] -mfancy-math-387 has no effect >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-amd64 >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Aug 16 16:50:01 GMT 2007 >Closed-Date: >Last-Modified: >Originator: Simun Mikecin >Release: FreeBSD/amd64 7-CURRENT >Organization: >Environment: >Description: 32-bit compatibility libraries on FreeBSD/amd64 are compiled using -mfancy-math-387 gcc option. As stated in gcc(1): -mno-fancy-math-387 Some 387 emulators do not support the "sin", "cos" and "sqrt" instructions for the 387. Specify this option to avoid generating those instructions. This option is the default on FreeBSD, OpenBSD and NetBSD. This option is overridden when -march indicates that the target cpu will always have an FPU and so the instruction will not need emulation. As of revision 2.6.1, these instructions are not generated unless you also use the -funsafe-math-optimizations switch. So, using just -mfancy-math-387 has no effect. It should be used in combination with -funsafe-math-optimizations or it should not be used. >How-To-Repeat: double test(double x) { return sin(x); } Try to compile using: gcc -m32 -S -mfancy-math-387 -funsafe-math-optimizations -O2 -march=athlon64 test.c and with: gcc -m32 -S -mfancy-math-387 -O2 -march=athlon64 test.c There will be a difference in assembler output. First one will use machine instruction 'fsin' and the second one will use a libm routine called 'sin'. >Fix: Patch attached with submission follows: --- Makefile.inc1.orig Tue Jul 10 18:39:36 2007 +++ Makefile.inc1 Thu Aug 16 18:30:44 2007 @@ -238,7 +238,7 @@ .else LIB32CPUTYPE= ${TARGET_CPUTYPE} .endif -LIB32FLAGS= -m32 -march=${LIB32CPUTYPE} -mfancy-math-387 -DCOMPAT_32BIT \ +LIB32FLAGS= -m32 -march=${LIB32CPUTYPE} -mfancy-math-387 -funsafe-math-optimizations -DCOMPAT_32BIT \ -iprefix ${LIB32TMP}/usr/ \ -L${LIB32TMP}/usr/lib32 \ -B${LIB32TMP}/usr/lib32 >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200708161642.l7GGg0Vu056249>