GNU bug report logs - #27018
[PATCH 0/5] Cross-compiler fixes

Previous Next

Package: guix-patches;

Reported by: Ricardo Wurmus <rekado <at> elephly.net>

Date: Mon, 22 May 2017 13:57:02 UTC

Severity: normal

Tags: patch

Done: Ricardo Wurmus <rekado <at> elephly.net>

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 27018 in the body.
You can then email your comments to 27018 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#27018; Package guix-patches. (Mon, 22 May 2017 13:57:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ricardo Wurmus <rekado <at> elephly.net>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Mon, 22 May 2017 13:57:02 GMT) Full text and rfc822 format available.

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

From: Ricardo Wurmus <rekado <at> elephly.net>
To: guix-patches <at> gnu.org
Cc: Ricardo Wurmus <rekado <at> elephly.net>
Subject: [PATCH 0/5] Cross-compiler fixes
Date: Mon, 22 May 2017 15:55:31 +0200
Hi Guix,

my goal here was to get a working C++ cross-compiler for arm-none-eabi (for
the Axoloti audio board).  While doing this I remembered that
"gcc-arm-none-eabi-4.9" was using "%xgcc" (which happens to be gcc-5) instead
of "gcc-4.9" because of the way that "cross-gcc" works.

The first few patches change "cross-gcc" and its users such that a xgcc
argument can be supplied (it defaults to %xgcc).  With that out of the way I
built libstdc++ for arm-none-eabi and added it to the arm-none-eabi-toolchain.

I also changed the toolchain package to present the union of all inputs at the
output.  That makes it much nicer for other packages to use the toolchain as
an input, because it actually contains files.

I have already successfully built the Axoloti firmware with the new toolchain,
and I'm preparing a patch set to finally add it (and the Java patcher UI) to
Guix proper.



Ricardo Wurmus (5):
  gnu: Allow overriding of xgcc package in cross-gcc.
  gnu: avr-gcc-4.9: Use gcc-4.9 as base compiler.
  gnu: Add libstdc++-arm-none-eabi.
  gnu: arm-none-eabi-toolchain: Provide union of all inputs at the
    output.
  gnu: arm-none-eabi-toolchain: Include libstdc++.

 gnu/packages/avr.scm        |  4 ++--
 gnu/packages/cross-base.scm | 28 ++++++++++++++++------------
 gnu/packages/embedded.scm   | 43 +++++++++++++++++++++++++++++++++++++++----
 3 files changed, 57 insertions(+), 18 deletions(-)

-- 
2.12.2






Information forwarded to guix-patches <at> gnu.org:
bug#27018; Package guix-patches. (Mon, 22 May 2017 14:14:02 GMT) Full text and rfc822 format available.

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

From: Ricardo Wurmus <rekado <at> elephly.net>
To: 27018 <at> debbugs.gnu.org
Cc: Ricardo Wurmus <rekado <at> elephly.net>
Subject: [PATCH 1/5] gnu: Allow overriding of xgcc package in cross-gcc.
Date: Mon, 22 May 2017 16:13:15 +0200
* gnu/packages/cross-base.scm (cross-gcc-arguments): Take extra "xgcc"
argument.
(cross-gcc): Use keyword arguments; take optional "xgcc" argument.
* gnu/packages/embedded.scm (gcc-arm-none-eabi-4.9, propeller-gcc, gcc-vc4):
Use keyword arguments.
* gnu/packages/avr.scm (avr-gcc-4.9): Likewise.
---
 gnu/packages/avr.scm        |  2 +-
 gnu/packages/cross-base.scm | 28 ++++++++++++++++------------
 gnu/packages/embedded.scm   |  7 ++++---
 3 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/gnu/packages/avr.scm b/gnu/packages/avr.scm
index fd18ff6a9..fc4eb8db0 100644
--- a/gnu/packages/avr.scm
+++ b/gnu/packages/avr.scm
@@ -39,7 +39,7 @@
     (name "avr-binutils")))
 
 (define-public avr-gcc-4.9
-  (let ((xgcc (cross-gcc "avr" avr-binutils)))
+  (let ((xgcc (cross-gcc "avr" #:xbinutils avr-binutils)))
     (package
       (inherit xgcc)
       (name "avr-gcc")
diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index 47e095819..54303b7b4 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -100,9 +100,9 @@
                binutils)
            target)))
 
-(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.)"
+(define (cross-gcc-arguments target xgcc libc)
+  "Return build system arguments for a cross-gcc for TARGET, using XGCC as the
+base compiler and using LIBC (which may be either a libc package or #f.)"
   ;; Set the current target system so that 'glibc-dynamic-linker' returns the
   ;; right name.
   (parameterize ((%current-target-system target))
@@ -111,7 +111,7 @@ may be either a libc package or #f.)"
     ;; <http://lists.fedoraproject.org/pipermail/arm/2010-August/000663.html>
     ;; for instance.
     (let ((args `(#:strip-binaries? #f
-                  ,@(package-arguments %xgcc))))
+                  ,@(package-arguments xgcc))))
      (substitute-keyword-arguments args
        ((#:configure-flags flags)
         `(append (list ,(string-append "--target=" target)
@@ -183,18 +183,22 @@ may be either a libc package or #f.)"
         (else #f)))
 
 (define* (cross-gcc target
-                    #:optional (xbinutils (cross-binutils target)) libc)
+                    #:key
+                    (xgcc %xgcc)
+                    (xbinutils (cross-binutils target))
+                    (libc #f))
   "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 %xgcc)
+XGCC as the base compiler.  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 xgcc)
     (name (string-append "gcc-cross-"
                          (if libc "" "sans-libc-")
                          target))
-    (source (origin (inherit (package-source %xgcc))
+    (source (origin (inherit (package-source xgcc))
               (patches
                (append
-                (origin-patches (package-source %xgcc))
+                (origin-patches (package-source xgcc))
                 (cons (search-patch "gcc-cross-environment-variables.patch")
                       (cross-gcc-patches target))))
               (modules '((guix build utils)))
@@ -216,7 +220,7 @@ GCC that does not target a libc; otherwise, target that libc."
                   (srfi srfi-26)
                   (ice-9 regex))
 
-       ,@(cross-gcc-arguments target libc)))
+       ,@(cross-gcc-arguments target xgcc libc)))
 
     (native-inputs
      `(("ld-wrapper-cross" ,(make-ld-wrapper
@@ -230,7 +234,7 @@ GCC that does not target a libc; otherwise, target that libc."
        ("libc-native" ,@(assoc-ref (%final-inputs) "libc"))
 
        ;; Remaining inputs.
-       ,@(let ((inputs (append (package-inputs %xgcc)
+       ,@(let ((inputs (append (package-inputs xgcc)
                                (alist-delete "libc" (%final-inputs)))))
            (cond
             ((target-mingw? target)
diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
index b919bdf6c..632682d63 100644
--- a/gnu/packages/embedded.scm
+++ b/gnu/packages/embedded.scm
@@ -52,7 +52,8 @@
 ;; See https://launchpadlibrarian.net/218827644/release.txt
 (define-public gcc-arm-none-eabi-4.9
   (let ((xgcc (cross-gcc "arm-none-eabi"
-                         (cross-binutils "arm-none-eabi")))
+                         #:xgcc gcc-4.9
+                         #:xbinutils (cross-binutils "arm-none-eabi")))
         (revision "1")
         (svn-revision 227977))
     (package (inherit xgcc)
@@ -419,7 +420,7 @@ with a layered architecture of JTAG interface and TAP support.")
 
 (define-public propeller-gcc
   (let ((xgcc (cross-gcc "propeller-elf"
-                         propeller-binutils))
+                         #:xbinutils propeller-binutils))
         (commit "b4f45a4725e0b6d0af59e594c4e3e35ca4105867")
         (revision "1"))
     (package (inherit xgcc)
@@ -776,7 +777,7 @@ the Raspberry Pi chip.")
 
 (define-public gcc-vc4
   (let ((commit "165f6d0e11d2e76ee799533bb45bd5c92bf60dc2")
-        (xgcc (cross-gcc "vc4-elf" binutils-vc4)))
+        (xgcc (cross-gcc "vc4-elf" #:xbinutils binutils-vc4)))
     (package (inherit xgcc)
       (name "gcc-vc4")
       (source (origin
-- 
2.12.2






Information forwarded to guix-patches <at> gnu.org:
bug#27018; Package guix-patches. (Mon, 22 May 2017 14:14:02 GMT) Full text and rfc822 format available.

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

From: Ricardo Wurmus <rekado <at> elephly.net>
To: 27018 <at> debbugs.gnu.org
Cc: Ricardo Wurmus <rekado <at> elephly.net>
Subject: [PATCH 3/5] gnu: Add libstdc++-arm-none-eabi.
Date: Mon, 22 May 2017 16:13:17 +0200
* gnu/packages/embedded.scm (make-libstdc++-arm-none-eabi): New procedure.
---
 gnu/packages/embedded.scm | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
index 632682d63..2befdf31b 100644
--- a/gnu/packages/embedded.scm
+++ b/gnu/packages/embedded.scm
@@ -197,6 +197,30 @@ usable on embedded products.")
            "--disable-nls"))))
     (synopsis "Newlib variant for small systems with limited memory")))
 
+(define (make-libstdc++-arm-none-eabi xgcc newlib)
+  (let ((libstdc++ (make-libstdc++ xgcc)))
+    (package (inherit libstdc++)
+      (name "libstdc++-arm-none-eabi")
+      (arguments
+       (substitute-keyword-arguments (package-arguments libstdc++)
+         ((#:configure-flags flags)
+          ``("--target=arm-none-eabi"
+             "--host=arm-none-eabi"
+             "--disable-libstdcxx-pch"
+             "--enable-multilib"
+             "--with-multilib-list=armv6-m,armv7-m,armv7e-m"
+             "--disable-shared"
+             "--disable-tls"
+             "--disable-plugin"
+             "--with-newlib"
+             ,(string-append "--with-gxx-include-dir="
+                             (assoc-ref %outputs "out")
+                             "/arm-none-eabi/include")))))
+      (native-inputs
+       `(("newlib" ,newlib)
+         ("xgcc" ,xgcc)
+         ,@(package-native-inputs libstdc++))))))
+
 (define (arm-none-eabi-toolchain xgcc newlib)
   "Produce a cross-compiler toolchain package with the compiler XGCC and the C
 library variant NEWLIB."
-- 
2.12.2






Information forwarded to guix-patches <at> gnu.org:
bug#27018; Package guix-patches. (Mon, 22 May 2017 14:14:02 GMT) Full text and rfc822 format available.

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

From: Ricardo Wurmus <rekado <at> elephly.net>
To: 27018 <at> debbugs.gnu.org
Cc: Ricardo Wurmus <rekado <at> elephly.net>
Subject: [PATCH 2/5] gnu: avr-gcc-4.9: Use gcc-4.9 as base compiler.
Date: Mon, 22 May 2017 16:13:16 +0200
* gnu/packages/avr.scm (avr-gcc-4.9): Pass gcc-4.9 to "cross-gcc".
---
 gnu/packages/avr.scm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/avr.scm b/gnu/packages/avr.scm
index fc4eb8db0..916f7983f 100644
--- a/gnu/packages/avr.scm
+++ b/gnu/packages/avr.scm
@@ -1,6 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2014, 2016 Manolis Fragkiskos Ragkousis <manolis837 <at> gmail.com>
-;;; Copyright © 2015 Ricardo Wurmus <rekado <at> elephly.net>
+;;; Copyright © 2015, 2017 Ricardo Wurmus <rekado <at> elephly.net>
 ;;; Copyright © 2016 David Thompson <davet <at> gnu.org>
 ;;; Copyright © 2016 Efraim Flashner <efraim <at> flashner.co.il>
 ;;;
@@ -39,7 +39,7 @@
     (name "avr-binutils")))
 
 (define-public avr-gcc-4.9
-  (let ((xgcc (cross-gcc "avr" #:xbinutils avr-binutils)))
+  (let ((xgcc (cross-gcc "avr" #:xgcc gcc-4.9 #:xbinutils avr-binutils)))
     (package
       (inherit xgcc)
       (name "avr-gcc")
-- 
2.12.2






Information forwarded to guix-patches <at> gnu.org:
bug#27018; Package guix-patches. (Mon, 22 May 2017 14:14:03 GMT) Full text and rfc822 format available.

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

From: Ricardo Wurmus <rekado <at> elephly.net>
To: 27018 <at> debbugs.gnu.org
Cc: Ricardo Wurmus <rekado <at> elephly.net>
Subject: [PATCH 5/5] gnu: arm-none-eabi-toolchain: Include libstdc++.
Date: Mon, 22 May 2017 16:13:19 +0200
* gnu/packages/embedded.scm (arm-none-eabi-toolchain)[propagated-inputs]: Add
libstdc++.
---
 gnu/packages/embedded.scm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
index f8684f46a..70541540e 100644
--- a/gnu/packages/embedded.scm
+++ b/gnu/packages/embedded.scm
@@ -249,6 +249,7 @@ library variant NEWLIB."
                            directories))))))
       (propagated-inputs
        `(("binutils" ,(cross-binutils "arm-none-eabi"))
+         ("libstdc++" ,(make-libstdc++-arm-none-eabi xgcc newlib-with-xgcc))
          ("gcc" ,xgcc)
          ("newlib" ,newlib-with-xgcc)))
       (synopsis "Complete GCC tool chain for ARM bare metal development")
-- 
2.12.2






Information forwarded to guix-patches <at> gnu.org:
bug#27018; Package guix-patches. (Mon, 22 May 2017 14:14:03 GMT) Full text and rfc822 format available.

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

From: Ricardo Wurmus <rekado <at> elephly.net>
To: 27018 <at> debbugs.gnu.org
Cc: Ricardo Wurmus <rekado <at> elephly.net>
Subject: [PATCH 4/5] gnu: arm-none-eabi-toolchain: Provide union of all inputs
 at the output.
Date: Mon, 22 May 2017 16:13:18 +0200
* gnu/packages/embedded.scm (arm-none-eabi-toolchain)[arguments]: Make the
union of all inputs available at the output.
---
 gnu/packages/embedded.scm | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
index 2befdf31b..f8684f46a 100644
--- a/gnu/packages/embedded.scm
+++ b/gnu/packages/embedded.scm
@@ -237,7 +237,16 @@ library variant NEWLIB."
       (version (package-version xgcc))
       (source #f)
       (build-system trivial-build-system)
-      (arguments '(#:builder (mkdir %output)))
+      (arguments
+       '(#:modules ((guix build union))
+         #:builder
+         (begin
+           (use-modules (ice-9 match)
+                        (guix build union))
+           (match %build-inputs
+             (((names . directories) ...)
+              (union-build (assoc-ref %outputs "out")
+                           directories))))))
       (propagated-inputs
        `(("binutils" ,(cross-binutils "arm-none-eabi"))
          ("gcc" ,xgcc)
-- 
2.12.2






Information forwarded to guix-patches <at> gnu.org:
bug#27018; Package guix-patches. (Wed, 24 May 2017 17:20:02 GMT) Full text and rfc822 format available.

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

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: Ricardo Wurmus <rekado <at> elephly.net>
Cc: 27018 <at> debbugs.gnu.org
Subject: Re: bug#27018: [PATCH 1/5] gnu: Allow overriding of xgcc package in
 cross-gcc.
Date: Wed, 24 May 2017 19:19:43 +0200
Hi Ricardo,

On Mon, 22 May 2017 16:13:15 +0200
Ricardo Wurmus <rekado <at> elephly.net> wrote:

>  (define* (cross-gcc target
> -                    #:optional (xbinutils (cross-binutils target)) libc)
> +                    #:key
> +                    (xgcc %xgcc)
> +                    (xbinutils (cross-binutils target))
> +                    (libc #f))

Why is it "xgcc", "xbinutils", but "libc" (no "x")? Aren't they all the "cross" versions?

Otherwise LGTM!




Reply sent to Ricardo Wurmus <rekado <at> elephly.net>:
You have taken responsibility. (Wed, 24 May 2017 21:30:03 GMT) Full text and rfc822 format available.

Notification sent to Ricardo Wurmus <rekado <at> elephly.net>:
bug acknowledged by developer. (Wed, 24 May 2017 21:30:03 GMT) Full text and rfc822 format available.

Message #28 received at 27018-done <at> debbugs.gnu.org (full text, mbox):

From: Ricardo Wurmus <rekado <at> elephly.net>
To: Danny Milosavljevic <dannym <at> scratchpost.org>
Cc: 27018-done <at> debbugs.gnu.org
Subject: Re: bug#27018: [PATCH 1/5] gnu: Allow overriding of xgcc package in
 cross-gcc.
Date: Wed, 24 May 2017 23:29:02 +0200
Danny Milosavljevic <dannym <at> scratchpost.org> writes:

> Hi Ricardo,
>
> On Mon, 22 May 2017 16:13:15 +0200
> Ricardo Wurmus <rekado <at> elephly.net> wrote:
>
>>  (define* (cross-gcc target
>> -                    #:optional (xbinutils (cross-binutils target)) libc)
>> +                    #:key
>> +                    (xgcc %xgcc)
>> +                    (xbinutils (cross-binutils target))
>> +                    (libc #f))
>
> Why is it "xgcc", "xbinutils", but "libc" (no "x")? Aren't they all the "cross" versions?

I don’t really know, but I assumed that it is because the libc is not a
set of cross-build tools but a library.

Anyway, thanks for the review.  I’m going to push this now.

--
Ricardo

GPG: BCA6 89B6 3655 3801 C3C6  2150 197A 5888 235F ACAC
https://elephly.net





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 22 Jun 2017 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 8 years and 56 days ago.

Previous Next


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