Bug 42243 - [4.5 Regression] powerpc-apple-darwin9 libffi failures
Summary: [4.5 Regression] powerpc-apple-darwin9 libffi failures
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libffi (show other bugs)
Version: 4.5.0
: P4 normal
Target Milestone: 4.5.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-12-01 18:52 UTC by Dominique d'Humieres
Modified: 2009-12-15 13:21 UTC (History)
4 users (show)

See Also:
Host: powerpc-apple-darwin9
Target: powerpc-apple-darwin9
Build: powerpc-apple-darwin9
Known to work:
Known to fail:
Last reconfirmed: 2009-12-02 12:35:27


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dominique d'Humieres 2009-12-01 18:52:28 UTC
Bootstrap on powerpc-apple-darwin9 at revision 154872 is broken:

...
libtool: compile:  /opt/gcc/darwin_buildw/./gcc/xgcc -B/opt/gcc/darwin_buildw/./gcc/ -B/opt/gcc/gcc4.5w/powerpc-apple-darwin9/bin/ -B/opt/gcc/gcc4.5w/powerpc-apple-darwin9/lib/ -isystem /opt/gcc/gcc4.5w/powerpc-apple-darwin9/include -isystem /opt/gcc/gcc4.5w/powerpc-apple-darwin9/sys-include -m64 -DHAVE_CONFIG_H -I. -I../../../../gcc-4.5-work/libffi -I. -I../../../../gcc-4.5-work/libffi/include -Iinclude -I../../../../gcc-4.5-work/libffi/src -Wall -g -fexceptions -g -O2 -m64 -MT src/powerpc/ffi_darwin.lo -MD -MP -MF src/powerpc/.deps/ffi_darwin.Tpo -c ../../../../gcc-4.5-work/libffi/src/powerpc/ffi_darwin.c  -fno-common -DPIC -o src/powerpc/.libs/ffi_darwin.o
../../../../gcc-4.5-work/libffi/src/powerpc/ffi_darwin.c: In function 'ffi_prep_args':
../../../../gcc-4.5-work/libffi/src/powerpc/ffi_darwin.c:160:6: error: lvalue required as increment operand
../../../../gcc-4.5-work/libffi/src/powerpc/ffi_darwin.c: In function 'ffi_call':
../../../../gcc-4.5-work/libffi/src/powerpc/ffi_darwin.c:499:6: warning: passing argument 6 of 'ffi_call_AIX' from incompatible pointer type
../../../../gcc-4.5-work/libffi/src/powerpc/ffi_darwin.c:472:13: note: expected 'void (*)(void)' but argument is of type 'void (*)(struct extended_cif *, long unsigned int * const)'
../../../../gcc-4.5-work/libffi/src/powerpc/ffi_darwin.c:503:9: warning: passing argument 6 of 'ffi_call_DARWIN' from incompatible pointer type
../../../../gcc-4.5-work/libffi/src/powerpc/ffi_darwin.c:474:13: note: expected 'void (*)(void)' but argument is of type 'void (*)(struct extended_cif *, long unsigned int * const)'
...

Likely due to revision 154855:

Subject: Bug 35484

Author: dje
Date: Mon Nov 30 23:34:33 2009
New Revision: 154855

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=154855
Log:
2009-11-30  David Edelsohn  <edelsohn@gnu.org>

        PR target/35484
        * src/powerpc/ffitarget.h (POWERPC64): Define for PPC64 Linux and
        AIX64.
        * src/powerpc/aix.S: Implement AIX64 version.
        * src/powerpc/aix_closure.S: Implement AIX64 version.
        (ffi_closure_ASM): Use extsb, lha and displament addresses.
        * src/powerpc/ffi_darwin.c (ffi_prep_args): Implement AIX64
        support.
        (ffi_prep_cif_machdep): Same.
        (ffi_call): Same.
        (ffi_closure_helper_DARWIN): Same.

Modified:
    trunk/libffi/ChangeLog
    trunk/libffi/src/powerpc/aix.S
    trunk/libffi/src/powerpc/aix_closure.S
    trunk/libffi/src/powerpc/ffi_darwin.c
    trunk/libffi/src/powerpc/ffitarget.h

See also http://gcc.gnu.org/ml/gcc-regression/2009-12/msg00004.html .
Comment 1 Dominique d'Humieres 2009-12-01 19:57:03 UTC
I have no idea if this the right fix, but the following patch allows bootstrap to proceed:

--- ../_gcc_clean/libffi/src/powerpc/ffi_darwin.c	2009-12-01 13:16:43.000000000 +0100
+++ ../gcc-4.5-work/libffi/src/powerpc/ffi_darwin.c	2009-12-01 20:51:19.000000000 +0100
@@ -157,7 +157,7 @@ void ffi_prep_args(extended_cif *ecif, u
 	case FFI_TYPE_LONGDOUBLE:
 #ifdef POWERPC64
 	  if (fparg_count < NUM_FPR_ARG_REGISTERS)
-	    *((long double *) fpr_base)++ = *(long double *) *p_argv;
+	    *(long double *) fpr_base++ = *(long double *) *p_argv;
 	  else
 	    *(long double *) next_arg = *(long double *) *p_argv;
 	  next_arg += 2;
Comment 2 Dominique d'Humieres 2009-12-02 06:42:04 UTC
With the patch in comment #1, the test results are:

Running target unix
Using /sw/share/dejagnu/baseboards/unix.exp as board description file for target.
Using /sw/share/dejagnu/config/unix.exp as generic interface file for target.
Using /opt/gcc/gcc-4.5-work/libffi/testsuite/config/default.exp as tool-and-target-specific interface file.
Running /opt/gcc/gcc-4.5-work/libffi/testsuite/libffi.call/call.exp ...
FAIL: libffi.call/cls_double_va.c -O0 -W -Wall output pattern test, is -0.0
FAIL: libffi.call/cls_longdouble.c -O0 -W -Wall execution test
FAIL: libffi.call/cls_longdouble_va.c -O0 -W -Wall output pattern test, is -0.0
FAIL: libffi.call/float.c -O0 -W -Wall execution test
FAIL: libffi.call/float4.c -O0 -W -Wall execution test
FAIL: libffi.call/many.c -O0 -W -Wall execution test
FAIL: libffi.call/nested_struct5.c -O0 -W -Wall execution test
FAIL: libffi.call/return_dbl.c -O0 -W -Wall execution test
FAIL: libffi.call/return_dbl1.c -O0 -W -Wall execution test
FAIL: libffi.call/return_dbl2.c -O0 -W -Wall execution test
FAIL: libffi.call/return_fl.c -O0 -W -Wall execution test
FAIL: libffi.call/return_fl1.c -O0 -W -Wall execution test
FAIL: libffi.call/return_fl2.c -O0 -W -Wall execution test
FAIL: libffi.call/return_fl3.c -O0 -W -Wall execution test
FAIL: libffi.call/return_ldl.c -O0 -W -Wall execution test
FAIL: libffi.call/cls_double_va.c -O2 output pattern test, is -0.0
FAIL: libffi.call/cls_longdouble.c -O2 execution test
FAIL: libffi.call/cls_longdouble_va.c -O2 output pattern test, is -0.0
FAIL: libffi.call/float.c -O2 execution test
FAIL: libffi.call/float4.c -O2 execution test
FAIL: libffi.call/many.c -O2 execution test
FAIL: libffi.call/return_dbl.c -O2 execution test
FAIL: libffi.call/return_dbl1.c -O2 execution test
FAIL: libffi.call/return_dbl2.c -O2 execution test
FAIL: libffi.call/return_fl.c -O2 execution test
FAIL: libffi.call/return_fl1.c -O2 execution test
FAIL: libffi.call/return_fl2.c -O2 execution test
FAIL: libffi.call/return_fl3.c -O2 execution test
FAIL: libffi.call/return_ldl.c -O2 execution test
FAIL: libffi.call/cls_double_va.c -O3 output pattern test, is -0.0
FAIL: libffi.call/cls_longdouble.c -O3 execution test
FAIL: libffi.call/cls_longdouble_va.c -O3 output pattern test, is -0.0
FAIL: libffi.call/float.c -O3 execution test
FAIL: libffi.call/float4.c -O3 execution test
FAIL: libffi.call/many.c -O3 execution test
FAIL: libffi.call/return_dbl.c -O3 execution test
FAIL: libffi.call/return_dbl1.c -O3 execution test
FAIL: libffi.call/return_dbl2.c -O3 execution test
FAIL: libffi.call/return_fl.c -O3 execution test
FAIL: libffi.call/return_fl1.c -O3 execution test
FAIL: libffi.call/return_fl2.c -O3 execution test
FAIL: libffi.call/return_fl3.c -O3 execution test
FAIL: libffi.call/return_ldl.c -O3 execution test
FAIL: libffi.call/cls_double_va.c -Os output pattern test, is -0.0
FAIL: libffi.call/cls_longdouble.c -Os execution test
FAIL: libffi.call/cls_longdouble_va.c -Os output pattern test, is -0.0
FAIL: libffi.call/float.c -Os execution test
FAIL: libffi.call/float4.c -Os execution test
FAIL: libffi.call/many.c -Os execution test
FAIL: libffi.call/return_dbl.c -Os execution test
FAIL: libffi.call/return_dbl1.c -Os execution test
FAIL: libffi.call/return_dbl2.c -Os execution test
FAIL: libffi.call/return_fl.c -Os execution test
FAIL: libffi.call/return_fl1.c -Os execution test
FAIL: libffi.call/return_fl2.c -Os execution test
FAIL: libffi.call/return_fl3.c -Os execution test
FAIL: libffi.call/return_ldl.c -Os execution test
FAIL: libffi.call/cls_double_va.c -O2 -fomit-frame-pointer output pattern test, is -0.0
FAIL: libffi.call/cls_longdouble.c -O2 -fomit-frame-pointer execution test
FAIL: libffi.call/cls_longdouble_va.c -O2 -fomit-frame-pointer output pattern test, is -0.0
FAIL: libffi.call/float.c -O2 -fomit-frame-pointer execution test
FAIL: libffi.call/float4.c -O2 -fomit-frame-pointer execution test
FAIL: libffi.call/many.c -O2 -fomit-frame-pointer execution test
FAIL: libffi.call/return_dbl.c -O2 -fomit-frame-pointer execution test
FAIL: libffi.call/return_dbl1.c -O2 -fomit-frame-pointer execution test
FAIL: libffi.call/return_dbl2.c -O2 -fomit-frame-pointer execution test
FAIL: libffi.call/return_fl.c -O2 -fomit-frame-pointer execution test
FAIL: libffi.call/return_fl1.c -O2 -fomit-frame-pointer execution test
FAIL: libffi.call/return_fl2.c -O2 -fomit-frame-pointer execution test
FAIL: libffi.call/return_fl3.c -O2 -fomit-frame-pointer execution test
FAIL: libffi.call/return_ldl.c -O2 -fomit-frame-pointer execution test
Running /opt/gcc/gcc-4.5-work/libffi/testsuite/libffi.special/special.exp ...

		=== libffi Summary for unix ===

# of expected passes		1532
# of unexpected failures	71
# of expected failures		10
# of unsupported tests		15
Running target unix/-m64
Using /sw/share/dejagnu/baseboards/unix.exp as board description file for target.
Using /sw/share/dejagnu/config/unix.exp as generic interface file for target.
Using /opt/gcc/gcc-4.5-work/libffi/testsuite/config/default.exp as tool-and-target-specific interface file.
Running /opt/gcc/gcc-4.5-work/libffi/testsuite/libffi.call/call.exp ...
FAIL: libffi.call/closure_fn0.c -O0 -W -Wall execution test
FAIL: libffi.call/closure_fn1.c -O0 -W -Wall execution test
...
FAIL: libffi.special/unwindtest_ffi_call.cc  -shared-libgcc -lstdc++ execution test

		=== libffi Summary for unix/-m64 ===

# of expected passes		593
# of unexpected failures	583
# of expected failures		10
# of unsupported tests		15

		=== libffi Summary ===

# of expected passes		2125
# of unexpected failures	654
# of expected failures		20
# of unsupported tests		30

Instead of (revision 154736):

Running target unix
FAIL: libffi.call/cls_double_va.c -O0 -W -Wall output pattern test, is -0.0
FAIL: libffi.call/cls_longdouble_va.c -O0 -W -Wall output pattern test, is -0.0
FAIL: libffi.call/nested_struct5.c -O0 -W -Wall execution test
FAIL: libffi.call/cls_double_va.c -O2 output pattern test, is -0.0
FAIL: libffi.call/cls_longdouble_va.c -O2 output pattern test, is -0.0
FAIL: libffi.call/cls_double_va.c -O3 output pattern test, is -0.0
FAIL: libffi.call/cls_longdouble_va.c -O3 output pattern test, is -0.0
FAIL: libffi.call/cls_double_va.c -Os output pattern test, is -0.0
FAIL: libffi.call/cls_longdouble_va.c -Os output pattern test, is -0.0
FAIL: libffi.call/cls_double_va.c -O2 -fomit-frame-pointer output pattern test, is -0.0
FAIL: libffi.call/cls_longdouble_va.c -O2 -fomit-frame-pointer output pattern test, is -0.0

                === libffi Summary for unix ===

# of expected passes            1597
# of unexpected failures        11
# of expected failures          10
# of unsupported tests          15

Running target unix/-m64
FAIL: libffi.call/closure_fn0.c -O0 -W -Wall execution test
FAIL: libffi.call/closure_fn1.c -O0 -W -Wall execution test
...

                === libffi Summary for unix/-m64 ===

# of expected passes            593
# of unexpected failures        583
# of expected failures          10
# of unsupported tests          15

                === libffi Summary ===

# of expected passes            2190
# of unexpected failures        594
# of expected failures          20
# of unsupported tests          30
Comment 3 David Edelsohn 2009-12-02 12:35:27 UTC
Yes
Comment 4 David Edelsohn 2009-12-02 12:36:07 UTC
I believe the bootstrap failure should be fixed.  Please let me know about the testsuite results.
Comment 5 Dominique d'Humieres 2009-12-02 13:54:18 UTC
See http://gcc.gnu.org/ml/gcc-testresults/2009-12/msg00147.html for results at revision 154892.
Comment 6 David Edelsohn 2009-12-03 01:44:07 UTC
Darwin and AIX share most of the C code and the assembly files are nearly identical for 32 bit support, except for the format of calls.  The results on AIX now are clean.  I cannot see any reason for the difference between the AIX results and the Apple regression tester results.  The regression tester results look identical to the results you posted with your long double fix and without my additional patches.
Comment 7 Dominique d'Humieres 2009-12-03 09:51:09 UTC
See also pr35484.
Comment 8 Richard Biener 2009-12-03 11:38:15 UTC
Bootstrap is fixed.
Comment 9 David Edelsohn 2009-12-03 13:46:36 UTC
Bootstrap is fixed, but mysterious libffi failures remain.
Comment 10 David Edelsohn 2009-12-03 13:56:45 UTC
The only unique change was in ffitarget.h:

#elif defined (POWERPC_DARWIN) && defined (__ppc64__)   /* Darwin */
#define POWERPC64

Does Darwin define __ppc64__ in 32 bit mode on 64 bit systems?
Comment 11 Dominique d'Humieres 2009-12-03 14:12:55 UTC
> Does Darwin define __ppc64__ in 32 bit mode on 64 bit systems?

I cannot answer the question, but I see

gcc/config/rs6000/darwin.h:      if (TARGET_64BIT) builtin_define ("__ppc64__");	\

Assuming powerpc-apple-darwin9 is a 32 bit target, __ppc64__ should not be defined (?).
Comment 12 Jack Howarth 2009-12-03 15:17:39 UTC
On powerpc-apple-darwin9 using a dual G5, for Apple's gcc 4.0 and 4.2 compilers as well as FSF gcc 4.4.2's, one gets...

howarth%  gcc -m32 -E -dM -x c /dev/null | grep LP64
howarth% 

only at -m64 do all of the compilers define LP64...

howarth% gcc -m64 -E -dM -x c /dev/null | grep LP64
#define __LP64__ 1
#define _LP64 1
Comment 13 David Edelsohn 2009-12-03 15:20:35 UTC
One would assume ...

I do not see any differences that should cause the 11 FPR return value tests to fail on Darwin but not AIX.
Comment 14 Jack Howarth 2009-12-03 15:20:55 UTC
Same is true for __ppc64__. For the Apple gcc-4.0 and 4.2 compilers as well as FSF gcc-4.4.2, __ppc64__ is only defined at -m64 and not -m32 as would be expected.
Comment 15 David Edelsohn 2009-12-03 16:32:31 UTC
One would not expect __ppc64__ to be defined for -m32.  Thanks for the confirmation.

I do not have access to a darwin system.  Do either of you have enough PPC assembly knowledge to step through libffi/testsuite/libffi.call/return_fl1.c in a debugger?
Comment 16 David Edelsohn 2009-12-03 17:42:52 UTC
I found a system and backported the libffi changes.  For some reason, Darwin is calculating the stack location of FP arguments wrong.
Comment 17 Jack Howarth 2009-12-03 18:02:26 UTC
Can you verify that powerpc darwin calculates the stack location of FP arguments correctly before your patch to see if it was a latent problem?
Comment 18 David Edelsohn 2009-12-03 19:09:59 UTC
Subject: Bug 42243

Author: dje
Date: Thu Dec  3 19:09:29 2009
New Revision: 154956

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=154956
Log:
        PR libffi/42243
        * src/powerpc/ffi_darwin.c (ffi_prep_args): Remove extra parentheses.

Modified:
    trunk/libffi/ChangeLog
    trunk/libffi/src/powerpc/ffi_darwin.c

Comment 19 Dominique d'Humieres 2009-12-03 20:57:48 UTC
At revision 154956 the results are:

		=== libffi tests ===


Running target unix
FAIL: libffi.call/cls_double_va.c -O0 -W -Wall output pattern test, is -0.0
FAIL: libffi.call/cls_longdouble.c -O0 -W -Wall execution test
FAIL: libffi.call/cls_longdouble_va.c -O0 -W -Wall output pattern test, is -0.0
FAIL: libffi.call/nested_struct5.c -O0 -W -Wall execution test
FAIL: libffi.call/cls_double_va.c -O2 output pattern test, is -0.0
FAIL: libffi.call/cls_longdouble.c -O2 execution test
FAIL: libffi.call/cls_longdouble_va.c -O2 output pattern test, is -0.0
FAIL: libffi.call/cls_double_va.c -O3 output pattern test, is -0.0
FAIL: libffi.call/cls_longdouble.c -O3 execution test
FAIL: libffi.call/cls_longdouble_va.c -O3 output pattern test, is -0.0
FAIL: libffi.call/cls_double_va.c -Os output pattern test, is -0.0
FAIL: libffi.call/cls_longdouble.c -Os execution test
FAIL: libffi.call/cls_longdouble_va.c -Os output pattern test, is -0.0
FAIL: libffi.call/cls_double_va.c -O2 -fomit-frame-pointer output pattern test, is -0.0
FAIL: libffi.call/cls_longdouble.c -O2 -fomit-frame-pointer execution test
FAIL: libffi.call/cls_longdouble_va.c -O2 -fomit-frame-pointer output pattern test, is -0.0

		=== libffi Summary ===

# of expected passes		1587
# of unexpected failures	16
# of expected failures		10
# of unsupported tests		15

So the libffi.call/cls_longdouble.c test is still failing while it was not before revision 154855.
Comment 20 Dominique d'Humieres 2009-12-04 08:25:09 UTC
At revision 154970, there are still 16 failures, but the error has changed for libffi.call/cls_longdouble.c:

...
FAIL: libffi.call/cls_longdouble.c -O0 -W -Wall output pattern test, is 1 2 3 4 5 6 7 8: 36
...

Looking at the log file, I see:

1 2 3 4 5 6 7 8: 36
res: 36
1 2 3 4 5 6 7 7: 35
res: 35
PASS: libffi.call/cls_longdouble.c -O2 execution test
FAIL: libffi.call/cls_longdouble.c -O2 output pattern test, is 1 2 3 4 5 6 7 8: 36
res: 361 2 3 4 5 6 7 7: 35res: 35
, should match 1 2 3 4 5 6 7 8: 36^M?
res: 36^M?
1 2 3 4 5 6 7 8: 36^M?
res: 36
Comment 21 Dominique d'Humieres 2009-12-04 16:27:57 UTC
At revision 154983, I get

		=== libffi tests ===


Running target unix
FAIL: libffi.call/cls_double_va.c -O0 -W -Wall output pattern test, is -0.0
FAIL: libffi.call/cls_longdouble_va.c -O0 -W -Wall output pattern test, is -0.0
FAIL: libffi.call/nested_struct5.c -O0 -W -Wall execution test
FAIL: libffi.call/cls_double_va.c -O2 output pattern test, is -0.0
FAIL: libffi.call/cls_longdouble_va.c -O2 output pattern test, is -0.0
FAIL: libffi.call/cls_double_va.c -O3 output pattern test, is -0.0
FAIL: libffi.call/cls_longdouble_va.c -O3 output pattern test, is -0.0
FAIL: libffi.call/cls_double_va.c -Os output pattern test, is -0.0
FAIL: libffi.call/cls_longdouble_va.c -Os output pattern test, is -0.0
FAIL: libffi.call/cls_double_va.c -O2 -fomit-frame-pointer output pattern test, is -0.0
FAIL: libffi.call/cls_longdouble_va.c -O2 -fomit-frame-pointer output pattern test, is -0.0

		=== libffi Summary ===

# of expected passes		1597
# of unexpected failures	11
# of expected failures		10
# of unsupported tests		15

So it seems that all the problems due to revision 154855 are now fixed. Thanks for the patches.
BTW did you get an idea about where to look for the remaining 11 failures?
Comment 22 Jack Howarth 2009-12-04 18:13:27 UTC
Have you tried r154983 with http://gcc.gnu.org/ml/gcc-patches/2009-12/msg00255.html?
Comment 23 Dominique d'Humieres 2009-12-04 18:34:01 UTC
> Have you tried r154983 with
> http://gcc.gnu.org/ml/gcc-patches/2009-12/msg00255.html?

Not yet! 
Comment 24 Dominique d'Humieres 2009-12-04 21:00:28 UTC
> Have you tried r154983 with
> http://gcc.gnu.org/ml/gcc-patches/2009-12/msg00255.html?

The patch does not change anything, I get the same failures with or without it.
Comment 25 Dominique d'Humieres 2009-12-05 12:54:07 UTC
If there is no objection, I'll close tomorrow this pr as fixed. The failure of libffi.call/nested_struct5.c is pr34311 (Opened: 2007-12-01) and I'll open a new pr for the failures of libffi.call/cls_*double_va.c.
Comment 26 Dominique d'Humieres 2009-12-15 13:21:13 UTC
I have open pr42378 for the remaining failures in comment #21 (I did not include  libffi.call/nested_struct5.c that is pr34311). Closing this PR as fixed, please reopen if you disagree.