NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

toolchain/40468: Optimizer bug suspected -- porting devel/libffi to NetBSD/powerpc



>Number:         40468
>Category:       toolchain
>Synopsis:       Optimizer bug suspected -- porting devel/libffi to 
>NetBSD/powerpc
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Jan 24 22:40:00 +0000 2009
>Originator:     Havard Eidnes
>Release:        NetBSD 4.0
>Organization:
        I Try, Inc.
>Environment:
System: NetBSD malus.urc.uninett.no 4.0 NetBSD 4.0 (GENERIC) #0: Sun Dec 16 
00:27:58 PST 2007 
builds@wb30:/home/builds/ab/netbsd-4-0-RELEASE/macppc/200712160005Z-obj/home/builds/ab/netbsd-4-0-RELEASE/src/sys/arch/macppc/compile/GENERIC
 macppc
Compiler: gcc version 4.1.2 20061021 prerelease (NetBSD nb3 20061125)
Architecture: powerpc
Machine: macppc
>Description:
        While trying to update and port devel/libffi to NetBSD/macppc 4.0,
        I found out that even after doing basic porting, some of the
        self-tests fail.

        Closer inspection reveals that there is one particular self-test
        which involves a function which takes two by-value arguments
        consisting of an (ideally) 6-byte struct, and which returns
        such a struct as a return value.

        When the self-test is compiled -O0 or -O1, the test prints
        the expected values.  When it's compiled either of

        -O2, -O3, -Os, or -O2 -fomit-frame-pointer

        the output does not match what is expected.

        This can be verified on NetBSD/macppc by first doing
        "make" in devel/libffi after applying the attached patch, decending
        into work/libffi-3.0.8/testsuite/libffi.call and doing e.g.

        cc -O1 -o /tmp/cls_6byte -I../.. -I../../include cls_6byte.c \
                ../../.libs/libffi.a ../../.libs/libffi_convenience.a

        and executing the result.  With the above, it prints

127 120 1 128 12 128 9 127: 139 248 10 255
res: 139 248 10 255
127 120 1 128 12 128 9 127: 139 248 10 255
res: 139 248 10 255

        with the failing optimization flags, it prints

127 120 1 128 12 128 9 127: 139 248 10 255
res: 139 248 10 255
0 120 1 128 12 128 9 127: 12 248 10 255
res: 12 248 10 255

>How-To-Repeat:
        Apply this patch to upgrade / adapt devel/libffi, and
        make sure to have dejagnu installed.  Watch
        "make test" print 4 unexpected failures.

        Inspection of work/libffi-3.0.8/testsuite/libffi.log
        will reveal the offending test and the expected and actual
        output from the test (and it's reproducability as above).

Index: Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/devel/libffi/Makefile,v
retrieving revision 1.8
diff -u -p -r1.8 Makefile
--- Makefile    11 Oct 2008 22:33:56 -0000      1.8
+++ Makefile    24 Jan 2009 22:02:56 -0000
@@ -1,7 +1,7 @@
 # $NetBSD: Makefile,v 1.8 2008/10/11 22:33:56 dholland Exp $
 #
 
-DISTNAME=      libffi-3.0.6
+DISTNAME=      libffi-3.0.8
 CATEGORIES=    devel
 MASTER_SITES=  ftp://sourceware.org/pub/libffi/
 
@@ -18,6 +18,8 @@ USE_TOOLS+=   pkg-config
 USE_LANGUAGES= c c++
 INFO_FILES=    # PLIST
 
+TEST_TARGET=   check
+
 PKGCONFIG_OVERRIDE+=   libffi.pc.in
 
 .include "../../mk/bsd.pkg.mk"
Index: distinfo
===================================================================
RCS file: /cvsroot/pkgsrc/devel/libffi/distinfo,v
retrieving revision 1.9
diff -u -p -r1.9 distinfo
--- distinfo    11 Oct 2008 22:33:56 -0000      1.9
+++ distinfo    24 Jan 2009 22:02:56 -0000
@@ -1,7 +1,10 @@
 $NetBSD: distinfo,v 1.9 2008/10/11 22:33:56 dholland Exp $
 
-SHA1 (libffi-3.0.6.tar.gz) = 04a5f38c76dfe3e078767645ca89f2ff71721104
-RMD160 (libffi-3.0.6.tar.gz) = da8f547209e6b13dc7be86ea29ad5fa5e85844e5
-Size (libffi-3.0.6.tar.gz) = 717171 bytes
+SHA1 (libffi-3.0.8.tar.gz) = ce44d10c39d9a37479c8777e206cac0f36c48712
+RMD160 (libffi-3.0.8.tar.gz) = 4144f64e79ebf95161a6afd58ceaeef8372b5e57
+Size (libffi-3.0.8.tar.gz) = 722834 bytes
 SHA1 (patch-ac) = 307c08e8e3df5f079c0b2f63da58bb59fc089d30
 SHA1 (patch-ad) = 8901a00abe25422e3e35f321a5fb89311185fc0b
+SHA1 (patch-ae) = bf16fd422f2d705324bd8a113f5681252f6c6bdc
+SHA1 (patch-af) = cb6cdffa127f34b1e6f299f76de08bff20ab83dd
+SHA1 (patch-ag) = 1d0f5dbfafeff21db44d305daa96573f827b222a
--- /dev/null   2009-01-24 04:35:54.000000000 +0100
+++ patches/patch-ae    2009-01-18 15:47:54.000000000 +0100
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- configure.ac.orig  2008-12-19 17:12:30.000000000 +0100
++++ configure.ac
+@@ -118,7 +118,7 @@ case "$host" in
+   powerpc-*-aix* | rs6000-*-aix*)
+       TARGET=POWERPC_AIX; TARGETDIR=powerpc
+       ;;
+-  powerpc-*-freebsd*)
++  powerpc-*-freebsd* | powerpc-*-netbsd*)
+       TARGET=POWERPC_FREEBSD; TARGETDIR=powerpc
+       ;;
+   powerpc*-*-rtems*)
--- /dev/null   2009-01-24 04:35:54.000000000 +0100
+++ patches/patch-af    2009-01-18 15:48:54.000000000 +0100
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- configure.orig     2009-01-18 15:46:33.000000000 +0100
++++ configure
+@@ -21033,7 +21033,7 @@ case "$host" in
+   powerpc-*-aix* | rs6000-*-aix*)
+       TARGET=POWERPC_AIX; TARGETDIR=powerpc
+       ;;
+-  powerpc-*-freebsd*)
++  powerpc-*-freebsd* | powerpc-*-netbsd*)
+       TARGET=POWERPC_FREEBSD; TARGETDIR=powerpc
+       ;;
+   powerpc*-*-rtems*)
--- /dev/null   2009-01-24 04:35:54.000000000 +0100
+++ patches/patch-ag    2009-01-23 18:05:01.000000000 +0100
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- testsuite/libffi.call/float2.c.orig        2008-01-29 16:15:20.000000000 
+0100
++++ testsuite/libffi.call/float2.c
+@@ -44,7 +44,7 @@ int main (void)
+   /* This is ifdef'd out for now. long double support under SunOS/gcc
+      is pretty much non-existent.  You'll get the odd bus error in library
+      routines like printf().  */
+-  printf ("%Lf, %Lf, %Lf, %Lf\n", ld, ldblit(f), ld - ldblit(f), 
LDBL_EPSILON);
++  printf ("%Lf, %Lf, %Lf, %f\n", ld, ldblit(f), ld - ldblit(f), LDBL_EPSILON);
+ #endif
+ 
+   /* These are not always the same!! Check for a reasonable delta */
>Fix:
        Sorry, don't know, so none provided.



Home | Main Index | Thread Index | Old Index