diff --git libffi/ChangeLog libffi/ChangeLog
index 5027680..8245f5b 100644
--- libffi/ChangeLog
+++ libffi/ChangeLog
@@ -1,3 +1,8 @@
+2016-05-23  Thomas Schwinge  <thomas@codesourcery.com>
+
+	PR libffi/65567
+	* testsuite/lib/libffi.exp (libffi_feature_test): Fix, and simply.
+
 2016-03-17  Andreas Schwab  <schwab@suse.de>
 
 	* src/aarch64/ffitarget.h (FFI_SIZEOF_JAVA_RAW) [__ILP32__]:
diff --git libffi/testsuite/lib/libffi.exp libffi/testsuite/lib/libffi.exp
index 169fe74..a0f6ab3 100644
--- libffi/testsuite/lib/libffi.exp
+++ libffi/testsuite/lib/libffi.exp
@@ -227,20 +227,21 @@ proc libffi_target_compile { source dest type options } {
 
 # TEST should be a preprocessor condition.  Returns true if it holds.
 proc libffi_feature_test { test } {
-    set src "ffitest.c"
+    set src "ffitest[pid].c"
 
     set f [open $src "w"]
     puts $f "#include <ffi.h>"
     puts $f $test
-    puts $f "xyzzy"
+    puts $f "/* OK */"
+    puts $f "#else"
+    puts $f "# error Failed $test"
     puts $f "#endif"
     close $f
 
-    set lines [libffi_target_compile $src "" "preprocess" ""]
+    set lines [libffi_target_compile $src /dev/null assembly ""]
     file delete $src
 
-    set last [lindex [split $lines] end]
-    return [regexp -- "xyzzy" $last]
+    return [string match "" $lines]
 }
 
 # Utility routines.


Backported to gcc-6-branch in r236595:

commit eb4cfb9897caae0af36c9bc496a104c9f8aa11c6
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Mon May 23 15:00:41 2016 +0000

    [PR libffi/65567] libffi: Fix, and simply libffi_feature_test
    
    Backport trunk r236594:
    
    	libffi/
    	PR libffi/65567
    	* testsuite/lib/libffi.exp (libffi_feature_test): Fix, and simply.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-6-branch@236595 138bc75d-0d04-0410-961f-82ee72b054a4
---
 libffi/ChangeLog                |    7 +++++++
 libffi/testsuite/lib/libffi.exp |   11 ++++++-----
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git libffi/ChangeLog libffi/ChangeLog
index e00113c..c851366 100644
--- libffi/ChangeLog
+++ libffi/ChangeLog
@@ -1,3 +1,10 @@
+2016-05-23  Thomas Schwinge  <thomas@codesourcery.com>
+
+	Backport trunk r236594:
+
+	PR libffi/65567
+	* testsuite/lib/libffi.exp (libffi_feature_test): Fix, and simply.
+
 2016-04-27  Release Manager
 
 	* GCC 6.1.0 released.
diff --git libffi/testsuite/lib/libffi.exp libffi/testsuite/lib/libffi.exp
index 169fe74..a0f6ab3 100644
--- libffi/testsuite/lib/libffi.exp
+++ libffi/testsuite/lib/libffi.exp
@@ -227,20 +227,21 @@ proc libffi_target_compile { source dest type options } {
 
 # TEST should be a preprocessor condition.  Returns true if it holds.
 proc libffi_feature_test { test } {
-    set src "ffitest.c"
+    set src "ffitest[pid].c"
 
     set f [open $src "w"]
     puts $f "#include <ffi.h>"
     puts $f $test
-    puts $f "xyzzy"
+    puts $f "/* OK */"
+    puts $f "#else"
+    puts $f "# error Failed $test"
     puts $f "#endif"
     close $f
 
-    set lines [libffi_target_compile $src "" "preprocess" ""]
+    set lines [libffi_target_compile $src /dev/null assembly ""]
     file delete $src
 
-    set last [lindex [split $lines] end]
-    return [regexp -- "xyzzy" $last]
+    return [string match "" $lines]
 }
 
 # Utility routines.


And, as obvious, backported to gcc-5-branch in r236596:

commit e2b5ae708e24c5e37b30d7ca3690e6f123a5cdf0
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Mon May 23 15:03:08 2016 +0000

    [PR libffi/65567] libffi: Fix, and simply libffi_feature_test
    
    Backport trunk r236594:
    
    	libffi/
    	PR libffi/65567
    	* testsuite/lib/libffi.exp (libffi_feature_test): Fix, and simply.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-5-branch@236596 138bc75d-0d04-0410-961f-82ee72b054a4
---
 libffi/ChangeLog                |    7 +++++++
 libffi/testsuite/lib/libffi.exp |   11 ++++++-----
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git libffi/ChangeLog libffi/ChangeLog
index 7bcce81..3307bfb 100644
--- libffi/ChangeLog
+++ libffi/ChangeLog
@@ -1,3 +1,10 @@
+2016-05-23  Thomas Schwinge  <thomas@codesourcery.com>
+
+	Backport trunk r236594:
+
+	PR libffi/65567
+	* testsuite/lib/libffi.exp (libffi_feature_test): Fix, and simply.
+
 2015-12-04  Release Manager
 
 	* GCC 5.3.0 released.
diff --git libffi/testsuite/lib/libffi.exp libffi/testsuite/lib/libffi.exp
index 169fe74..a0f6ab3 100644
--- libffi/testsuite/lib/libffi.exp
+++ libffi/testsuite/lib/libffi.exp
@@ -227,20 +227,21 @@ proc libffi_target_compile { source dest type options } {
 
 # TEST should be a preprocessor condition.  Returns true if it holds.
 proc libffi_feature_test { test } {
-    set src "ffitest.c"
+    set src "ffitest[pid].c"
 
     set f [open $src "w"]
     puts $f "#include <ffi.h>"
     puts $f $test
-    puts $f "xyzzy"
+    puts $f "/* OK */"
+    puts $f "#else"
+    puts $f "# error Failed $test"
     puts $f "#endif"
     close $f
 
-    set lines [libffi_target_compile $src "" "preprocess" ""]
+    set lines [libffi_target_compile $src /dev/null assembly ""]
     file delete $src
 
-    set last [lindex [split $lines] end]
-    return [regexp -- "xyzzy" $last]
+    return [string match "" $lines]
 }
 
 # Utility routines.
