gnu: Add toolchain support for 'armhf-linux'.

Based on preliminary work by John Darrington <john@darrington.wattle.id.au>.

* gnu/packages/cross-base.scm (xgcc-armhf): New variable.
* gnu/packages/gcc.scm (gcc-configure-flags-for-triplet): Add armhf case.
  (gcc-4.7)[pre-configure]: Add gcc/config/*/linux-eabi.h to the list
  of files in which to patch GLIBC_DYNAMIC_LINKER.
* gnu/packages/bootstrap.scm (glibc-dynamic-linker): Add armhf case.
* guix/utils.scm (gnu-triplet->nix-system, nix-system->gnu-triplet):
  Add armhf cases.
This commit is contained in:
Mark H Weaver 2015-01-07 15:55:23 -05:00
parent f7d2b496b9
commit 3f00ff8b43
4 changed files with 36 additions and 13 deletions

View File

@ -162,6 +162,7 @@ successful, or false to signal an error."
"Return the name of Glibc's dynamic linker for SYSTEM." "Return the name of Glibc's dynamic linker for SYSTEM."
(cond ((string=? system "x86_64-linux") "/lib/ld-linux-x86-64.so.2") (cond ((string=? system "x86_64-linux") "/lib/ld-linux-x86-64.so.2")
((string=? system "i686-linux") "/lib/ld-linux.so.2") ((string=? system "i686-linux") "/lib/ld-linux.so.2")
((string=? system "armhf-linux") "/lib/ld-linux-armhf.so.3")
((string=? system "mips64el-linux") "/lib/ld.so.1") ((string=? system "mips64el-linux") "/lib/ld.so.1")
;; XXX: This one is used bare-bones, without a libc, so add a case ;; XXX: This one is used bare-bones, without a libc, so add a case

View File

@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2013, 2014 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2013, 2014 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2014, 2015 Mark H Weaver <mhw@netris.org>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -322,6 +323,12 @@ XBINUTILS and the cross tool chain."
;; Bare-bones Xtensa cross-compiler, used to build the Atheros firmware. ;; Bare-bones Xtensa cross-compiler, used to build the Atheros firmware.
(cross-gcc "xtensa-elf")) (cross-gcc "xtensa-elf"))
(define-public xgcc-armhf
(let ((triplet "arm-linux-gnueabihf"))
(cross-gcc triplet
(cross-binutils triplet)
(cross-libc triplet))))
;; (define-public xgcc-armel ;; (define-public xgcc-armel
;; (let ((triplet "armel-linux-gnueabi")) ;; (let ((triplet "armel-linux-gnueabi"))
;; (cross-gcc triplet ;; (cross-gcc triplet

View File

@ -46,8 +46,17 @@ where the OS part is overloaded to denote a specific ABI---into GCC
;; Triplets recognized by glibc as denoting the N64 ABI; see ;; Triplets recognized by glibc as denoting the N64 ABI; see
;; ports/sysdeps/mips/preconfigure. ;; ports/sysdeps/mips/preconfigure.
'("--with-abi=64")) '("--with-abi=64"))
((string-match "^arm.*-gnueabihf$" target)
'("--with-arch=armv7-a"
"--with-float=hard"
"--with-mode=thumb"
;; See <https://wiki.debian.org/ArmHardFloatPort/VfpComparison#FPU>
"--with-fpu=vfpv3-d16"))
(else (else
;; TODO: Add `armel.*gnueabi', `hf', etc. ;; TODO: Add `arm.*-gnueabi', etc.
'()))) '())))
(define-public gcc-4.7 (define-public gcc-4.7
@ -184,14 +193,14 @@ where the OS part is overloaded to denote a specific ABI---into GCC
(for-each (for-each
(lambda (x) (lambda (x)
(substitute* (find-files "gcc/config" (substitute* (find-files "gcc/config"
"^linux(64|-elf)?\\.h$") "^linux(64|-elf|-eabi)?\\.h$")
(("(#define GLIBC_DYNAMIC_LINKER.*)\\\\\n$" _ line) (("(#define GLIBC_DYNAMIC_LINKER.*)\\\\\n$" _ line)
line))) line)))
'(1 2 3)) '(1 2 3))
;; Fix the dynamic linker's file name. ;; Fix the dynamic linker's file name.
(substitute* (find-files "gcc/config" (substitute* (find-files "gcc/config"
"^linux(64|-elf)?\\.h$") "^linux(64|-elf|-eabi)?\\.h$")
(("#define GLIBC_DYNAMIC_LINKER([^ ]*).*$" _ suffix) (("#define GLIBC_DYNAMIC_LINKER([^ ]*).*$" _ suffix)
(format #f "#define GLIBC_DYNAMIC_LINKER~a \"~a\"~%" (format #f "#define GLIBC_DYNAMIC_LINKER~a \"~a\"~%"
suffix suffix

View File

@ -1,6 +1,6 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2013 Mark H Weaver <mhw@netris.org> ;;; Copyright © 2013, 2014, 2015 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org> ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
;;; Copyright © 2014 Ian Denhardt <ian@zenhack.net> ;;; Copyright © 2014 Ian Denhardt <ian@zenhack.net>
;;; ;;;
@ -481,14 +481,18 @@ previous value of the keyword argument."
#:optional (system (%current-system)) (vendor "unknown")) #:optional (system (%current-system)) (vendor "unknown"))
"Return a guess of the GNU triplet corresponding to Nix system "Return a guess of the GNU triplet corresponding to Nix system
identifier SYSTEM." identifier SYSTEM."
(let* ((dash (string-index system #\-)) (match system
(arch (substring system 0 dash)) ("armhf-linux"
(os (substring system (+ 1 dash)))) (string-append "arm-" vendor "-linux-gnueabihf"))
(string-append arch (_
"-" vendor "-" (let* ((dash (string-index system #\-))
(if (string=? os "linux") (arch (substring system 0 dash))
"linux-gnu" (os (substring system (+ 1 dash))))
os)))) (string-append arch
"-" vendor "-"
(if (string=? os "linux")
"linux-gnu"
os))))))
(define (gnu-triplet->nix-system triplet) (define (gnu-triplet->nix-system triplet)
"Return the Nix system type corresponding to TRIPLET, a GNU triplet as "Return the Nix system type corresponding to TRIPLET, a GNU triplet as
@ -498,7 +502,9 @@ returned by `config.guess'."
(lambda (m) (lambda (m)
(string-append "i686-" (match:substring m 1)))) (string-append "i686-" (match:substring m 1))))
(else triplet)))) (else triplet))))
(cond ((string-match "^([^-]+)-([^-]+-)?linux-gnu.*" triplet) (cond ((string-match "^arm[^-]*-([^-]+-)?linux-gnueabihf" triplet)
"armhf-linux")
((string-match "^([^-]+)-([^-]+-)?linux-gnu.*" triplet)
=> =>
(lambda (m) (lambda (m)
;; Nix omits `-gnu' for GNU/Linux. ;; Nix omits `-gnu' for GNU/Linux.