0.7.9.67:
authorChristophe Rhodes <csr21@cam.ac.uk>
Mon, 25 Nov 2002 13:24:15 +0000 (13:24 +0000)
committerChristophe Rhodes <csr21@cam.ac.uk>
Mon, 25 Nov 2002 13:24:15 +0000 (13:24 +0000)
MIPSel build patch
... write a noddy C program to determine target endianness
(KLUDGE: assumes int is 32 bits)
... use it in make-config.sh if we are building a MIPS target

make-config.sh
tools-for-build/Makefile
tools-for-build/determine-endianness.c [new file with mode: 0644]
version.lisp-expr

index 9f9a530..720cf14 100644 (file)
@@ -37,7 +37,6 @@ case `uname -m` in
     ppc) guessed_sbcl_arch=ppc ;;
     parisc) guessed_sbcl_arch=hppa ;;
     mips) guessed_sbcl_arch=mips ;;
-    mipsel) guessed_sbcl_arch=mips; little_endian=yes ;;
     *)
         # If we're not building on a supported target architecture, we
        # we have no guess, but it's not an error yet, since maybe
@@ -64,8 +63,12 @@ printf ":%s" "$sbcl_arch" >> $ltf
 # similar with :STACK-GROWS-FOOWARD, too. -- WHN 2002-03-03
 if [ "$sbcl_arch" = "x86" ] ; then
     printf ' :gencgc :stack-grows-downward-not-upward :c-stack-is-control-stack' >> $ltf
-elif [ "$sbcl_arch" = "mips" -a "$little_endian" = "yes" ] ; then
-    printf ' :little-endian' >> $ltf
+elif [ "$sbcl_arch" = "mips" ] ; then
+    # Use a little C program to try to guess the endianness.  Ware
+    # cross-compilers!
+    gnumake=${GNUMAKE:-gmake}
+    $gnumake -C tools-for-build determine-endianness
+    tools-for-build/determine-endianness >> $ltf
 else
     # Nothing need be done in this case, but sh syntax wants a placeholder.
     echo > /dev/null
index 3b3d30f..d4caad3 100644 (file)
@@ -7,7 +7,7 @@
 # provided with absolutely no warranty. See the COPYING and CREDITS
 # files for more information.
 
-all: grovel_headers
+all: grovel_headers determine-endianness
 
 clean: 
-       rm -f *.o grovel_headers
+       rm -f *.o grovel_headers determine-endianness
diff --git a/tools-for-build/determine-endianness.c b/tools-for-build/determine-endianness.c
new file mode 100644 (file)
index 0000000..e1001c4
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Test for the endianness of the target platform (needed for MIPS
+ * support, at the very least, as systems with either endianness exist
+ * in the wild).
+ */
+
+/*
+ * This software is part of the SBCL system. See the README file for
+ * more information.
+ *
+ * While most of SBCL is derived from the CMU CL system, many
+ * utilities for the build process (like this one) were written from
+ * scratch after the fork from CMU CL.
+ * 
+ * This software is in the public domain and is provided with
+ * absolutely no warranty. See the COPYING and CREDITS files for
+ * more information.
+ */
+
+#include <stdio.h>
+
+int main (int argc, char *argv[]) {
+    int foo = 0x20212223;
+    char *bar = (char *) &foo;
+    switch(*bar) {
+    case ' ':
+       /* Do nothing */
+       break;
+    case '#':
+       printf(" :little-endian");
+       break;
+    default:
+       /* FIXME: How do we do sane error processing in Unix?  This
+          program will be called from a script, in a manner somewhat
+          like:
+
+              tools-for-build/determine-endianness >> $ltf
+
+           but what if we have a too-smart C compiler that actually
+          gets us down to this branch?  I suppose that if we have a C
+          compiler that is that smart, we're doomed to miscompile the
+          runtime anyway, so we won't get here.  Still, it might be
+          good to have "set -e" in the various scripts so that we can
+          exit with an error here and have it be caught by the build
+          tools.  -- CSR, 2002-11-24
+       */
+       exit(1);
+    }
+    exit(0); 
+}
index 1cf8fce..0f5aa9c 100644 (file)
@@ -18,4 +18,4 @@
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
 
-"0.7.9.66"
+"0.7.9.67"