Archived
1
0
Fork 0

gnu: cross-base: Externalize cross-gcc arguments.

* gnu/packages/cross-base.scm (cross-gcc-arguments): New procedure.
  (cross-gcc): Use it.  [No functional change.]
This commit is contained in:
Ludovic Courtès 2014-10-02 21:41:40 +02:00
parent 0d5a559f0f
commit cdb4b4b3ed

View file

@ -66,33 +66,10 @@
`(cons "--with-sysroot=/" ,flags)))))))
(cross binutils target)))
(define* (cross-gcc target
#:optional (xbinutils (cross-binutils target)) libc)
"Return a cross-compiler for TARGET, where TARGET is a GNU triplet. Use
XBINUTILS as the associated cross-Binutils. If LIBC is false, then build a
GCC that does not target a libc; otherwise, target that libc."
(package (inherit gcc-4.8)
(name (string-append "gcc-cross-"
(if libc "" "sans-libc-")
target))
(source (origin (inherit (package-source gcc-4.8))
(patches
(list (search-patch
"gcc-cross-environment-variables.patch")))))
;; For simplicity, use a single output. Otherwise libgcc_s & co. are not
;; found by default, etc.
(outputs '("out"))
(arguments
`(#:implicit-inputs? #f
#:modules ((guix build gnu-build-system)
(guix build utils)
(ice-9 regex)
(srfi srfi-1)
(srfi srfi-26))
,@(substitute-keyword-arguments (package-arguments gcc-4.8)
(define (cross-gcc-arguments target libc)
"Return build system arguments for a cross-gcc for TARGET, using LIBC (which
may be either a libc package or #f.)"
(substitute-keyword-arguments (package-arguments gcc-4.8)
((#:configure-flags flags)
`(append (list ,(string-append "--target=" target)
,@(gcc-configure-flags-for-triplet target)
@ -101,10 +78,9 @@ GCC that does not target a libc; otherwise, target that libc."
`(;; Disable features not needed at this stage.
"--disable-shared" "--enable-static"
;; Disable C++ because libstdc++'s
;; configure script otherwise fails with
;; "Link tests are not allowed after
;; GCC_NO_EXECUTABLES."
;; Disable C++ because libstdc++'s configure
;; script otherwise fails with "Link tests are not
;; allowed after GCC_NO_EXECUTABLES."
"--enable-languages=c"
"--disable-threads" ;libgcc, would need libc
@ -123,8 +99,8 @@ GCC that does not target a libc; otherwise, target that libc."
((#:make-flags flags)
(if libc
`(let ((libc (assoc-ref %build-inputs "libc")))
;; FLAGS_FOR_TARGET are needed for the target libraries to
;; receive the -Bxxx for the startfiles.
;; FLAGS_FOR_TARGET are needed for the target libraries to receive
;; the -Bxxx for the startfiles.
(cons (string-append "FLAGS_FOR_TARGET=-B" libc "/lib")
,flags))
flags))
@ -150,8 +126,8 @@ GCC that does not target a libc; otherwise, target that libc."
`(alist-cons-before
'configure 'set-cross-path
(lambda* (#:key inputs #:allow-other-keys)
;; Add the cross Linux headers to CROSS_CPATH, and remove
;; them from CPATH.
;; Add the cross Linux headers to CROSS_CPATH, and remove them
;; from CPATH.
(let ((libc (assoc-ref inputs "libc"))
(linux (assoc-ref inputs
"libc/linux-headers")))
@ -180,11 +156,39 @@ GCC that does not target a libc; otherwise, target that libc."
,phases)
phases)))
((#:strip-binaries? _)
;; Disable stripping as this can break binaries, with object files
;; of libgcc.a showing up as having an unknown architecture. See
;; Disable stripping as this can break binaries, with object files of
;; libgcc.a showing up as having an unknown architecture. See
;; <http://lists.fedoraproject.org/pipermail/arm/2010-August/000663.html>
;; for instance.
#f))))
#f)))
(define* (cross-gcc target
#:optional (xbinutils (cross-binutils target)) libc)
"Return a cross-compiler for TARGET, where TARGET is a GNU triplet. Use
XBINUTILS as the associated cross-Binutils. If LIBC is false, then build a
GCC that does not target a libc; otherwise, target that libc."
(package (inherit gcc-4.8)
(name (string-append "gcc-cross-"
(if libc "" "sans-libc-")
target))
(source (origin (inherit (package-source gcc-4.8))
(patches
(list (search-patch
"gcc-cross-environment-variables.patch")))))
;; For simplicity, use a single output. Otherwise libgcc_s & co. are not
;; found by default, etc.
(outputs '("out"))
(arguments
`(#:implicit-inputs? #f
#:modules ((guix build gnu-build-system)
(guix build utils)
(ice-9 regex)
(srfi srfi-1)
(srfi srfi-26))
,@(cross-gcc-arguments target libc)))
(native-inputs
`(("binutils-cross" ,xbinutils)