* [bug#56882] [PATCH 0/4] build-system/perl: Support some cross-compilation, and test with xdg-utils
@ 2022-08-02 11:54 Maxime Devos
2022-08-02 12:13 ` [bug#56882] [PATCH 1/4] build-system/perl: Support cross-compilation of some Perl packages Maxime Devos
2022-08-06 16:25 ` bug#56882: [PATCH 0/4] build-system/perl: Support some cross-compilation, and test with xdg-utils Mathieu Othacehe
0 siblings, 2 replies; 6+ messages in thread
From: Maxime Devos @ 2022-08-02 11:54 UTC (permalink / raw)
To: 56882
[-- Attachment #1.1.1: Type: text/plain, Size: 376 bytes --]
Supporting cross-compilation of xdg-utils opens the way to trying
cross-compilation of Qt things.
Things like XS are unsupported -- going by
https://arsv.github.io/perl-cross/modules.html and the web page that
states that external modules need to be copied into Perl first (but
which I cannot find anymore), it sounds rather complicated.
Greeetings,
Maxime.
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 929 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* [bug#56882] [PATCH 1/4] build-system/perl: Support cross-compilation of some Perl packages.
2022-08-02 11:54 [bug#56882] [PATCH 0/4] build-system/perl: Support some cross-compilation, and test with xdg-utils Maxime Devos
@ 2022-08-02 12:13 ` Maxime Devos
2022-08-02 12:13 ` [bug#56882] [PATCH 2/4] gnu: freedesktop: Add 'bash' input for 'wrap-program' Maxime Devos
` (2 more replies)
2022-08-06 16:25 ` bug#56882: [PATCH 0/4] build-system/perl: Support some cross-compilation, and test with xdg-utils Mathieu Othacehe
1 sibling, 3 replies; 6+ messages in thread
From: Maxime Devos @ 2022-08-02 12:13 UTC (permalink / raw)
To: 56882; +Cc: Maxime Devos
* guix/build-system/perl.scm: Add info on cross-compilation.
(lower)[private-keywords]: Remove #:target when cross-compiling.
(lower)[target]: Set.
(host-inputs)[perl]: New entry.
(host-inputs)[(standard-packages)]: Move to ...
(build-inputs)[(standard-packages)]: ... here when cross-compiling.
(build-inputs)[standard-cross-packages]: Add when cross-compiling.
(target-inputs): New entry when cross-compiling.
(build): Use perl-cross-build when cross-compiling.
(perl-cross-build): New procedure.
---
guix/build-system/perl.scm | 120 +++++++++++++++++++++++++++++++------
1 file changed, 103 insertions(+), 17 deletions(-)
diff --git a/guix/build-system/perl.scm b/guix/build-system/perl.scm
index db0a916fb2..3890cd91ea 100644
--- a/guix/build-system/perl.scm
+++ b/guix/build-system/perl.scm
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2013, 2014, 2015, 2021 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2022 Maxime Devos <maximedevos@telenet.be>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -29,13 +30,17 @@ (define-module (guix build-system perl)
#:use-module (ice-9 match)
#:export (%perl-build-system-modules
perl-build
+ perl-cross-build
perl-build-system))
;; Commentary:
;;
;; Standard build procedure for Perl packages using the "makefile
;; maker"---i.e., "perl Makefile.PL". This is implemented as an extension of
-;; `gnu-build-system'.
+;; `gnu-build-system'. Cross-compilation is supported for some simple Perl
+;; packages, but not for any Perl packages that do things like XS (Perl's FFI),
+;; which makes C-style shared libraries, as it is currently not known how to
+;; tell Perl to properly cross-compile.
;;
;; Code:
@@ -59,24 +64,43 @@ (define* (lower name
#:rest arguments)
"Return a bag for NAME."
(define private-keywords
- '(#:target #:perl #:inputs #:native-inputs))
+ `(#:perl #:inputs #:native-inputs
+ ,@(if target '() '(#:target))))
- (and (not target) ;XXX: no cross-compilation
- (bag
- (name name)
- (system system)
- (host-inputs `(,@(if source
- `(("source" ,source))
- '())
- ,@inputs
+ (bag
+ (name name)
+ (system system) (target target)
+ (host-inputs `(,@(if source
+ `(("source" ,source))
+ '())
+ ,@inputs
+ ;; For interpreters in #! (shebang)
+ ,@(if target
+ `(("perl" ,perl))
+ '())
- ;; Keep the standard inputs of 'gnu-build-system'.
- ,@(standard-packages)))
- (build-inputs `(("perl" ,perl)
- ,@native-inputs))
- (outputs outputs)
- (build perl-build)
- (arguments (strip-keyword-arguments private-keywords arguments)))))
+ ;; Keep the standard inputs of 'gnu-build-system'.
+ ;; TODO: make this unconditional, putting this into 'build-inputs'.
+ ,@(if target
+ '()
+ (standard-packages))))
+ (build-inputs `(("perl" ,perl)
+ ,@native-inputs
+ ,@(if target
+ (standard-cross-packages target 'host)
+ '())
+ ,@(if target
+ (standard-packages)
+ '())))
+ ;; Keep the standard inputs of 'gnu-build-system'.
+ (target-inputs (if target
+ (standard-cross-packages target 'target)
+ '()))
+ (outputs outputs)
+ (build (if target
+ perl-cross-build
+ perl-build))
+ (arguments (strip-keyword-arguments private-keywords arguments))))
(define* (perl-build name inputs
#:key source
@@ -127,6 +151,68 @@ (define build
(gexp->derivation name build
#:system system
#:target #f
+ #:graft? #f
+ #:guile-for-build guile)))
+
+(define* (perl-cross-build name #:key
+ source
+ target
+ build-inputs host-inputs target-inputs
+ (search-paths '())
+ (native-search-paths '())
+ (tests? #f) ; usually not possible when cross-compiling
+ (parallel-build? #t)
+ (parallel-tests? #t)
+ (make-maker? #f)
+ (make-maker-flags ''())
+ (module-build-flags ''())
+ (phases '(@ (guix build perl-build-system)
+ %standard-phases))
+ (outputs '("out"))
+ (system (%current-system))
+ (build (nix-system->gnu-triplet system))
+ (guile #f)
+ (imported-modules %perl-build-system-modules)
+ (modules '((guix build perl-build-system)
+ (guix build utils))))
+ "Cross-build SOURCE to TARGET using PERL, and with INPUTS. This assumes that
+SOURCE provides a `Makefile.PL' file as its build system and does not use XS
+or similar."
+ (define inputs
+ #~(append #$(input-tuples->gexp host-inputs)
+ #+(input-tuples->gexp target-inputs)))
+ (define builder
+ (with-imported-modules imported-modules
+ #~(begin
+ (use-modules #$@(sexp->gexp modules))
+ (perl-build #:name #$name
+ #:source #+source
+ #:search-paths '#$(sexp->gexp
+ (map search-path-specification->sexp
+ search-paths))
+ #:native-search-paths '#$(sexp->gexp
+ (map search-path-specification->sexp
+ native-search-paths))
+ #:make-maker? #$make-maker?
+ #:make-maker-flags #$make-maker-flags
+ #:module-build-flags #$(sexp->gexp module-build-flags)
+ #:phases #$phases
+ #:build #$build
+ #:system #$system
+ #:target #$target
+ #:test-target "test"
+ #:tests? #$tests?
+ #:parallel-build? #$parallel-build?
+ #:parallel-tests? #$parallel-tests?
+ #:outputs #$(outputs->gexp outputs)
+ #:inputs #$inputs
+ #:native-inputs #+(input-tuples->gexp build-inputs)))))
+ (mlet %store-monad ((guile (package->derivation (or guile (default-guile))
+ system #:graft? #f)))
+ (gexp->derivation name builder
+ #:system system
+ #:target target
+ #:graft? #false
#:guile-for-build guile)))
(define perl-build-system
base-commit: d519305d83d08058e4def2c4d72fe62102d9599d
--
2.37.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [bug#56882] [PATCH 2/4] gnu: freedesktop: Add 'bash' input for 'wrap-program'
2022-08-02 12:13 ` [bug#56882] [PATCH 1/4] build-system/perl: Support cross-compilation of some Perl packages Maxime Devos
@ 2022-08-02 12:13 ` Maxime Devos
2022-08-02 12:13 ` [bug#56882] [PATCH 3/4] perl-file-mimeinfo: Fix cross-compilation Maxime Devos
2022-08-02 12:13 ` [bug#56882] [PATCH 4/4] xdg-utils: Support cross-compilation Maxime Devos
2 siblings, 0 replies; 6+ messages in thread
From: Maxime Devos @ 2022-08-02 12:13 UTC (permalink / raw)
To: 56882; +Cc: Maxime Devos
It is required for cross-compilation.
Cherry-picked from <https://issues.guix.gnu.org/49327#6>.
* gnu/packages/freedesktop.scm
(udisks)[inputs]: Add 'bash-minimal' when cross-compiling.
(perl-file-mimeinfo)[inputs]: Likewise.
(udiskie)[inputs]: Likewise.
---
gnu/packages/freedesktop.scm | 33 +++++++++++++++++++++++++--------
1 file changed, 25 insertions(+), 8 deletions(-)
diff --git a/gnu/packages/freedesktop.scm b/gnu/packages/freedesktop.scm
index 4d06235771..577b354f66 100644
--- a/gnu/packages/freedesktop.scm
+++ b/gnu/packages/freedesktop.scm
@@ -1319,13 +1319,17 @@ (define-public udisks
(propagated-inputs
(list glib)) ; required by udisks2.pc
(inputs
- (list acl
- cryptsetup
- libatasmart
- libblockdev
- libgudev
- polkit
- util-linux))
+ `(,acl
+ ;; TODO(staging): Make unconditional.
+ ,@(if (%current-target-system)
+ (list bash-minimal) ; for wrap-program
+ '())
+ ,cryptsetup
+ ,libatasmart
+ ,libblockdev
+ ,libgudev
+ ,polkit
+ ,util-linux))
(outputs '("out"
"doc")) ;5 MiB of gtk-doc HTML
(arguments
@@ -1930,6 +1934,11 @@ (define-public perl-file-mimeinfo
(base32
"1sh8r6vczyz08zm8vfsjmkg6a165wch54akjdrd1vbifcmwjg5pi"))))
(build-system perl-build-system)
+ (inputs
+ ;; TODO(staging): Make unconditional.
+ (if (%current-target-system)
+ (list bash-minimal) ; for wrap-program
+ '()))
;; If the tests are fixed, add perl-test-pod, perl-test-pod-coverage, and
;; perl-test-tiny as native-inputs.
(propagated-inputs
@@ -2026,7 +2035,15 @@ (define-public udiskie
("gettext" ,gettext-minimal)
("gobject-introspection" ,gobject-introspection)))
(inputs
- (list gobject-introspection gtk+ libappindicator libnotify udisks))
+ ;; TODO(staging): Make unconditional.
+ `(,@(if (%current-target-system)
+ (list bash-minimal)
+ '())
+ ,gobject-introspection
+ ,gtk+
+ ,libappindicator
+ ,libnotify
+ ,udisks))
(propagated-inputs
(list python-docopt python-pygobject python-keyutils python-pyxdg
python-pyyaml))
--
2.37.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [bug#56882] [PATCH 3/4] perl-file-mimeinfo: Fix cross-compilation.
2022-08-02 12:13 ` [bug#56882] [PATCH 1/4] build-system/perl: Support cross-compilation of some Perl packages Maxime Devos
2022-08-02 12:13 ` [bug#56882] [PATCH 2/4] gnu: freedesktop: Add 'bash' input for 'wrap-program' Maxime Devos
@ 2022-08-02 12:13 ` Maxime Devos
2022-08-02 12:13 ` [bug#56882] [PATCH 4/4] xdg-utils: Support cross-compilation Maxime Devos
2 siblings, 0 replies; 6+ messages in thread
From: Maxime Devos @ 2022-08-02 12:13 UTC (permalink / raw)
To: 56882; +Cc: Maxime Devos
The result of "guix style" was ignored, as it put #~(modify-phases ...) on the
same line as #:phases, causing it to go beyond to 80 columns limit.
* gnu/packages/freedesktop.scm
(perl-file-mimeinfo)[arguments]<#:phases>: Make it a G-exp to avoid messy nested
quasiquotation.
{wrap-programs}: When cross-compiling, don't use the PELRL5LIB environment
variable, instead use 'search-path-as-list'.
---
gnu/packages/freedesktop.scm | 37 +++++++++++++++++++++++-------------
1 file changed, 24 insertions(+), 13 deletions(-)
diff --git a/gnu/packages/freedesktop.scm b/gnu/packages/freedesktop.scm
index 577b354f66..2d12567a42 100644
--- a/gnu/packages/freedesktop.scm
+++ b/gnu/packages/freedesktop.scm
@@ -1946,19 +1946,30 @@ (define-public perl-file-mimeinfo
(arguments
;; Some tests fail due to requiring the mimetype of perl files to be
;; text/plain when they are actually application/x-perl.
- `(#:tests? #f
- #:phases
- (modify-phases %standard-phases
- (add-after 'install 'wrap-programs
- (lambda* (#:key outputs #:allow-other-keys)
- (let ((out (assoc-ref outputs "out")))
- (for-each (lambda (prog)
- (wrap-program (string-append out "/bin/" prog)
- `("PERL5LIB" ":" prefix
- (,(string-append (getenv "PERL5LIB") ":" out
- "/lib/perl5/site_perl")))))
- '("mimeopen" "mimetype")))
- #t)))))
+ (list #:tests? #f
+ #:phases
+ #~(modify-phases %standard-phases
+ (add-after 'install 'wrap-programs
+ ;; TODO(staging): Make unconditional.
+ (lambda* (#:key #$@(if (%current-target-system)
+ #~(inputs)
+ #~()) outputs #:allow-other-keys)
+ (let ((out (assoc-ref outputs "out")))
+ (for-each
+ (lambda (prog)
+ (wrap-program (string-append out "/bin/" prog)
+ `("PERL5LIB" ":" prefix
+ ;; PERL5LIB looks in 'native-inputs', not 'inputs',
+ ;; whereas the latter is required for
+ ;; cross-compilation.
+ #$(if (%current-target-system)
+ #~,(search-path-as-list
+ '("lib/perl5/site_perl")
+ (map cdr (append inputs outputs)))
+ #~(,(string-append (getenv "PERL5LIB") ":" out
+ "/lib/perl5/site_perl"))))))
+ '("mimeopen" "mimetype")))
+ #t)))))
(home-page "https://metacpan.org/release/File-MimeInfo")
(synopsis "Determine file type from the file name")
(description
--
2.37.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [bug#56882] [PATCH 4/4] xdg-utils: Support cross-compilation.
2022-08-02 12:13 ` [bug#56882] [PATCH 1/4] build-system/perl: Support cross-compilation of some Perl packages Maxime Devos
2022-08-02 12:13 ` [bug#56882] [PATCH 2/4] gnu: freedesktop: Add 'bash' input for 'wrap-program' Maxime Devos
2022-08-02 12:13 ` [bug#56882] [PATCH 3/4] perl-file-mimeinfo: Fix cross-compilation Maxime Devos
@ 2022-08-02 12:13 ` Maxime Devos
2 siblings, 0 replies; 6+ messages in thread
From: Maxime Devos @ 2022-08-02 12:13 UTC (permalink / raw)
To: 56882; +Cc: Maxime Devos
"guix style" does not support with-directory-excursion yet, leading to too
much spacing, so I have ignored its results.
It has been verified that this does not cause rebuilds when compiling
natively. The references graph when cross-compiling has also been verified --
glibc-2.33 and the native bash-static-5.1.8 still remains in the graph, but
via the cross-compiled inetutils-2.0, ncurses-6.2.20210619 and via
gcc-cross-TARGET-10.3.0-lib, which is not related with Perl cross-compilation.
* gnu/packages/freedesktop.scm
(xdg-utils)[inputs]{bash-minimal,file}: New inputs when cross-compiling.
(xdg-utils)[arguments]<#:phases>{locate-catalog-files}: Add 'native-inputs'
argument when cross-compiling. Look for docbook-xml and docbook-xsl in
native-inputs when cross-compiling. While we are at it, eliminate input
labels with search-input-file.
(xdg-utils)[arguments]<#:phases>{patch-hardcoded-patch}: Use
search-input-file + inputs instead of 'which' when cross-compiling.
---
gnu/packages/freedesktop.scm | 58 ++++++++++++++++++++++++++++--------
1 file changed, 45 insertions(+), 13 deletions(-)
diff --git a/gnu/packages/freedesktop.scm b/gnu/packages/freedesktop.scm
index 2d12567a42..1c984ebca8 100644
--- a/gnu/packages/freedesktop.scm
+++ b/gnu/packages/freedesktop.scm
@@ -25,7 +25,7 @@
;;; Copyright © 2021 pineapples <guixuser6392@protonmail.com>
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
;;; Copyright © 2021 Robby Zambito <contact@robbyzambito.me>
-;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
+;;; Copyright © 2021, 2022 Maxime Devos <maximedevos@telenet.be>
;;; Copyright © 2021 John Kehayias <john.kehayias@protonmail.com>
;;; Copyright © 2021, 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2022 Daniel Meißner <daniel.meissner-i4k@ruhr-uni-bochum.de>
@@ -76,6 +76,7 @@ (define-module (gnu packages freedesktop)
#:use-module (gnu packages disk)
#:use-module (gnu packages docbook)
#:use-module (gnu packages documentation)
+ #:use-module (gnu packages file)
#:use-module (gnu packages fontutils)
#:use-module (gnu packages gawk)
#:use-module (gnu packages gettext)
@@ -414,7 +415,15 @@ (define-public xdg-utils
(list docbook-xsl docbook-xml-4.1.2 libxslt w3m xmlto))
(inputs
`(("awk" ,gawk)
+ ;; TODO(staging): Make this unconditional, to avoid canonical packages,
+ ;; see <https://lists.gnu.org/archive/html/guix-devel/2020-02/msg00148.html>.
+ ,@(if (%current-target-system)
+ `(("bash-minimal" ,bash-minimal)) ; for 'wrap-program'
+ '())
("coreutils" ,coreutils)
+ ,@(if (%current-target-system)
+ `(("file" ,file))
+ '())
("grep" ,grep)
("inetutils" ,inetutils) ; xdg-screensaver uses `hostname'
("perl-file-mimeinfo" ,perl-file-mimeinfo) ; for mimeopen fallback
@@ -428,19 +437,41 @@ (define-public xdg-utils
#:phases
(modify-phases %standard-phases
(add-after 'unpack 'patch-hardcoded-paths
- (lambda _
- (substitute* "scripts/xdg-mime.in"
- (("/usr/bin/file") (which "file")))
- (substitute* "scripts/xdg-open.in"
- (("/usr/bin/printf") (which "printf")))
- #t))
+ ;; TODO(staging): make unconditional
+ (,@(if (%current-target-system)
+ '(lambda* (#:key inputs #:allow-other-keys))
+ '(lambda _))
+ (substitute* "scripts/xdg-mime.in"
+ (("/usr/bin/file")
+ (,@(if (%current-target-system)
+ '(search-input-file inputs "bin/file")
+ '(which "file")))))
+ (substitute* "scripts/xdg-open.in"
+ (("/usr/bin/printf")
+ (,@(if (%current-target-system)
+ '(search-input-file inputs "bin/printf")
+ '(which "printf")))))
+ #t))
(add-before 'build 'locate-catalog-files
- (lambda* (#:key inputs #:allow-other-keys)
- (let ((xmldoc (string-append (assoc-ref inputs "docbook-xml")
- "/xml/dtd/docbook"))
- (xsldoc (string-append (assoc-ref inputs "docbook-xsl")
- "/xml/xsl/docbook-xsl-"
- ,(package-version docbook-xsl))))
+ ;; TODO(staging): Make unconditional for simplicity.
+ (lambda* (#:key inputs ,@(if (%current-target-system)
+ '(native-inputs)
+ '()) #:allow-other-keys)
+ ;; TODO(staging): Make unconditional for simplicity and
+ ;; to avoid dependning on input labels.
+ (let ,(if (%current-target-system)
+ `((native-inputs (or native-inputs inputs))
+ (xmldoc (search-input-directory native-inputs
+ "xml/dtd/docbook"))
+ (xsldoc (search-input-directory
+ native-inputs
+ (string-append "xml/xsl/docbook-xsl-"
+ ,(package-version docbook-xsl)))))
+ `((xmldoc (string-append (assoc-ref inputs "docbook-xml")
+ "/xml/dtd/docbook"))
+ (xsldoc (string-append (assoc-ref inputs "docbook-xsl")
+ "/xml/xsl/docbook-xsl-"
+ ,(package-version docbook-xsl)))))
(for-each (lambda (file)
(substitute* file
(("http://.*/docbookx\\.dtd")
@@ -456,6 +487,7 @@ (define-public xdg-utils
"/manpages/docbook.xsl man")))
(setenv "STYLESHEET"
(string-append xsldoc "/html/docbook.xsl"))
+ ;; TODO(staging): Might as well remove the #t while we are at it.
#t)))
(add-after 'install 'wrap-executables
(lambda* (#:key inputs outputs #:allow-other-keys)
--
2.37.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* bug#56882: [PATCH 0/4] build-system/perl: Support some cross-compilation, and test with xdg-utils
2022-08-02 11:54 [bug#56882] [PATCH 0/4] build-system/perl: Support some cross-compilation, and test with xdg-utils Maxime Devos
2022-08-02 12:13 ` [bug#56882] [PATCH 1/4] build-system/perl: Support cross-compilation of some Perl packages Maxime Devos
@ 2022-08-06 16:25 ` Mathieu Othacehe
1 sibling, 0 replies; 6+ messages in thread
From: Mathieu Othacehe @ 2022-08-06 16:25 UTC (permalink / raw)
To: Maxime Devos; +Cc: 56882-done
Hello Maxime,
> Supporting cross-compilation of xdg-utils opens the way to trying
> cross-compilation of Qt things.
>
> Things like XS are unsupported -- going by
> https://arsv.github.io/perl-cross/modules.html and the web page that states
> that external modules need to be copied into Perl first (but which I cannot
> find anymore), it sounds rather complicated.
At least that's a very good start :) I fixed some long lines before pushing.
Thanks,
Mathieu
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-08-06 16:26 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-02 11:54 [bug#56882] [PATCH 0/4] build-system/perl: Support some cross-compilation, and test with xdg-utils Maxime Devos
2022-08-02 12:13 ` [bug#56882] [PATCH 1/4] build-system/perl: Support cross-compilation of some Perl packages Maxime Devos
2022-08-02 12:13 ` [bug#56882] [PATCH 2/4] gnu: freedesktop: Add 'bash' input for 'wrap-program' Maxime Devos
2022-08-02 12:13 ` [bug#56882] [PATCH 3/4] perl-file-mimeinfo: Fix cross-compilation Maxime Devos
2022-08-02 12:13 ` [bug#56882] [PATCH 4/4] xdg-utils: Support cross-compilation Maxime Devos
2022-08-06 16:25 ` bug#56882: [PATCH 0/4] build-system/perl: Support some cross-compilation, and test with xdg-utils Mathieu Othacehe
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.