me
/
guix
Archived
1
0
Fork 0

gnu: cross-libc: Return #f if no libc available.

* gnu/packages/cross-base.scm (cross-libc): Return #f if no libc is
available for the given TARGET.

Change-Id: I17d19716373dd5704bb70d805437738fd29bd96b
Signed-off-by: Efraim Flashner <efraim@flashner.co.il>
Jean-Pierre De Jesus DIAZ 2023-11-28 12:34:44 +01:00 committed by Efraim Flashner
parent 8e61e63515
commit 444a40c75a
No known key found for this signature in database
GPG Key ID: 41AAE7DCCA3D8351
1 changed files with 68 additions and 63 deletions

View File

@ -9,6 +9,7 @@
;;; Copyright © 2020 Mathieu Othacehe <m.othacehe@gmail.com> ;;; Copyright © 2020 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com> ;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2023 Josselin Poiret <dev@jpoiret.xyz> ;;; Copyright © 2023 Josselin Poiret <dev@jpoiret.xyz>
;;; Copyright © 2023 Foundation Devices, Inc. <hello@foundationdevices.com>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -610,74 +611,78 @@ the base compiler. Use XBINUTILS as the associated cross-Binutils."
(xbinutils (cross-binutils target)) (xbinutils (cross-binutils target))
(xheaders (cross-kernel-headers target))) (xheaders (cross-kernel-headers target)))
"Return LIBC cross-built for TARGET, a GNU triplet. Use XGCC and XBINUTILS "Return LIBC cross-built for TARGET, a GNU triplet. Use XGCC and XBINUTILS
and the cross tool chain." and the cross tool chain. If TARGET doesn't have a standard C library #f is
(if (target-mingw? target) returned."
(let ((machine (substring target 0 (string-index target #\-)))) (match target
(make-mingw-w64 machine ((? target-mingw?)
#:xgcc xgcc (let ((machine (substring target 0 (string-index target #\-))))
#:xbinutils xbinutils)) (make-mingw-w64 machine
(package #:xgcc xgcc
(inherit libc) #:xbinutils xbinutils)))
(name (string-append "glibc-cross-" target)) ((or (? target-linux?) (? target-hurd?))
(arguments (package
(substitute-keyword-arguments (inherit libc)
`( ;; Disable stripping (see above.) (name (string-append "glibc-cross-" target))
#:strip-binaries? #f (arguments
(substitute-keyword-arguments
`(;; Disable stripping (see above.)
#:strip-binaries? #f
;; This package is used as a target input, but it should not have ;; This package is used as a target input, but it should not have
;; the usual cross-compilation inputs since that would include ;; the usual cross-compilation inputs since that would include
;; itself. ;; itself.
#:implicit-cross-inputs? #f #:implicit-cross-inputs? #f
;; We need SRFI 26. ;; We need SRFI 26.
#:modules ((guix build gnu-build-system) #:modules ((guix build gnu-build-system)
(guix build utils) (guix build utils)
(srfi srfi-26)) (srfi srfi-26))
,@(package-arguments libc)) ,@(package-arguments libc))
((#:configure-flags flags) ((#:configure-flags flags)
`(cons ,(string-append "--host=" target) `(cons ,(string-append "--host=" target)
,(if (target-hurd? target) ,(if (target-hurd? target)
`(append (list "--disable-werror" `(append (list "--disable-werror"
,@%glibc/hurd-configure-flags) ,@%glibc/hurd-configure-flags)
,flags) ,flags)
flags))) flags)))
((#:phases phases) ((#:phases phases)
`(modify-phases ,phases `(modify-phases ,phases
(add-before 'configure 'set-cross-kernel-headers-path (add-before 'configure 'set-cross-kernel-headers-path
(lambda* (#:key inputs #:allow-other-keys) (lambda* (#:key inputs #:allow-other-keys)
(let* ((kernel (assoc-ref inputs "kernel-headers")) (let* ((kernel (assoc-ref inputs "kernel-headers"))
(cpath (string-append kernel "/include"))) (cpath (string-append kernel "/include")))
(for-each (cut setenv <> cpath) (for-each (cut setenv <> cpath)
',%gcc-cross-include-paths) ',%gcc-cross-include-paths)
(setenv "CROSS_LIBRARY_PATH" (setenv "CROSS_LIBRARY_PATH"
(string-append kernel "/lib")) ; for Hurd's libihash (string-append kernel "/lib")) ; for Hurd's libihash
#t))) #t)))
,@(if (target-hurd? target) ,@(if (target-hurd? target)
'((add-after 'install 'augment-libc.so '((add-after 'install 'augment-libc.so
(lambda* (#:key outputs #:allow-other-keys) (lambda* (#:key outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out"))) (let* ((out (assoc-ref outputs "out")))
(substitute* (string-append out "/lib/libc.so") (substitute* (string-append out "/lib/libc.so")
(("/[^ ]+/lib/libc.so.0.3") (("/[^ ]+/lib/libc.so.0.3")
(string-append out "/lib/libc.so.0.3" (string-append out "/lib/libc.so.0.3"
" libmachuser.so libhurduser.so")))) " libmachuser.so libhurduser.so"))))
#t))) #t)))
'()))))) '())))))
;; Shadow the native "kernel-headers" because glibc's recipe expects the ;; Shadow the native "kernel-headers" because glibc's recipe expects the
;; "kernel-headers" input to point to the right thing. ;; "kernel-headers" input to point to the right thing.
(propagated-inputs `(("kernel-headers" ,xheaders))) (propagated-inputs `(("kernel-headers" ,xheaders)))
(native-inputs `(("cross-gcc" ,xgcc) (native-inputs `(("cross-gcc" ,xgcc)
("cross-binutils" ,xbinutils) ("cross-binutils" ,xbinutils)
,@(if (target-hurd? target) ,@(if (target-hurd? target)
`(("cross-mig" `(("cross-mig"
,(cross-mig target ,(cross-mig target
#:xgcc xgcc #:xgcc xgcc
#:xbinutils xbinutils))) #:xbinutils xbinutils)))
'()) '())
,@(package-inputs libc) ;FIXME: static-bash ,@(package-inputs libc) ;FIXME: static-bash
,@(package-native-inputs libc)))))) ,@(package-native-inputs libc)))))
(else #f)))
;;; Concrete cross tool chains are instantiated like this: ;;; Concrete cross tool chains are instantiated like this: