mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-29 19:30:36 +02:00
NetBSD and pkgsrc have been using an empty vendor string since the mid-'90s, such as x86_64--netbsd. pkgsrc has been carrying around a workaround just the guile build for a long time. (Before that, NetBSD omitted the vendor altogether, so if x86_64 existed then it might have been `x86_64-netbsd', but that caused more problems.) This change makes Guile accept an empty vendor string so workarounds are no longer necessary. * module/system/base/target.scm (validate-target): Allow empty vendor string in GNU target triplets. * test-suite/tests/cross-compilation.test ("cross-compilation"): Add tests for "x86_64--netbsd". Co-authored-by: Ludovic Courtès <ludo@gnu.org>
100 lines
4 KiB
Scheme
100 lines
4 KiB
Scheme
;;;; Cross compilation -*- mode: scheme; coding: utf-8; -*-
|
|
;;;;
|
|
;;;; Copyright (C) 2010-2014, 2020, 2022 Free Software Foundation, Inc.
|
|
;;;;
|
|
;;;; This library is free software; you can redistribute it and/or
|
|
;;;; modify it under the terms of the GNU Lesser General Public
|
|
;;;; License as published by the Free Software Foundation; either
|
|
;;;; version 3 of the License, or (at your option) any later version.
|
|
;;;;
|
|
;;;; This library is distributed in the hope that it will be useful,
|
|
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
;;;; Lesser General Public License for more details.
|
|
;;;;
|
|
;;;; You should have received a copy of the GNU Lesser General Public
|
|
;;;; License along with this library; if not, write to the Free Software
|
|
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
(define-module (tests cross-compilation)
|
|
#:use-module (test-suite lib)
|
|
#:use-module (rnrs bytevectors)
|
|
#:use-module (system vm elf)
|
|
#:use-module (system base compile)
|
|
#:use-module (system base target))
|
|
|
|
(define (test-triplet cpu vendor os)
|
|
(let ((triplet (string-append cpu "-" vendor "-" os)))
|
|
(pass-if (format #f "triplet ~a" triplet)
|
|
(with-target triplet
|
|
(lambda ()
|
|
(and (string=? (target-cpu) cpu)
|
|
(string=? (target-vendor) vendor)
|
|
(string=? (target-os) os)))))))
|
|
|
|
(define (native-cpu)
|
|
(with-target %host-type target-cpu))
|
|
|
|
(define (native-os)
|
|
(with-target %host-type target-os))
|
|
|
|
(define (native-word-size)
|
|
((@ (system foreign) sizeof) '*))
|
|
|
|
(define (test-target triplet endian word-size)
|
|
(pass-if (format #f "target `~a' honored" triplet)
|
|
(with-target triplet
|
|
(lambda ()
|
|
(let ((word-size
|
|
;; When the target is the native CPU, rather trust
|
|
;; the native CPU's word size. This is because
|
|
;; Debian's `sparc64-linux-gnu' port, for instance,
|
|
;; actually has a 32-bit user-land, for instance (see
|
|
;; <http://www.debian.org/ports/sparc/#sparc64bit>
|
|
;; for details.)
|
|
(if (and (string=? (native-cpu) (target-cpu))
|
|
(string=? (native-os) (target-os)))
|
|
(native-word-size)
|
|
word-size))
|
|
(bv (compile '(hello-world) #:warning-level 0 #:to 'bytecode)))
|
|
(and=> (parse-elf bv)
|
|
(lambda (elf)
|
|
(and (equal? (elf-byte-order elf) endian)
|
|
(equal? (elf-word-size elf) word-size)))))))))
|
|
|
|
(with-test-prefix "cross-compilation"
|
|
|
|
(test-triplet "i586" "pc" "gnu0.3")
|
|
(test-triplet "x86_64" "unknown" "linux-gnu")
|
|
(test-triplet "x86_64" "unknown" "kfreebsd-gnu")
|
|
(test-triplet "x86_64" "" "netbsd") ;NetBSD/pkgsrc with empty vendor
|
|
|
|
(test-target "i586-pc-gnu0.3" (endianness little) 4)
|
|
(test-target "x86_64-pc-linux-gnu" (endianness little) 8)
|
|
(test-target "powerpc-unknown-linux-gnu" (endianness big) 4)
|
|
(test-target "sparc64-unknown-freebsd8.2" (endianness big) 8)
|
|
(test-target "x86_64--netbsd" (endianness little) 8)
|
|
|
|
(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)
|
|
(test-target "x86_64-unknown-linux-gnux32" ; x32 ABI (Debian tuplet)
|
|
(endianness little) 4)
|
|
(test-target "arm-unknown-linux-androideabi"
|
|
(endianness little) 4)
|
|
(test-target "armeb-unknown-linux-gnu"
|
|
(endianness big) 4)
|
|
(test-target "aarch64-linux-gnu"
|
|
(endianness little) 8)
|
|
(test-target "aarch64_be-linux-gnu"
|
|
(endianness big) 8)
|
|
|
|
(pass-if-exception "unknown target" exception:miscellaneous-error
|
|
(with-target "fcpu-unknown-gnu1.0"
|
|
(lambda ()
|
|
(compile '(ohai) #:warning-level 0 #:to 'bytecode)))))
|
|
|
|
;; Local Variables:
|
|
;; eval: (put 'with-target 'scheme-indent-function 1)
|
|
;; End:
|