Check whether a triplet's OS part specifies an ABI.
authorLudovic Courtès <ludo@gnu.org>
Wed, 27 Feb 2013 19:36:52 +0000 (20:36 +0100)
committerLudovic Courtès <ludo@gnu.org>
Wed, 27 Feb 2013 19:40:08 +0000 (20:40 +0100)
* module/system/base/target.scm (cpu-word-size): Rename to...
  (triplet-pointer-size): ... this.  Update caller.  Take a triplet as
  the argument.  Check the `triplet-os' part when checking for equality
  with the host.  Add support "mips64.*-gnuabi64".
* test-suite/tests/asm-to-bytecode.test ("cross-compilation")
  [ "mips64el-unknown-linux-gnuabi64"]: New test.

module/system/base/target.scm
test-suite/tests/asm-to-bytecode.test

index 93c644a..5cc0c1d 100644 (file)
@@ -55,7 +55,7 @@
   (let ((cpu (triplet-cpu target)))
     (with-fluids ((%target-type target)
                   (%target-endianness (cpu-endianness cpu))
-                  (%target-word-size (cpu-word-size cpu)))
+                  (%target-word-size (triplet-pointer-size target)))
       (thunk))))
 
 (define (cpu-endianness cpu)
             (else
              (error "unknown CPU endianness" cpu)))))
 
-(define (cpu-word-size cpu)
-  "Return the word size for CPU."
-  (if (string=? cpu (triplet-cpu %host-type))
-      %native-word-size
-      (cond ((string-match "^i[0-9]86$" cpu) 4)
-
-            ;; See <http://www.linux-mips.org/wiki/WhatsWrongWithO32N32N64>
-            ;; for details on the MIPS ABIs.
-            ((string-match "^mips64" cpu) 4)      ; n32 or o32
-
-            ((string-match "64$" cpu) 8)
-            ((string-match "64[lbe][lbe]$" cpu) 8)
-            ((member cpu '("sparc" "powerpc" "mips" "mipsel")) 4)
-            ((string-match "^arm.*" cpu) 4)
-            (else (error "unknown CPU word size" cpu)))))
+(define (triplet-pointer-size triplet)
+  "Return the size of pointers in bytes for TRIPLET."
+  (let ((cpu (triplet-cpu triplet)))
+    (cond ((and (string=? cpu (triplet-cpu %host-type))
+                (string=? (triplet-os triplet) (triplet-os %host-type)))
+           %native-word-size)
+
+          ((string-match "^i[0-9]86$" cpu) 4)
+
+          ;; Although GNU config.guess doesn't yet recognize them,
+          ;; Debian (ab)uses the OS part to denote the specific ABI
+          ;; being used: <http://wiki.debian.org/Multiarch/Tuples>.
+          ;; See <http://www.linux-mips.org/wiki/WhatsWrongWithO32N32N64>
+          ;; for details on the MIPS ABIs.
+          ((string-match "^mips64.*-gnuabi64" triplet) 8) ; n64 ABI
+          ((string-match "^mips64" cpu) 4)                ; n32 or o32
+
+          ((string-match "64$" cpu) 8)
+          ((string-match "64[lbe][lbe]$" cpu) 8)
+          ((member cpu '("sparc" "powerpc" "mips" "mipsel")) 4)
+          ((string-match "^arm.*" cpu) 4)
+          (else (error "unknown CPU word size" cpu)))))
 
 (define (triplet-cpu t)
   (substring t 0 (string-index t #\-)))
index 41707b2..6b1449d 100644 (file)
 
   (test-target "mips64el-unknown-linux-gnu"       ; n32 or o32 ABI
                (endianness little) 4)
+  (test-target "mips64el-unknown-linux-gnuabi64"  ; n64 ABI (Debian tuplet)
+               (endianness little) 8)
 
   (pass-if-exception "unknown target"
     exception:miscellaneous-error