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

re: plink FTBFS: #error "Cannot determine endianness.



tags 528659 +patch
thanks

It seems that gcc on debian doesn't define __{BIG|LITTLE}_ENDIAN__ or any of the equvilents the package checks for. The package has hardcoded fallbacks for some architectures but not others hence the FTBFS on some but not all debian architectures (roughly correlated with how well known the architecture is). I've added code to fallback to endian.h if all else fails (I included the #warning lines so that I could check the new code behaved correctly, you may remove them if you wish).

The patch for that issue is attatched in the file 30_endiandetection.patch ready to be added to the quilt series. The patch lead to a full successfull build on armel and allowed successfull manual compilation of r.cpp on mips (compilation of the package as a whole on mips was not achived due to the other issue mentioned below). In both cases my #warning lines reported the endianess I expected.

There is also a seperate issue with parse.cpp making g++ sick on mips(el). On the buildds it failed with assembler errors, in my qemu system it failed with a segfault. Reducing the optmisation level to 02 it still segfaulted, reducing it to 01 the build was still running after more time than I was prepared to leave it for (this probablly isn't helped by the fact that qemu-system-mips seems to crash if I give it too much ram)


Index: plink-1.06/Rsrv.h
===================================================================
--- plink-1.06.orig/Rsrv.h	2009-05-15 03:35:29.000000000 +0100
+++ plink-1.06/Rsrv.h	2009-05-15 03:35:41.000000000 +0100
@@ -313,7 +313,18 @@
 #define __BIG_ENDIAN__ 1
 #define SWAPEND 1
 #elif ! defined Win32 /* Windows is little-endian is most cases, anywhere else we're stuck */
-#error "Cannot determine endianness. Make sure config.h is included or __{BIG|LITTLE}_ENDIAN__ is defined ."
+  //try endian.h before we finally bail out
+  #include <endian.h>
+  #if __BYTE_ORDER == __LITTLE_ENDIAN
+    #warning using little endian based on information from endian.h
+    #define __LITTLE_ENDIAN__ 1
+  #elif __BYTE_ORDER == __BIG_ENDIAN
+    #warning using big endian based on information from endian.h
+    #define __BIG_ENDIAN__ 1
+    #define SWAPEND 1
+  #else    
+    #error "Cannot determine endianness. Make sure config.h is included or __{BIG|LITTLE}_ENDIAN__ is defined ."
+  #endif    
 #endif
 
 /* FIXME: all the mess below needs more efficient implementation - the current one is so messy to work around alignment problems on some platforms like Sun and HP 9000 */

Reply to: