GNU bug report logs - #67969
[PATCH 0/4] guix: scons: Support cross-compilation.

Previous Next

Package: guix-patches;

Reported by: Jean-Pierre De Jesus DIAZ <jean <at> foundationdevices.com>

Date: Fri, 22 Dec 2023 12:37:02 UTC

Severity: normal

Tags: patch

Done: Mathieu Othacehe <mathieu <at> meije.mail-host-address-is-not-set>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 67969 in the body.
You can then email your comments to 67969 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#67969; Package guix-patches. (Fri, 22 Dec 2023 12:37: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-patches <at> gnu.org. (Fri, 22 Dec 2023 12:37:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Jean-Pierre De Jesus DIAZ <jean <at> foundationdevices.com>
To: guix-patches <at> gnu.org
Cc: Jean-Pierre De Jesus DIAZ <jean <at> foundationdevices.com>
Subject: [PATCH 0/4] guix: scons: Support cross-compilation.
Date: Fri, 22 Dec 2023 13:36:29 +0100
This removes the need to use `(gnu packages cross-base)' in
the `make-nsis' procedure at `(gnu packages installers)' by
making use of the `#:target' keyword argument.

As a result scons-build-system now supports cross-compilation,
although it is not very useful for general cross-compilation
as SCons doesn't have a standard way of setting the "target"
and each SConscript specifies which toolchain to use
manually, so it depends on a per package basis on how to
select the correct target as projects will generally take
some command line variables for that, like in the `make-nsis'
case.

Jean-Pierre De Jesus DIAZ (4):
  guix: scons-build: Cleanup keyword arguments.
  guix: scons: Support cross-compilation.
  gnu: make-nsis: Use cross-compilation.
  gnu: make-nsis: Adjust description acronym.

 gnu/packages/installers.scm | 129 +++++++++++-------------------------
 guix/build-system/scons.scm | 110 +++++++++++++++++++++++++-----
 2 files changed, 132 insertions(+), 107 deletions(-)


base-commit: ca813173894360edef35a5d98878a3135e99e62a
-- 
2.41.0





Information forwarded to guix-patches <at> gnu.org:
bug#67969; Package guix-patches. (Fri, 22 Dec 2023 12:38:01 GMT) Full text and rfc822 format available.

Message #8 received at 67969 <at> debbugs.gnu.org (full text, mbox):

From: Jean-Pierre De Jesus DIAZ <jean <at> foundationdevices.com>
To: 67969 <at> debbugs.gnu.org
Cc: Jean-Pierre De Jesus DIAZ <jean <at> foundationdevices.com>
Subject: [PATCH 1/4] guix: scons-build: Cleanup keyword arguments.
Date: Fri, 22 Dec 2023 13:37:14 +0100
* guix/build-system/scons.scm (scons-build): Remove default value of #f
  from keyword arguments since they are #f if they are not present.

Change-Id: I18cca8abb350c99c20e87d623cc9975570731dfc
---
 guix/build-system/scons.scm | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/guix/build-system/scons.scm b/guix/build-system/scons.scm
index 046ddef740..6cbffcab63 100644
--- a/guix/build-system/scons.scm
+++ b/guix/build-system/scons.scm
@@ -75,7 +75,7 @@ (define* (lower name
 
 (define* (scons-build name inputs
                       #:key
-                      (source #f)
+                      guile source
                       (tests? #t)
                       (scons-flags ''())
                       (build-targets #~'())
@@ -85,7 +85,6 @@ (define* (scons-build name inputs
                       (outputs '("out"))
                       (search-paths '())
                       (system (%current-system))
-                      (guile #f)
                       (imported-modules %scons-build-system-modules)
                       (modules '((guix build scons-build-system)
                                  (guix build utils))))
-- 
2.41.0





Information forwarded to guix-patches <at> gnu.org:
bug#67969; Package guix-patches. (Fri, 22 Dec 2023 12:38:02 GMT) Full text and rfc822 format available.

Message #11 received at 67969 <at> debbugs.gnu.org (full text, mbox):

From: Jean-Pierre De Jesus DIAZ <jean <at> foundationdevices.com>
To: 67969 <at> debbugs.gnu.org
Cc: Jean-Pierre De Jesus DIAZ <jean <at> foundationdevices.com>
Subject: [PATCH 2/4] guix: scons: Support cross-compilation.
Date: Fri, 22 Dec 2023 13:37:15 +0100
* guix/build-system/scons.scm (lower): Add cross compilation support.

* guix/build-system/scons.scm (scons-build-cross): New procedure.

Change-Id: I90413c4b573f17455b007672f701ac81f514e057
---
 guix/build-system/scons.scm | 107 ++++++++++++++++++++++++++++++------
 1 file changed, 91 insertions(+), 16 deletions(-)

diff --git a/guix/build-system/scons.scm b/guix/build-system/scons.scm
index 6cbffcab63..3db007901c 100644
--- a/guix/build-system/scons.scm
+++ b/guix/build-system/scons.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2017 Arun Isaac <arunisaac <at> systemreboot.net>
 ;;; Copyright © 2021 Ludovic Courtès <ludo <at> gnu.org>
+;;; Copyright © 2023 Foundation Devices, Inc. <hello <at> foundationdevices.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -56,22 +57,28 @@ (define* (lower name
   (define private-keywords
     '(#:target #:scons #:inputs #:native-inputs))
 
-  (and (not target)                               ;XXX: no cross-compilation
-       (bag
-         (name name)
-         (system system)
-         (host-inputs `(,@(if source
-                              `(("source" ,source))
-                              '())
-                        ,@inputs
-
-                        ;; Keep the standard inputs of 'gnu-build-system'.
-                        ,@(standard-packages)))
-         (build-inputs `(("scons" ,scons)
-                         ,@native-inputs))
-         (outputs outputs)
-         (build scons-build)
-         (arguments (strip-keyword-arguments private-keywords arguments)))))
+  (bag
+    (name name)
+    (system system)
+    (target target)
+    (build-inputs `(("scons" ,scons)
+                    ,@(if source
+                         `(("source" ,source))
+                         '())
+                    ,@native-inputs
+
+                    ,@(if target '() inputs)
+                    ,@(if target
+                          (standard-cross-packages target 'host)
+                          '())
+                    ,@(standard-packages system)))
+    (host-inputs (if target inputs '()))
+    (target-inputs (if target
+                       (standard-cross-packages target 'target)
+                       '()))
+    (outputs outputs)
+    (build (if target scons-build-cross scons-build))
+    (arguments (strip-keyword-arguments private-keywords arguments))))
 
 (define* (scons-build name inputs
                       #:key
@@ -122,6 +129,74 @@ (define* (scons-build name inputs
                     #:graft? #f
                     #:guile-for-build guile))
 
+(define* (scons-build-cross name
+                            #:key
+                            target
+                            build-inputs target-inputs host-inputs
+                            guile source
+                            (tests? #f)
+                            (scons-flags ''())
+                            (build-targets #~'())
+                            (test-target "test")
+                            (install-targets #~'("install"))
+                            (phases '%standard-phases)
+                            (outputs '("out"))
+                            (search-paths '())
+                            (native-search-paths '())
+                            (system (%current-system))
+                            (build (nix-system->gnu-triplet system))
+                            (imported-modules %scons-build-system-modules)
+                            (modules '((guix build scons-build-system)
+                                       (guix build utils))))
+  (define builder
+    #~(begin
+        (use-modules #$@(sexp->gexp modules))
+
+        (define %build-host-inputs
+          #+(input-tuples->gexp build-inputs))
+
+        (define %build-target-inputs
+          (append #$(input-tuples->gexp host-inputs)
+                  #+(input-tuples->gexp target-inputs)))
+
+        (define %build-inputs
+          (append %build-host-inputs %build-target-inputs))
+
+        (define %outputs
+          #$(outputs->gexp outputs))
+
+        (scons-build #:name #$name
+                     #:source #+source
+                     #:scons-flags #$(if (pair? scons-flags)
+                                         (sexp->gexp scons-flags)
+                                         scons-flags)
+                     #:system #$system
+                     #:build #$build
+                     #:target #$target
+                     #:build-targets #$build-targets
+                     #:test-target #$test-target
+                     #:tests? #$tests?
+                     #:install-targets #$install-targets
+                     #:phases #$(if (pair? phases)
+                                    (sexp->gexp phases)
+                                    phases)
+                     #:outputs %outputs
+                     #:inputs %build-target-inputs
+                     #:native-inputs %build-host-inputs
+                     #:search-paths '#$(sexp->gexp
+                                         (map search-path-specification->sexp
+                                              search-paths))
+                     #:native-search-paths '#$(sexp->gexp
+                                               (map search-path-specification->sexp
+                                                    native-search-paths)))))
+
+  (gexp->derivation name builder
+                    #:system system
+                    #:target target
+                    #:graft? #f
+                    #:modules imported-modules
+                    #:guile-for-build guile))
+
 (define scons-build-system
   (build-system
     (name 'scons)
-- 
2.41.0





Information forwarded to guix-patches <at> gnu.org:
bug#67969; Package guix-patches. (Fri, 22 Dec 2023 12:38:02 GMT) Full text and rfc822 format available.

Message #14 received at 67969 <at> debbugs.gnu.org (full text, mbox):

From: Jean-Pierre De Jesus DIAZ <jean <at> foundationdevices.com>
To: 67969 <at> debbugs.gnu.org
Cc: Jean-Pierre De Jesus DIAZ <jean <at> foundationdevices.com>
Subject: [PATCH 4/4] gnu: make-nsis: Adjust description acronym.
Date: Fri, 22 Dec 2023 13:37:17 +0100
* gnu/packages/installers.scm (make-nsis) <description>: Use `@acronym'
  for NSIS.

Change-Id: Ibff07455897542672affc1762d85009eaed0065a
---
 gnu/packages/installers.scm | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gnu/packages/installers.scm b/gnu/packages/installers.scm
index 67e91b908d..9a971d5081 100644
--- a/gnu/packages/installers.scm
+++ b/gnu/packages/installers.scm
@@ -80,9 +80,9 @@ (define (make-nsis machine target-arch nsis-target-type)
       (home-page "https://nsis.sourceforge.io/Main_Page")
       (synopsis "System to create Windows installers")
       (description
-       "NSIS (Nullsoft Scriptable Install System) is a system to create
-Windows installers.  It is designed to be as small and flexible as possible
-and is therefore very suitable for internet distribution.")
+       "@acronym{NSIS, Nullsoft Scriptable Install System} is a system to
+create Windows installers.  It is designed to be as small and flexible as
+possible and is therefore very suitable for internet distribution.")
       (license (license:non-copyleft "file://COPYING"
                                      "See COPYING in the distribution.")))))
 
-- 
2.41.0





Information forwarded to guix-patches <at> gnu.org:
bug#67969; Package guix-patches. (Fri, 22 Dec 2023 12:38:02 GMT) Full text and rfc822 format available.

Message #17 received at 67969 <at> debbugs.gnu.org (full text, mbox):

From: Jean-Pierre De Jesus DIAZ <jean <at> foundationdevices.com>
To: 67969 <at> debbugs.gnu.org
Cc: Jean-Pierre De Jesus DIAZ <jean <at> foundationdevices.com>
Subject: [PATCH 3/4] gnu: make-nsis: Use cross-compilation.
Date: Fri, 22 Dec 2023 13:37:16 +0100
* gnu/packages/installers.scm (make-nsis): Use `#:target' keyword
  argument in order to cross-compile the package.

Change-Id: I403254a08f43bcd21e475807ea592c2f3908ff6b
---
 gnu/packages/installers.scm | 123 +++++++++++-------------------------
 1 file changed, 37 insertions(+), 86 deletions(-)

diff --git a/gnu/packages/installers.scm b/gnu/packages/installers.scm
index 9879359be7..67e91b908d 100644
--- a/gnu/packages/installers.scm
+++ b/gnu/packages/installers.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2019 Carl Dong <contact <at> carldong.me>
+;;; Copyright © 2023 Foundation Devices, Inc. <hello <at> foundationdevices.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -21,17 +22,14 @@ (define-module (gnu packages installers)
   #:use-module (gnu packages)
   #:use-module (gnu packages build-tools)
   #:use-module (gnu packages compression)
-  #:use-module (gnu packages cross-base)
   #:use-module (guix packages)
   #:use-module (guix download)
+  #:use-module (guix gexp)
   #:use-module (guix build-system scons)
   #:use-module (guix utils))
 
 (define (make-nsis machine target-arch nsis-target-type)
-  (let* ((triplet (string-append machine "-" "w64-mingw32"))
-         (xbinutils (cross-binutils triplet))
-         (xlibc (cross-libc triplet))
-         (xgcc (cross-gcc triplet #:libc xlibc)))
+  (let ((target (string-append machine "-" "w64-mingw32")))
     (package
       (name (string-append "nsis-" machine))
       (version "3.09")
@@ -44,88 +42,41 @@ (define (make-nsis machine target-arch nsis-target-type)
                   "1qjnvhnj89a40ac10k2mbln0yqscdmawmgw71816i465x734dn0c"))
                 (patches (search-patches "nsis-env-passthru.patch"))))
       (build-system scons-build-system)
-      (native-inputs `(("xgcc" ,xgcc)
-                       ("xbinutils" ,xbinutils)
-                       ("mingw-w64" ,xlibc)))
-      (inputs (list zlib))
       (arguments
-       `(#:scons ,scons-python2
-         #:modules ((srfi srfi-1)
-                    (srfi srfi-26)
-                    (guix build utils)
-                    (guix build scons-build-system))
-         #:tests? #f
-         #:scons-flags `("UNICODE=yes"
-                         "SKIPUTILS=MakeLangId,Makensisw,NSIS Menu,SubStart,zip2exe"
-                         "SKIPDOC=COPYING"
-                         "STRIP_CP=no"
-                         ,(string-append "PREFIX=" %output)
-                         ,(string-append "TARGET_ARCH=" ,target-arch)
-                         ,(string-append "XGCC_W32_PREFIX=" ,triplet "-")
-                         ,(string-append "PREFIX_PLUGINAPI_INC=" (assoc-ref %build-inputs "mingw-w64") "/include/")
-                         ,(string-append "PREFIX_PLUGINAPI_LIB=" (assoc-ref %build-inputs "mingw-w64") "/lib/"))
-         #:build-targets '("makensis"
-                           "stubs"
-                           "plugins"
-                           "utils")
-         #:install-targets '("install-stubs"
-                             "install-plugins"
-                             "install-data"
-                             "install-utils"
-                             "install-compiler"
-                             "install-conf")
-         #:phases (modify-phases %standard-phases
-                    (add-before 'build 'fix-env
-                      (lambda _
-                        (define* (filter-delimited-string delimited-string predicate #:optional (delimiter #\:))
-                          ;; Given a DELIMITED-STRING delimited by DELIMITER,
-                          ;; only keep items that satisfy PREDICATE
-                          (string-join
-                           (filter predicate (string-split delimited-string delimiter))
-                           (string delimiter)))
-                        (define (mingw-path? path)
-                          (string-prefix? (assoc-ref %build-inputs "mingw-w64") path))
-                        (for-each
-                         (lambda (env-name)
-                           (let ((env-val (getenv env-name)))
-                             ;; Remove all mingw-w64 paths from env vars meant
-                             ;; for native toolchain
-                             (setenv env-name
-                                     (filter-delimited-string env-val (negate mingw-path?)))
-                             ;; Add the removed paths back into CROSS_-prefixed
-                             ;; version of env vars
-                             (setenv (string-append "CROSS_" env-name)
-                                     (filter-delimited-string env-val mingw-path?))))
-                         '("C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH" "LIBRARY_PATH"))
-                        ;; Hack to place mingw-w64 path at the end of search
-                        ;; paths.  Could probably use a specfile and dirafter
-                        (setenv "CROSS_C_INCLUDE_PATH"
-                                (string-join
-                                 `(,@(map (cut string-append
-                                               (assoc-ref %build-inputs "xgcc")
-                                               "/lib/gcc/" ,triplet "/"
-                                               ,(package-version xgcc) <>)
-                                          '("/include"
-                                            "/include-fixed"))
-                                   ,(getenv "CROSS_C_INCLUDE_PATH"))
-                                 ":"))
-                        (setenv "CROSS_CPLUS_INCLUDE_PATH"
-                                (string-join
-                                 `(,@(map (cut string-append (assoc-ref %build-inputs "xgcc") <>)
-                                          `("/include/c++"
-                                            ,(string-append "/include/c++/" ,triplet)
-                                            "/include/c++/backward"
-                                            ,@(map (cut string-append "/lib/gcc/" ,triplet "/" ,(package-version xgcc) <>)
-                                                   '("/include"
-                                                     "/include-fixed"))))
-                                   ,(getenv "CROSS_CPLUS_INCLUDE_PATH"))
-                                 ":"))))
-                    (add-before 'build 'fix-target-detection
-                      (lambda _
-                        ;; NSIS target detection is screwed up, manually change
-                        ;; it ourselves
-                        (substitute* "Source/build.cpp" (("m_target_type=TARGET_X86UNICODE")
-                                                         (string-append "m_target_type=" ,nsis-target-type))))))))
+       (list #:target target
+             #:scons scons-python2
+             #:tests? #f
+             #:scons-flags
+             #~(let ((xlibc (assoc-ref %build-inputs "cross-libc")))
+                 (list "UNICODE=yes"
+                       "SKIPUTILS=MakeLangId,Makensisw,NSIS Menu,SubStart,zip2exe"
+                       "SKIPDOC=COPYING"
+                       "STRIP_CP=no"
+                       (string-append "PREFIX=" #$output)
+                       (string-append "TARGET_ARCH=" #$target-arch)
+                       (string-append "XGCC_W32_PREFIX=" #$target "-")
+                       (string-append "PREFIX_PLUGINAPI_INC=" xlibc "/include/")
+                       (string-append "PREFIX_PLUGINAPI_LIB=" xlibc "/lib/")))
+             #:build-targets #~'("makensis"
+                                 "stubs"
+                                 "plugins"
+                                 "utils")
+             #:install-targets #~'("install-stubs"
+                                   "install-plugins"
+                                   "install-data"
+                                   "install-utils"
+                                   "install-compiler"
+                                   "install-conf")
+             #:phases
+             #~(modify-phases %standard-phases
+                 (add-before 'build 'fix-target-detection
+                   (lambda _
+                     ;; NSIS target detection is screwed up, manually change
+                     ;; it ourselves
+                     (substitute* "Source/build.cpp"
+                      (("m_target_type=TARGET_X86UNICODE")
+                       (string-append "m_target_type=" #$nsis-target-type))))))))
+      (native-inputs (list zlib))
       (home-page "https://nsis.sourceforge.io/Main_Page")
       (synopsis "System to create Windows installers")
       (description
-- 
2.41.0





Information forwarded to guix-patches <at> gnu.org:
bug#67969; Package guix-patches. (Fri, 22 Dec 2023 14:44:01 GMT) Full text and rfc822 format available.

Message #20 received at 67969 <at> debbugs.gnu.org (full text, mbox):

From: Jean-Pierre De Jesus Diaz <jean <at> foundationdevices.com>
To: 67969 <at> debbugs.gnu.org
Subject: Re: [PATCH 0/4] guix: scons: Support cross-compilation.
Date: Fri, 22 Dec 2023 14:43:12 +0000
Hello,

Sorry for the noise but I've realised this is not the correct
solution as the nsis compiler is indeed a Linux binary and
only code needed for Windows is cross-compiled to
mingw32.

So it makes sense to have the cross toolchain as an input
instead of using target.

-- 
Jean-Pierre De Jesus DIAZ
Foundation Devices, Inc.




Information forwarded to guix-patches <at> gnu.org:
bug#67969; Package guix-patches. (Fri, 22 Dec 2023 14:46:02 GMT) Full text and rfc822 format available.

Message #23 received at 67969 <at> debbugs.gnu.org (full text, mbox):

From: Jean-Pierre De Jesus Diaz <jean <at> foundationdevices.com>
To: 67969 <at> debbugs.gnu.org
Subject: Re: [PATCH 0/4] guix: scons: Support cross-compilation.
Date: Fri, 22 Dec 2023 14:44:59 +0000
close 67969

On Fri, Dec 22, 2023 at 2:43 PM Jean-Pierre De Jesus Diaz
<jean <at> foundationdevices.com> wrote:
>
> Hello,
>
> Sorry for the noise but I've realised this is not the correct
> solution as the nsis compiler is indeed a Linux binary and
> only code needed for Windows is cross-compiled to
> mingw32.
>
> So it makes sense to have the cross toolchain as an input
> instead of using target.
>
> --
> Jean-Pierre De Jesus DIAZ
> Foundation Devices, Inc.



-- 
Jean-Pierre De Jesus DIAZ
Foundation Devices, Inc.




bug closed, send any further explanations to 67969 <at> debbugs.gnu.org and Jean-Pierre De Jesus DIAZ <jean <at> foundationdevices.com> Request was from Mathieu Othacehe <mathieu <at> meije.mail-host-address-is-not-set> to control <at> debbugs.gnu.org. (Mon, 25 Dec 2023 16:35:01 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 23 Jan 2024 12:24:11 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 144 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.