unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* bug#27018: [PATCH 0/5] Cross-compiler fixes
@ 2017-05-22 13:55 Ricardo Wurmus
  2017-05-22 14:13 ` bug#27018: [PATCH 1/5] gnu: Allow overriding of xgcc package in cross-gcc Ricardo Wurmus
  0 siblings, 1 reply; 8+ messages in thread
From: Ricardo Wurmus @ 2017-05-22 13:55 UTC (permalink / raw)
  To: 27018; +Cc: Ricardo Wurmus

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#27018: [PATCH 1/5] gnu: Allow overriding of xgcc package in cross-gcc.
  2017-05-22 13:55 bug#27018: [PATCH 0/5] Cross-compiler fixes Ricardo Wurmus
@ 2017-05-22 14:13 ` Ricardo Wurmus
  2017-05-22 14:13   ` bug#27018: [PATCH 2/5] gnu: avr-gcc-4.9: Use gcc-4.9 as base compiler Ricardo Wurmus
                     ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Ricardo Wurmus @ 2017-05-22 14:13 UTC (permalink / raw)
  To: 27018; +Cc: Ricardo Wurmus

* 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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#27018: [PATCH 2/5] gnu: avr-gcc-4.9: Use gcc-4.9 as base compiler.
  2017-05-22 14:13 ` bug#27018: [PATCH 1/5] gnu: Allow overriding of xgcc package in cross-gcc Ricardo Wurmus
@ 2017-05-22 14:13   ` Ricardo Wurmus
  2017-05-22 14:13   ` bug#27018: [PATCH 3/5] gnu: Add libstdc++-arm-none-eabi Ricardo Wurmus
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Ricardo Wurmus @ 2017-05-22 14:13 UTC (permalink / raw)
  To: 27018; +Cc: Ricardo Wurmus

* 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@gmail.com>
-;;; Copyright © 2015 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2015, 2017 Ricardo Wurmus <rekado@elephly.net>
 ;;; Copyright © 2016 David Thompson <davet@gnu.org>
 ;;; Copyright © 2016 Efraim Flashner <efraim@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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#27018: [PATCH 3/5] gnu: Add libstdc++-arm-none-eabi.
  2017-05-22 14:13 ` bug#27018: [PATCH 1/5] gnu: Allow overriding of xgcc package in cross-gcc Ricardo Wurmus
  2017-05-22 14:13   ` bug#27018: [PATCH 2/5] gnu: avr-gcc-4.9: Use gcc-4.9 as base compiler Ricardo Wurmus
@ 2017-05-22 14:13   ` Ricardo Wurmus
  2017-05-22 14:13   ` bug#27018: [PATCH 4/5] gnu: arm-none-eabi-toolchain: Provide union of all inputs at the output Ricardo Wurmus
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Ricardo Wurmus @ 2017-05-22 14:13 UTC (permalink / raw)
  To: 27018; +Cc: Ricardo Wurmus

* 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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#27018: [PATCH 4/5] gnu: arm-none-eabi-toolchain: Provide union of all inputs at the output.
  2017-05-22 14:13 ` bug#27018: [PATCH 1/5] gnu: Allow overriding of xgcc package in cross-gcc Ricardo Wurmus
  2017-05-22 14:13   ` bug#27018: [PATCH 2/5] gnu: avr-gcc-4.9: Use gcc-4.9 as base compiler Ricardo Wurmus
  2017-05-22 14:13   ` bug#27018: [PATCH 3/5] gnu: Add libstdc++-arm-none-eabi Ricardo Wurmus
@ 2017-05-22 14:13   ` Ricardo Wurmus
  2017-05-22 14:13   ` bug#27018: [PATCH 5/5] gnu: arm-none-eabi-toolchain: Include libstdc++ Ricardo Wurmus
  2017-05-24 17:19   ` bug#27018: [PATCH 1/5] gnu: Allow overriding of xgcc package in cross-gcc Danny Milosavljevic
  4 siblings, 0 replies; 8+ messages in thread
From: Ricardo Wurmus @ 2017-05-22 14:13 UTC (permalink / raw)
  To: 27018; +Cc: Ricardo Wurmus

* 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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#27018: [PATCH 5/5] gnu: arm-none-eabi-toolchain: Include libstdc++.
  2017-05-22 14:13 ` bug#27018: [PATCH 1/5] gnu: Allow overriding of xgcc package in cross-gcc Ricardo Wurmus
                     ` (2 preceding siblings ...)
  2017-05-22 14:13   ` bug#27018: [PATCH 4/5] gnu: arm-none-eabi-toolchain: Provide union of all inputs at the output Ricardo Wurmus
@ 2017-05-22 14:13   ` Ricardo Wurmus
  2017-05-24 17:19   ` bug#27018: [PATCH 1/5] gnu: Allow overriding of xgcc package in cross-gcc Danny Milosavljevic
  4 siblings, 0 replies; 8+ messages in thread
From: Ricardo Wurmus @ 2017-05-22 14:13 UTC (permalink / raw)
  To: 27018; +Cc: Ricardo Wurmus

* 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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#27018: [PATCH 1/5] gnu: Allow overriding of xgcc package in cross-gcc.
  2017-05-22 14:13 ` bug#27018: [PATCH 1/5] gnu: Allow overriding of xgcc package in cross-gcc Ricardo Wurmus
                     ` (3 preceding siblings ...)
  2017-05-22 14:13   ` bug#27018: [PATCH 5/5] gnu: arm-none-eabi-toolchain: Include libstdc++ Ricardo Wurmus
@ 2017-05-24 17:19   ` Danny Milosavljevic
  2017-05-24 21:29     ` Ricardo Wurmus
  4 siblings, 1 reply; 8+ messages in thread
From: Danny Milosavljevic @ 2017-05-24 17:19 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: 27018

Hi Ricardo,

On Mon, 22 May 2017 16:13:15 +0200
Ricardo Wurmus <rekado@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!

^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#27018: [PATCH 1/5] gnu: Allow overriding of xgcc package in cross-gcc.
  2017-05-24 17:19   ` bug#27018: [PATCH 1/5] gnu: Allow overriding of xgcc package in cross-gcc Danny Milosavljevic
@ 2017-05-24 21:29     ` Ricardo Wurmus
  0 siblings, 0 replies; 8+ messages in thread
From: Ricardo Wurmus @ 2017-05-24 21:29 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 27018-done


Danny Milosavljevic <dannym@scratchpost.org> writes:

> Hi Ricardo,
>
> On Mon, 22 May 2017 16:13:15 +0200
> Ricardo Wurmus <rekado@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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-05-24 21:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-22 13:55 bug#27018: [PATCH 0/5] Cross-compiler fixes Ricardo Wurmus
2017-05-22 14:13 ` bug#27018: [PATCH 1/5] gnu: Allow overriding of xgcc package in cross-gcc Ricardo Wurmus
2017-05-22 14:13   ` bug#27018: [PATCH 2/5] gnu: avr-gcc-4.9: Use gcc-4.9 as base compiler Ricardo Wurmus
2017-05-22 14:13   ` bug#27018: [PATCH 3/5] gnu: Add libstdc++-arm-none-eabi Ricardo Wurmus
2017-05-22 14:13   ` bug#27018: [PATCH 4/5] gnu: arm-none-eabi-toolchain: Provide union of all inputs at the output Ricardo Wurmus
2017-05-22 14:13   ` bug#27018: [PATCH 5/5] gnu: arm-none-eabi-toolchain: Include libstdc++ Ricardo Wurmus
2017-05-24 17:19   ` bug#27018: [PATCH 1/5] gnu: Allow overriding of xgcc package in cross-gcc Danny Milosavljevic
2017-05-24 21:29     ` Ricardo Wurmus

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).