GNU bug report logs -
#65016
[PATCH] gnu: cross-libc: Return #f if no libc for target.
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 65016 in the body.
You can then email your comments to 65016 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
guix <at> cbaines.net, efraim <at> flashner.co.il, dev <at> jpoiret.xyz, ludo <at> gnu.org, othacehe <at> gnu.org, rekado <at> elephly.net, zimon.toutoune <at> gmail.com, me <at> tobias.gr, vagrant <at> debian.org, guix-patches <at> gnu.org
:
bug#65016
; Package
guix-patches
.
(Wed, 02 Aug 2023 13:25:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Jean-Pierre De Jesus DIAZ <jean <at> foundationdevices.com>
:
New bug report received and forwarded. Copy sent to
guix <at> cbaines.net, efraim <at> flashner.co.il, dev <at> jpoiret.xyz, ludo <at> gnu.org, othacehe <at> gnu.org, rekado <at> elephly.net, zimon.toutoune <at> gmail.com, me <at> tobias.gr, vagrant <at> debian.org, guix-patches <at> gnu.org
.
(Wed, 02 Aug 2023 13:25:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
* gnu/packages/cross-base.scm (cross-libc): Return #f if TARGET does
not contain a libc implementation.
This is the common case for most of the bare metal targets like
aarch64-none-elf et al.
Some bare-metal targets like `avr' do include AVR Libc though, but
this patch allows handling that separately in the future.
As glibc now only has been tested to work on Linux and GNU Hurd it
makes sense to contain it only for those targets.
This essentially allows to specify targets on packages like:
(arguments
(list #:target "aarch64-none-elf"
...))
And it should provide the implicit cross inputs packages without a
libc.
And opens the door for bare-metal platform definitions on GNU Guix as
it'd be nice to have proper cross toolchains and package management
for bare metal packages as the industry right now relies on bundling
each other's dependencies to compile entire systems.
* guix/build-system/gnu.scm (standard-cross-packages): Only add libc
inputs if actually present as a result of returning #f on cross-libc.
Do the same for the `static' output.
Signed-off-by: Jean-Pierre De Jesus DIAZ <jean <at> foundationdevices.com>
---
gnu/packages/cross-base.scm | 139 ++++++++++++++++++------------------
guix/build-system/gnu.scm | 6 +-
2 files changed, 75 insertions(+), 70 deletions(-)
diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index 14cb365099..d24d85c179 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -610,74 +610,77 @@ (define* (cross-libc* target
(xbinutils (cross-binutils target))
(xheaders (cross-kernel-headers target)))
"Return LIBC cross-built for TARGET, a GNU triplet. Use XGCC and XBINUTILS
-and the cross tool chain."
- (if (target-mingw? target)
- (let ((machine (substring target 0 (string-index target #\-))))
- (make-mingw-w64 machine
- #:xgcc xgcc
- #:xbinutils xbinutils))
- (package
- (inherit libc)
- (name (string-append "glibc-cross-" target))
- (arguments
- (substitute-keyword-arguments
- `( ;; Disable stripping (see above.)
- #:strip-binaries? #f
-
- ;; This package is used as a target input, but it should not have
- ;; the usual cross-compilation inputs since that would include
- ;; itself.
- #:implicit-cross-inputs? #f
-
- ;; We need SRFI 26.
- #:modules ((guix build gnu-build-system)
- (guix build utils)
- (srfi srfi-26))
-
- ,@(package-arguments libc))
- ((#:configure-flags flags)
- `(cons ,(string-append "--host=" target)
- ,(if (target-hurd? target)
- `(append (list "--disable-werror"
- ,@%glibc/hurd-configure-flags)
- ,flags)
- flags)))
- ((#:phases phases)
- `(modify-phases ,phases
- (add-before 'configure 'set-cross-kernel-headers-path
- (lambda* (#:key inputs #:allow-other-keys)
- (let* ((kernel (assoc-ref inputs "kernel-headers"))
- (cpath (string-append kernel "/include")))
- (for-each (cut setenv <> cpath)
- ',%gcc-cross-include-paths)
- (setenv "CROSS_LIBRARY_PATH"
- (string-append kernel "/lib")) ; for Hurd's libihash
- #t)))
- ,@(if (target-hurd? target)
- '((add-after 'install 'augment-libc.so
- (lambda* (#:key outputs #:allow-other-keys)
- (let* ((out (assoc-ref outputs "out")))
- (substitute* (string-append out "/lib/libc.so")
- (("/[^ ]+/lib/libc.so.0.3")
- (string-append out "/lib/libc.so.0.3"
- " libmachuser.so libhurduser.so"))))
- #t)))
- '())))))
-
- ;; Shadow the native "kernel-headers" because glibc's recipe expects the
- ;; "kernel-headers" input to point to the right thing.
- (propagated-inputs `(("kernel-headers" ,xheaders)))
-
- (native-inputs `(("cross-gcc" ,xgcc)
- ("cross-binutils" ,xbinutils)
- ,@(if (target-hurd? target)
- `(("cross-mig"
- ,(cross-mig target
- #:xgcc xgcc
- #:xbinutils xbinutils)))
- '())
- ,@(package-inputs libc) ;FIXME: static-bash
- ,@(package-native-inputs libc))))))
+and the cross tool chain. If TARGET does not have a libc then #f is returned."
+ (match target
+ ((? target-mingw?)
+ (let ((machine (substring target 0 (string-index target #\-))))
+ (make-mingw-w64 machine
+ #:xgcc xgcc
+ #:xbinutils xbinutils)))
+ ((or (? target-linux?) (? target-hurd?))
+ (package
+ (inherit libc)
+ (name (string-append "glibc-cross-" target))
+ (arguments
+ (substitute-keyword-arguments
+ `( ;; Disable stripping (see above.)
+ #:strip-binaries? #f
+
+ ;; This package is used as a target input, but it should not have
+ ;; the usual cross-compilation inputs since that would include
+ ;; itself.
+ #:implicit-cross-inputs? #f
+
+ ;; We need SRFI 26.
+ #:modules ((guix build gnu-build-system)
+ (guix build utils)
+ (srfi srfi-26))
+
+ ,@(package-arguments libc))
+ ((#:configure-flags flags)
+ `(cons ,(string-append "--host=" target)
+ ,(if (target-hurd? target)
+ `(append (list "--disable-werror"
+ ,@%glibc/hurd-configure-flags)
+ ,flags)
+ flags)))
+ ((#:phases phases)
+ `(modify-phases ,phases
+ (add-before 'configure 'set-cross-kernel-headers-path
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let* ((kernel (assoc-ref inputs "kernel-headers"))
+ (cpath (string-append kernel "/include")))
+ (for-each (cut setenv <> cpath)
+ ',%gcc-cross-include-paths)
+ (setenv "CROSS_LIBRARY_PATH"
+ (string-append kernel "/lib")) ; for Hurd's libihash
+ #t)))
+ ,@(if (target-hurd? target)
+ '((add-after 'install 'augment-libc.so
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let* ((out (assoc-ref outputs "out")))
+ (substitute* (string-append out "/lib/libc.so")
+ (("/[^ ]+/lib/libc.so.0.3")
+ (string-append out "/lib/libc.so.0.3"
+ " libmachuser.so libhurduser.so"))))
+ #t)))
+ '())))))
+
+ ;; Shadow the native "kernel-headers" because glibc's recipe expects the
+ ;; "kernel-headers" input to point to the right thing.
+ (propagated-inputs `(("kernel-headers" ,xheaders)))
+
+ (native-inputs `(("cross-gcc" ,xgcc)
+ ("cross-binutils" ,xbinutils)
+ ,@(if (target-hurd? target)
+ `(("cross-mig"
+ ,(cross-mig target
+ #:xgcc xgcc
+ #:xbinutils xbinutils)))
+ '())
+ ,@(package-inputs libc) ;FIXME: static-bash
+ ,@(package-native-inputs libc)))))
+ (else #f)))
;;; Concrete cross tool chains are instantiated like this:
diff --git a/guix/build-system/gnu.scm b/guix/build-system/gnu.scm
index c1aa187c42..1483f6baeb 100644
--- a/guix/build-system/gnu.scm
+++ b/guix/build-system/gnu.scm
@@ -460,10 +460,12 @@ (define standard-cross-packages
`(("cross-gcc" ,(gcc target
#:xbinutils (binutils target)
#:libc libc))
- ("cross-libc" ,libc)
+ ,@(if libc
+ `(("cross-libc" ,libc))
+ '())
;; MinGW's libc doesn't have a "static" output.
- ,@(if (member "static" (package-outputs libc))
+ ,@(if (and libc (member "static" (package-outputs libc)))
`(("cross-libc:static" ,libc "static"))
'()))))))))
--
2.34.1
Reply sent
to
Mathieu Othacehe <othacehe <at> gnu.org>
:
You have taken responsibility.
(Thu, 05 Oct 2023 15:22:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Jean-Pierre De Jesus DIAZ <jean <at> foundationdevices.com>
:
bug acknowledged by developer.
(Thu, 05 Oct 2023 15:22:02 GMT)
Full text and
rfc822 format available.
Message #10 received at 65016-done <at> debbugs.gnu.org (full text, mbox):
Hello,
> * gnu/packages/cross-base.scm (cross-libc): Return #f if TARGET does
> not contain a libc implementation.
This is the first patch of your 66263 series unless I'm mistaken.
Closing this one,
Thanks,
Mathieu
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Fri, 03 Nov 2023 11:24:06 GMT)
Full text and
rfc822 format available.
This bug report was last modified 1 year and 188 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.