all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH 0/3] Add GCC cross compiler for arm-none-eabi.
@ 2016-09-18  6:35 Ricardo Wurmus
  2016-09-18  6:35 ` [PATCH 1/3] gnu: Add arm-none-eabi cross compiler Ricardo Wurmus
                   ` (5 more replies)
  0 siblings, 6 replies; 29+ messages in thread
From: Ricardo Wurmus @ 2016-09-18  6:35 UTC (permalink / raw)
  To: guix-devel

Hi Guix,

here's a patch series I've been sitting on for about a year.  It's a compiler
for bare-metal binaries targetting arm-none-eabi.  I'm using this successfully
to compile ChibiOS for the Axoloti Core board.

I've chosen to package the particular compiler version that is used for the
Axoloti Core, so this is equivalent to what the GNU ARM Embedded Toolchain
project provides with the "4.9-2015-q2-update" release (see
https://launchpadlibrarian.net/209776344/release.txt).  I used SVN revisions
because certain ARM patches are not part of the standard release tarball; they
are only in SVN.

I did update newlib to the very latest release, however, because it seems to
work just fine.

I don't know if it's okay to keep older versions of the cross compiler.  For
version 4.9 the GNU ARM Embedded Toolchain project made another release
"4.9-2015-q3-update".  It's probably better to at least use the upstream
versions they used for that release instead of basing things on
"4.9-2015-q2-update".

I have no idea if we can build our own version of 4.9 from a later revision,
because I don't know exactly what patches I'd need to backport.  If somebody
knows better I'd appreciate hints.

~~ Ricardo


Ricardo Wurmus (3):
  gnu: Add arm-none-eabi cross compiler.
  gnu: Add newlib-arm-none-eabi.
  gnu: Add newlib-nano-arm-none-eabi.

 gnu/local.mk               |   1 +
 gnu/packages/bootstrap.scm |   1 +
 gnu/packages/embedded.scm  | 185 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 187 insertions(+)
 create mode 100644 gnu/packages/embedded.scm

-- 
2.10.0

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

* [PATCH 1/3] gnu: Add arm-none-eabi cross compiler.
  2016-09-18  6:35 [PATCH 0/3] Add GCC cross compiler for arm-none-eabi Ricardo Wurmus
@ 2016-09-18  6:35 ` Ricardo Wurmus
  2016-09-21  8:34   ` Ludovic Courtès
  2016-09-18  6:35 ` [PATCH 2/3] gnu: Add newlib-arm-none-eabi Ricardo Wurmus
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 29+ messages in thread
From: Ricardo Wurmus @ 2016-09-18  6:35 UTC (permalink / raw)
  To: guix-devel

* gnu/packages/bootstrap.scm (glibc-dynamic-linker): Add case for "arm-eabi".
* gnu/packages/embedded.scm: New file.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
---
 gnu/local.mk               |   1 +
 gnu/packages/bootstrap.scm |   1 +
 gnu/packages/embedded.scm  | 121 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 123 insertions(+)
 create mode 100644 gnu/packages/embedded.scm

diff --git a/gnu/local.mk b/gnu/local.mk
index e2cf40d..ce5faca 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -110,6 +110,7 @@ GNU_SYSTEM_MODULES =				\
   %D%/packages/education.scm			\
   %D%/packages/elf.scm				\
   %D%/packages/elixir.scm			\
+  %D%/packages/embedded.scm			\
   %D%/packages/emacs.scm			\
   %D%/packages/enchant.scm			\
   %D%/packages/engineering.scm			\
diff --git a/gnu/packages/bootstrap.scm b/gnu/packages/bootstrap.scm
index f47a343..f6faba3 100644
--- a/gnu/packages/bootstrap.scm
+++ b/gnu/packages/bootstrap.scm
@@ -171,6 +171,7 @@ successful, or false to signal an error."
 
         ;; XXX: This one is used bare-bones, without a libc, so add a case
         ;; here just so we can keep going.
+        ((string=? system "arm-eabi") "no-ld.so")
         ((string=? system "xtensa-elf") "no-ld.so")
         ((string=? system "avr") "no-ld.so")
         ((string=? system "i686-mingw") "no-ld.so")
diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
new file mode 100644
index 0000000..17ca784
--- /dev/null
+++ b/gnu/packages/embedded.scm
@@ -0,0 +1,121 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages embedded)
+  #:use-module (guix utils)
+  #:use-module (guix packages)
+  #:use-module (guix download)
+  #:use-module (guix svn-download)
+  #:use-module (guix git-download)
+  #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix build-system gnu)
+  #:use-module (gnu packages)
+  #:use-module (gnu packages bison)
+  #:use-module (gnu packages cross-base)
+  #:use-module (gnu packages flex)
+  #:use-module (gnu packages perl)
+  #:use-module (gnu packages texinfo))
+
+;; Commit hashes and SVN revisions for xbinutils and xgcc are taken
+;; from https://launchpadlibrarian.net/209776344/release.txt
+
+(define-public xbinutils-arm-none-eabi
+  (let ((parent (cross-binutils "arm-none-eabi"))
+        (commit "136a940ac535e464d2a7a86880ce1f1a5554c484")
+        (revision "1"))
+    (package (inherit parent)
+      (version (string-append (package-version parent) "-"
+                              revision "." (string-take commit 9)))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "git://sourceware.org/git/binutils-gdb.git")
+                      (commit commit)))
+                (file-name (string-append "xbinutils-arm-none-eabi-"
+                                          version "-checkout"))
+                (patches (origin-patches (package-source parent)))
+                (sha256
+                 (base32
+                  "185sfmhbplidvj8n3h1clqqf6c0wqcigzm3phn9sqfy9arsv3mg8"))))
+      (native-inputs
+       `(("texinfo" ,texinfo)
+         ("perl" ,perl)
+         ("bison" ,bison)
+         ("flex" ,flex)
+         ,@(package-native-inputs parent)))
+      (arguments
+       `(,@(substitute-keyword-arguments (package-arguments parent)
+             ((#:configure-flags flags)
+              `(cons "--enable-multilib"
+                     (delete "--disable-multilib" ,flags)))))))))
+
+;; We must not use the released GCC sources here, because the cross-compiler
+;; does not produce working binaries.  Instead we take the very same SVN
+;; revision from the branch that is used for a release of the "GCC ARM
+;; embedded" project on launchpad.
+(define-public gcc-arm-none-eabi
+  (let ((xgcc (cross-gcc "arm-none-eabi"
+                         xbinutils-arm-none-eabi))
+        (revision "1")
+        (svn-revision 224288))
+    (package (inherit xgcc)
+      (version (string-append (package-version xgcc) "-"
+                              revision "." (number->string svn-revision)))
+      (source
+       (origin
+         (method svn-fetch)
+         (uri (svn-reference
+               (url "svn://gcc.gnu.org/svn/gcc/branches/ARM/embedded-4_9-branch/")
+               (revision svn-revision)))
+         (file-name (string-append "gcc-arm-embedded-" version "-checkout"))
+         (sha256
+          (base32
+           "113r98kygy8rrjfv2pd3z6zlfzbj543pq7xyq8bgh72c608mmsbr"))
+         (patches (origin-patches (package-source xgcc)))))
+      (native-inputs
+       `(("flex" ,flex)
+         ,@(package-native-inputs xgcc)))
+      (arguments
+       `(,@(substitute-keyword-arguments (package-arguments xgcc)
+             ((#:phases phases)
+              `(modify-phases ,phases
+                 (add-after 'unpack 'fix-genmultilib
+                   (lambda _
+                     (substitute* "gcc/genmultilib"
+                       (("#!/bin/sh") (string-append "#!" (which "sh"))))
+                     #t))))
+             ((#:configure-flags flags)
+              `(append (list "--enable-multilib"
+                             "--with-newlib"
+                             "--with-multilib-list=armv6-m,armv7-m,armv7e-m"
+                             "--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm"
+                             "--enable-plugins"
+                             "--disable-decimal-float"
+                             "--disable-libffi"
+                             "--disable-libgomp"
+                             "--disable-libmudflap"
+                             "--disable-libquadmath"
+                             "--disable-libssp"
+                             "--disable-libstdcxx-pch"
+                             "--disable-nls"
+                             "--disable-shared"
+                             "--disable-threads"
+                             "--disable-tls"
+                             "--with-gnu-as"
+                             "--with-gnu-ld")
+                       (delete "--disable-multilib" ,flags)))))))))
-- 
2.10.0

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

* [PATCH 2/3] gnu: Add newlib-arm-none-eabi.
  2016-09-18  6:35 [PATCH 0/3] Add GCC cross compiler for arm-none-eabi Ricardo Wurmus
  2016-09-18  6:35 ` [PATCH 1/3] gnu: Add arm-none-eabi cross compiler Ricardo Wurmus
@ 2016-09-18  6:35 ` Ricardo Wurmus
  2016-09-21  8:38   ` Ludovic Courtès
  2016-09-18  6:35 ` [PATCH 3/3] gnu: Add newlib-nano-arm-none-eabi Ricardo Wurmus
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 29+ messages in thread
From: Ricardo Wurmus @ 2016-09-18  6:35 UTC (permalink / raw)
  To: guix-devel

* gnu/packages/embedded.scm (newlib-arm-none-eabi): New variable.
---
 gnu/packages/embedded.scm | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
index 17ca784..8f484e5 100644
--- a/gnu/packages/embedded.scm
+++ b/gnu/packages/embedded.scm
@@ -119,3 +119,47 @@
                              "--with-gnu-as"
                              "--with-gnu-ld")
                        (delete "--disable-multilib" ,flags)))))))))
+
+(define-public newlib-arm-none-eabi
+  (package
+    (name "newlib")
+    (version "2.4.0")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "ftp://sourceware.org/pub/newlib/newlib-"
+                                  version ".tar.gz"))
+              (sha256
+               (base32
+                "01i7qllwicf05vsvh39qj7qp5fdifpvvky0x95hjq39mbqiksnsl"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:out-of-source? #t
+       #:configure-flags '("--target=arm-none-eabi"
+                           "--enable-newlib-io-long-long"
+                           "--enable-newlib-register-fini"
+                           "--disable-newlib-supplied-syscalls"
+                           "--disable-nls")
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'fix-shell-shebangs
+           (lambda _
+             (setenv "SHELL" (which "sh"))
+             (setenv "CONFIG_SHELL" (which "sh"))
+             (substitute* '("libgloss/arm/configure"
+                            "libgloss/arm/cpu-init/Makefile.in"
+                            "libgloss/arm/Makefile.in"
+                            "libgloss/libnosys/Makefile.in"
+                            "libgloss/Makefile.in")
+               (("/bin/sh") (which "sh")))
+             #t)))))
+    (native-inputs
+     `(("xbinutils" ,xbinutils-arm-none-eabi)
+       ("xgcc" ,gcc-arm-none-eabi)
+       ("texinfo" ,texinfo)))
+    (home-page "http://www.sourceware.org/newlib/")
+    (synopsis "C library for use on embedded systems")
+    (description "Newlib is a C library intended for use on embedded
+systems.  It is a conglomeration of several library parts that are easily
+usable on embedded products.")
+    (license (license:non-copyleft
+              "https://www.sourceware.org/newlib/COPYING.NEWLIB"))))
-- 
2.10.0

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

* [PATCH 3/3] gnu: Add newlib-nano-arm-none-eabi.
  2016-09-18  6:35 [PATCH 0/3] Add GCC cross compiler for arm-none-eabi Ricardo Wurmus
  2016-09-18  6:35 ` [PATCH 1/3] gnu: Add arm-none-eabi cross compiler Ricardo Wurmus
  2016-09-18  6:35 ` [PATCH 2/3] gnu: Add newlib-arm-none-eabi Ricardo Wurmus
@ 2016-09-18  6:35 ` Ricardo Wurmus
  2016-09-21  8:40   ` Ludovic Courtès
  2016-09-19 20:23 ` [PATCH v2 0/4] Add GCC cross compiler for arm-none-eabi Theodoros Foradis
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 29+ messages in thread
From: Ricardo Wurmus @ 2016-09-18  6:35 UTC (permalink / raw)
  To: guix-devel

* gnu/packages/embedded.scm (newlib-nano-arm-none-eabi): New variable.
---
 gnu/packages/embedded.scm | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
index 8f484e5..43f6068 100644
--- a/gnu/packages/embedded.scm
+++ b/gnu/packages/embedded.scm
@@ -163,3 +163,23 @@ systems.  It is a conglomeration of several library parts that are easily
 usable on embedded products.")
     (license (license:non-copyleft
               "https://www.sourceware.org/newlib/COPYING.NEWLIB"))))
+
+(define-public newlib-nano-arm-none-eabi
+  (package (inherit newlib-arm-none-eabi)
+    (name "newlib-nano")
+    (arguments
+     (substitute-keyword-arguments (package-arguments newlib-arm-none-eabi)
+       ((#:configure-flags flags)
+        ``("--target=arm-none-eabi"
+           "--enable-multilib"
+           "--disable-newlib-supplied-syscalls"
+           "--enable-newlib-reent-small"
+           "--disable-newlib-fvwrite-in-streamio"
+           "--disable-newlib-fseek-optimization"
+           "--disable-newlib-wide-orient"
+           "--enable-newlib-nano-malloc"
+           "--disable-newlib-unbuf-stream-opt"
+           "--enable-lite-exit"
+           "--enable-newlib-global-atexit"
+           "--enable-newlib-nano-formatted-io"
+           "--disable-nls"))))))
-- 
2.10.0

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

* [PATCH v2 0/4] Add GCC cross compiler for arm-none-eabi.
  2016-09-18  6:35 [PATCH 0/3] Add GCC cross compiler for arm-none-eabi Ricardo Wurmus
                   ` (2 preceding siblings ...)
  2016-09-18  6:35 ` [PATCH 3/3] gnu: Add newlib-nano-arm-none-eabi Ricardo Wurmus
@ 2016-09-19 20:23 ` Theodoros Foradis
  2016-09-19 20:23   ` [PATCH v2 1/4] gnu: Add arm-none-eabi cross compiler Theodoros Foradis
                     ` (4 more replies)
  2016-09-20 10:50 ` [PATCH v2 0/1] " Theodoros Foradis
  2016-09-21  8:30 ` [PATCH 0/3] Add GCC cross compiler for arm-none-eabi Ludovic Courtès
  5 siblings, 5 replies; 29+ messages in thread
From: Theodoros Foradis @ 2016-09-19 20:23 UTC (permalink / raw)
  To: rekado; +Cc: guix-devel


Hello Guix and Ricardo,

The original patch series was working correctly and producing working binaries. Some
flags (that I had been using with 6.2.0) are missing from that version of GCC 4.9,
so I added 6.2.0 as an extra option. I have tested it to produce working binaries.

Here are some modifications to Ricardo's patches for the arm-none-eabi
bare metal cross compiler. The following changes have been made:

- I have modified xbinutils to use binutils 2.25.1 from cross-base, as it compiles
correctly with it. The version from the svn commit that was used by Ricardo is compiling
correct binaries as well. Thus, if it is deemed appropriate, the source for xbinutils can
be swapped for the previous one, with (seemingly) no difference.

- The xgcc of the original, was failing to find the headers that newlib provided.
I have set the native-cross-paths as a workaround. Not sure if there is a better
alternative, or if the failure was my mistake.

- A package for cross GCC 6.2.0 is added, with appropriate patches for multilib
support.

- Newlib-arm-none-eabi and newlib-nano-arm-none-eabi have been changed to
procedures, taking an xgcc as argument, so as to facilitate building with
either version of gcc.

- An arm-none-eabi-toolchain procedure is declared, to create toolchain packages
for both gcc and newlib version. The four toolchain variables follow. Not sure
if it's a mistake to include "nano" in the toolchain version.


This is the first patch that I send in guix-devel, so please bear with me.

Regards,
Theodoros Foradis


* gnu: Add arm-none-eabi-toolchain.
* gnu: Add newlib-arm-none-eabi.
* gnu: Add arm-none-eabi-gcc-6 and patches.
* gnu: Add arm-none-eabi cross compiler.

 gnu/local.mk                                                 |   1 +
 gnu/packages/bootstrap.scm                                   |   1 +
 gnu/packages/embedded.scm                                    | 226 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gnu/packages/patches/gcc-6-arm-none-eabi-multilib.patch      | 201 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gnu/packages/patches/gcc-6-cross-environment-variables.patch |  65 +++++++++++++++++++
 5 files changed, 494 insertions(+)
 create mode 100644 gnu/packages/embedded.scm
 create mode 100644 gnu/packages/patches/gcc-6-arm-none-eabi-multilib.patch
 create mode 100644 gnu/packages/patches/gcc-6-cross-environment-variables.patch

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

* [PATCH v2 1/4] gnu: Add arm-none-eabi cross compiler.
  2016-09-19 20:23 ` [PATCH v2 0/4] Add GCC cross compiler for arm-none-eabi Theodoros Foradis
@ 2016-09-19 20:23   ` Theodoros Foradis
  2016-09-19 20:23   ` [PATCH v2 2/4] gnu: Add arm-none-eabi-gcc-6 and patches Theodoros Foradis
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 29+ messages in thread
From: Theodoros Foradis @ 2016-09-19 20:23 UTC (permalink / raw)
  To: rekado; +Cc: guix-devel

* gnu/packages/bootstrap.scm (glibc-dynamic-linker): Add case for "arm-eabi".
* gnu/packages/embedded.scm: New file.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
---
 gnu/local.mk               |   1 +
 gnu/packages/bootstrap.scm |   1 +
 gnu/packages/embedded.scm  | 119 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 121 insertions(+)
 create mode 100644 gnu/packages/embedded.scm

diff --git a/gnu/local.mk b/gnu/local.mk
index 4076121..caecfa2 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -110,6 +110,7 @@ GNU_SYSTEM_MODULES =				\
   %D%/packages/education.scm			\
   %D%/packages/elf.scm				\
   %D%/packages/elixir.scm			\
+  %D%/packages/embedded.scm			\
   %D%/packages/emacs.scm			\
   %D%/packages/enchant.scm			\
   %D%/packages/engineering.scm			\
diff --git a/gnu/packages/bootstrap.scm b/gnu/packages/bootstrap.scm
index f47a343..f6faba3 100644
--- a/gnu/packages/bootstrap.scm
+++ b/gnu/packages/bootstrap.scm
@@ -171,6 +171,7 @@ successful, or false to signal an error."
 
         ;; XXX: This one is used bare-bones, without a libc, so add a case
         ;; here just so we can keep going.
+        ((string=? system "arm-eabi") "no-ld.so")
         ((string=? system "xtensa-elf") "no-ld.so")
         ((string=? system "avr") "no-ld.so")
         ((string=? system "i686-mingw") "no-ld.so")
diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
new file mode 100644
index 0000000..8650817
--- /dev/null
+++ b/gnu/packages/embedded.scm
@@ -0,0 +1,119 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2016 Theodoros Foradis <theodoros.for@openmailbox.org>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages embedded)
+  #:use-module (guix utils)
+  #:use-module (guix packages)
+  #:use-module (guix download)
+  #:use-module (guix svn-download)
+  #:use-module (guix git-download)
+  #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix build-system gnu)
+  #:use-module (guix build-system trivial)
+  #:use-module (gnu packages)
+  #:use-module (gnu packages bison)
+  #:use-module (gnu packages cross-base)
+  #:use-module (gnu packages flex)
+  #:use-module (gnu packages gcc)
+  #:use-module (gnu packages perl)
+  #:use-module (gnu packages texinfo))
+
+(define-public xbinutils-arm-none-eabi
+  (let ((parent (cross-binutils "arm-none-eabi")))
+    (package
+      (inherit parent)
+      (native-inputs
+       `(("texinfo" ,texinfo)
+         ("perl" ,perl)
+         ("bison" ,bison)
+         ("flex" ,flex)
+         ,@(package-native-inputs parent)))
+      (arguments
+       `(,@(substitute-keyword-arguments (package-arguments parent)
+             ((#:configure-flags flags)
+              `(cons "--enable-multilib"
+                     (delete "--disable-multilib" ,flags)))))))))
+
+;; Commit hashes and SVN revisions for xgcc 4.9 are taken
+;; from https://launchpadlibrarian.net/209776344/release.txt
+;; We must not use the released GCC 4.9 sources here, because the cross-compiler
+;; does not produce working binaries.  Instead we take the very same SVN
+;; revision from the branch that is used for a release of the "GCC ARM
+;; embedded" project on launchpad.
+(define-public gcc-arm-none-eabi-4.9
+  (let ((xgcc (cross-gcc "arm-none-eabi"
+                         xbinutils-arm-none-eabi))
+        (revision "1")
+        (svn-revision 224288))
+    (package (inherit xgcc)
+      (version (string-append (package-version xgcc) "-"
+                              revision "." (number->string svn-revision)))
+      (source
+       (origin
+         (method svn-fetch)
+         (uri (svn-reference
+               (url "svn://gcc.gnu.org/svn/gcc/branches/ARM/embedded-4_9-branch/")
+               (revision svn-revision)))
+         (file-name (string-append "gcc-arm-embedded-" version "-checkout"))
+         (sha256
+          (base32
+           "113r98kygy8rrjfv2pd3z6zlfzbj543pq7xyq8bgh72c608mmsbr"))
+         (patches (origin-patches (package-source xgcc)))))
+      (native-inputs
+       `(("flex" ,flex)
+         ,@(package-native-inputs xgcc)))
+      (arguments
+       `(,@(substitute-keyword-arguments (package-arguments xgcc)
+             ((#:phases phases)
+              `(modify-phases ,phases
+                 (add-after 'unpack 'fix-genmultilib
+                   (lambda _
+                     (substitute* "gcc/genmultilib"
+                       (("#!/bin/sh") (string-append "#!" (which "sh"))))
+                     #t))))
+             ((#:configure-flags flags)
+              `(append (list "--enable-multilib"
+                             "--with-newlib"
+                             "--with-multilib-list=armv6-m,armv7-m,armv7e-m"
+                             "--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm"
+                             "--enable-plugins"
+                             "--disable-decimal-float"
+                             "--disable-libffi"
+                             "--disable-libgomp"
+                             "--disable-libmudflap"
+                             "--disable-libquadmath"
+                             "--disable-libssp"
+                             "--disable-libstdcxx-pch"
+                             "--disable-nls"
+                             "--disable-shared"
+                             "--disable-threads"
+                             "--disable-tls"
+                             "--with-gnu-as"
+                             "--with-gnu-ld")
+                       (delete "--disable-multilib" ,flags))))))
+      (native-search-paths
+       (list (search-path-specification
+              (variable "CROSS_C_INCLUDE_PATH")
+              (files '("arm-none-eabi/include")))
+             (search-path-specification
+              (variable "CROSS_CPLUS_INCLUDE_PATH")
+              (files '("arm-none-eabi/include")))
+             (search-path-specification
+              (variable "CROSS_LIBRARY_PATH")
+              (files '("arm-none-eabi/lib"))))))))
-- 
2.9.3

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

* [PATCH v2 2/4] gnu: Add arm-none-eabi-gcc-6 and patches.
  2016-09-19 20:23 ` [PATCH v2 0/4] Add GCC cross compiler for arm-none-eabi Theodoros Foradis
  2016-09-19 20:23   ` [PATCH v2 1/4] gnu: Add arm-none-eabi cross compiler Theodoros Foradis
@ 2016-09-19 20:23   ` Theodoros Foradis
  2016-10-10 20:22     ` Ricardo Wurmus
  2016-09-19 20:23   ` [PATCH v2 3/4] gnu: Add newlib-arm-none-eabi Theodoros Foradis
                     ` (2 subsequent siblings)
  4 siblings, 1 reply; 29+ messages in thread
From: Theodoros Foradis @ 2016-09-19 20:23 UTC (permalink / raw)
  To: rekado; +Cc: guix-devel

* gnu/packages/embedded.scm (gcc-arm-none-eabi-6): New variable.
* gnu/packages/patches/gcc-arm-none-eabi-multilib.patch : New file.
* gnu/packages/patches/gcc-6-cross-environment-variables.patch : New file.
---
 gnu/packages/embedded.scm                          |  12 ++
 .../patches/gcc-6-arm-none-eabi-multilib.patch     | 201 +++++++++++++++++++++
 .../gcc-6-cross-environment-variables.patch        |  65 +++++++
 3 files changed, 278 insertions(+)
 create mode 100644 gnu/packages/patches/gcc-6-arm-none-eabi-multilib.patch
 create mode 100644 gnu/packages/patches/gcc-6-cross-environment-variables.patch

diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
index 8650817..56fbafb 100644
--- a/gnu/packages/embedded.scm
+++ b/gnu/packages/embedded.scm
@@ -117,3 +117,15 @@
              (search-path-specification
               (variable "CROSS_LIBRARY_PATH")
               (files '("arm-none-eabi/lib"))))))))
+
+(define-public gcc-arm-none-eabi-6
+  (package
+    (inherit gcc-arm-none-eabi-4.9)
+    (version (package-version gcc-6))
+    (source (origin (inherit (package-source gcc-6))
+                    (patches
+                     (append
+                      (origin-patches (package-source gcc-6))
+                      (cons
+                       (search-patch "gcc-6-cross-environment-variables.patch")
+                       (search-patches "gcc-6-arm-none-eabi-multilib.patch"))))))))
diff --git a/gnu/packages/patches/gcc-6-arm-none-eabi-multilib.patch b/gnu/packages/patches/gcc-6-arm-none-eabi-multilib.patch
new file mode 100644
index 0000000..442f52b
--- /dev/null
+++ b/gnu/packages/patches/gcc-6-arm-none-eabi-multilib.patch
@@ -0,0 +1,201 @@
+From Anatol Pomozov <anatol.pomozov@gmail.com>
+Taken from Arch Linux arm-none-eabi-gcc package.
+
+Modified version of ARM patch https://gcc.gnu.org/ml/gcc-patches/2012-05/msg00083/enable-with-multilib-list-for-arm.patch
+
+diff --git a/gcc/Makefile.in b/gcc/Makefile.in
+index 4ab7405..6e1ea2c 100644
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -535,6 +535,7 @@ lang_opt_files=@lang_opt_files@ $(srcdir)/c-family/c.opt $(srcdir)/common.opt
+ lang_specs_files=@lang_specs_files@
+ lang_tree_files=@lang_tree_files@
+ target_cpu_default=@target_cpu_default@
++with_multilib_list=@with_multilib_list@
+ OBJC_BOEHM_GC=@objc_boehm_gc@
+ extra_modes_file=@extra_modes_file@
+ extra_opt_files=@extra_opt_files@
+diff --git a/gcc/config.gcc b/gcc/config.gcc
+index cb08a5c..7bded02 100644
+--- a/gcc/config.gcc
++++ b/gcc/config.gcc
+@@ -1072,7 +1072,7 @@ arm*-*-eabi* | arm*-*-symbianelf* | arm*-*-rtems*)
+ 	case ${target} in
+ 	arm*-*-eabi*)
+ 	  tm_file="$tm_file newlib-stdint.h"
+-	  tmake_file="${tmake_file} arm/t-bpabi"
++	  tmake_file="${tmake_file} arm/t-bpabi arm/t-mlibs"
+ 	  use_gcc_stdint=wrap
+ 	  ;;
+ 	arm*-*-rtems*)
+@@ -3684,42 +3684,6 @@ case "${target}" in
+ 			exit 1
+ 		fi
+ 
+-		# Add extra multilibs
+-		if test "x$with_multilib_list" != x; then
+-			arm_multilibs=`echo $with_multilib_list | sed -e 's/,/ /g'`
+-			for arm_multilib in ${arm_multilibs}; do
+-				case ${arm_multilib} in
+-				aprofile)
+-				# Note that arm/t-aprofile is a
+-				# stand-alone make file fragment to be
+-				# used only with itself.  We do not
+-				# specifically use the
+-				# TM_MULTILIB_OPTION framework because
+-				# this shorthand is more
+-				# pragmatic. Additionally it is only
+-				# designed to work without any
+-				# with-cpu, with-arch with-mode
+-				# with-fpu or with-float options.
+-					if test "x$with_arch" != x \
+-					    || test "x$with_cpu" != x \
+-					    || test "x$with_float" != x \
+-					    || test "x$with_fpu" != x \
+-					    || test "x$with_mode" != x ; then
+-					    echo "Error: You cannot use any of --with-arch/cpu/fpu/float/mode with --with-multilib-list=aprofile" 1>&2
+-					    exit 1
+-					fi
+-					tmake_file="${tmake_file} arm/t-aprofile"
+-					break
+-					;;
+-				default)
+-					;;
+-				*)
+-					echo "Error: --with-multilib-list=${with_multilib_list} not supported." 1>&2
+-					exit 1
+-					;;
+-				esac
+-			done
+-		fi
+ 		;;
+ 
+ 	fr*-*-*linux*)
+diff --git a/gcc/config/arm/t-mlibs b/gcc/config/arm/t-mlibs
+new file mode 100644
+index 0000000..5720cf7
+--- /dev/null
++++ b/gcc/config/arm/t-mlibs
+@@ -0,0 +1,89 @@
++# A set of predefined MULTILIB which can be used for different ARM targets.
++# Via the configure option --with-multilib-list, user can customize the
++# final MULTILIB implementation.
++
++comma := ,
++space :=
++space +=
++
++MULTILIB_OPTIONS   = mthumb/marm
++MULTILIB_DIRNAMES  = thumb arm
++MULTILIB_OPTIONS  += march=armv6s-m/march=armv7-m/march=armv7e-m/march=armv7
++MULTILIB_DIRNAMES += armv6-m armv7-m armv7e-m armv7-ar
++MULTILIB_OPTIONS  += mfloat-abi=softfp/mfloat-abi=hard
++MULTILIB_DIRNAMES += softfp fpu
++MULTILIB_OPTIONS  += mfpu=fpv4-sp-d16/mfpu=vfpv3-d16
++MULTILIB_DIRNAMES += fpv4-sp-d16 vfpv3-d16
++
++MULTILIB_MATCHES   = march?armv6s-m=mcpu?cortex-m0
++MULTILIB_MATCHES  += march?armv6s-m=mcpu?cortex-m0plus
++MULTILIB_MATCHES  += march?armv6s-m=mcpu?cortex-m1
++MULTILIB_MATCHES  += march?armv6s-m=march?armv6-m
++MULTILIB_MATCHES  += march?armv7-m=mcpu?cortex-m3
++MULTILIB_MATCHES  += march?armv7e-m=mcpu?cortex-m4
++MULTILIB_MATCHES  += march?armv7e-m=mcpu?cortex-m7
++MULTILIB_MATCHES  += march?armv7=march?armv7-r
++MULTILIB_MATCHES  += march?armv7=march?armv7-a
++MULTILIB_MATCHES  += march?armv7=mcpu?cortex-r4
++MULTILIB_MATCHES  += march?armv7=mcpu?cortex-r4f
++MULTILIB_MATCHES  += march?armv7=mcpu?cortex-r5
++MULTILIB_MATCHES  += march?armv7=mcpu?cortex-r7
++MULTILIB_MATCHES  += march?armv7=mcpu?cortex-a5
++MULTILIB_MATCHES  += march?armv7=mcpu?cortex-a7
++MULTILIB_MATCHES  += march?armv7=mcpu?cortex-a8
++MULTILIB_MATCHES  += march?armv7=mcpu?cortex-a9
++MULTILIB_MATCHES  += march?armv7=mcpu?cortex-a15
++MULTILIB_MATCHES  += mfpu?fpv4-sp-d16=mfpu?fpv5-sp-d16
++MULTILIB_MATCHES  += mfpu?fpv4-sp-d16=mfpu?fpv5-d16
++MULTILIB_MATCHES  += mfpu?vfpv3-d16=mfpu?vfpv3
++MULTILIB_MATCHES  += mfpu?vfpv3-d16=mfpu?vfpv3-fp16
++MULTILIB_MATCHES  += mfpu?vfpv3-d16=mfpu?vfpv3-d16-fp16
++MULTILIB_MATCHES  += mfpu?vfpv3-d16=mfpu?vfpv3xd
++MULTILIB_MATCHES  += mfpu?vfpv3-d16=mfpu?vfpv3xd-fp16
++MULTILIB_MATCHES  += mfpu?vfpv3-d16=mfpu?vfpv4
++MULTILIB_MATCHES  += mfpu?vfpv3-d16=mfpu?vfpv4-d16
++MULTILIB_MATCHES  += mfpu?vfpv3-d16=mfpu?neon
++MULTILIB_MATCHES  += mfpu?vfpv3-d16=mfpu?neon-fp16
++MULTILIB_MATCHES  += mfpu?vfpv3-d16=mfpu?neon-vfpv4
++
++MULTILIB_EXCEPTIONS =
++MULTILIB_REUSE =
++
++MULTILIB_REQUIRED  = mthumb
++MULTILIB_REQUIRED += marm
++MULTILIB_REQUIRED += mfloat-abi=hard
++
++MULTILIB_OSDIRNAMES  = mthumb=!thumb
++MULTILIB_OSDIRNAMES += marm=!arm
++MULTILIB_OSDIRNAMES += mfloat-abi.hard=!fpu
++
++ifneq (,$(findstring armv6-m,$(subst $(comma),$(space),$(with_multilib_list))))
++MULTILIB_REQUIRED   += mthumb/march=armv6s-m
++MULTILIB_OSDIRNAMES += mthumb/march.armv6s-m=!armv6-m
++endif
++
++ifneq (,$(findstring armv7-m,$(subst $(comma),$(space),$(with_multilib_list))))
++MULTILIB_REQUIRED   += mthumb/march=armv7-m
++MULTILIB_OSDIRNAMES += mthumb/march.armv7-m=!armv7-m
++endif
++
++ifneq (,$(findstring armv7e-m,$(subst $(comma),$(space),$(with_multilib_list))))
++MULTILIB_REQUIRED   += mthumb/march=armv7e-m
++MULTILIB_REQUIRED   += mthumb/march=armv7e-m/mfloat-abi=softfp/mfpu=fpv4-sp-d16
++MULTILIB_REQUIRED   += mthumb/march=armv7e-m/mfloat-abi=hard/mfpu=fpv4-sp-d16
++MULTILIB_OSDIRNAMES += mthumb/march.armv7e-m=!armv7e-m
++MULTILIB_OSDIRNAMES += mthumb/march.armv7e-m/mfloat-abi.hard/mfpu.fpv4-sp-d16=!armv7e-m/fpu
++MULTILIB_OSDIRNAMES += mthumb/march.armv7e-m/mfloat-abi.softfp/mfpu.fpv4-sp-d16=!armv7e-m/softfp
++endif
++
++ifneq (,$(filter armv7 armv7-r armv7-a,$(subst $(comma),$(space),$(with_multilib_list))))
++MULTILIB_REQUIRED   += mthumb/march=armv7
++MULTILIB_REQUIRED   += mthumb/march=armv7/mfloat-abi=softfp/mfpu=vfpv3-d16
++MULTILIB_REQUIRED   += mthumb/march=armv7/mfloat-abi=hard/mfpu=vfpv3-d16
++MULTILIB_OSDIRNAMES += mthumb/march.armv7=!armv7-ar/thumb
++MULTILIB_OSDIRNAMES += mthumb/march.armv7/mfloat-abi.hard/mfpu.vfpv3-d16=!armv7-ar/thumb/fpu
++MULTILIB_OSDIRNAMES += mthumb/march.armv7/mfloat-abi.softfp/mfpu.vfpv3-d16=!armv7-ar/thumb/softfp
++MULTILIB_REUSE      += mthumb/march.armv7=marm/march.armv7
++MULTILIB_REUSE      += mthumb/march.armv7/mfloat-abi.softfp/mfpu.vfpv3-d16=marm/march.armv7/mfloat-abi.softfp/mfpu.vfpv3-d16
++MULTILIB_REUSE      += mthumb/march.armv7/mfloat-abi.hard/mfpu.vfpv3-d16=marm/march.armv7/mfloat-abi.hard/mfpu.vfpv3-d16
++endif
+diff --git a/gcc/configure b/gcc/configure
+index 9523773..24952e3 100755
+--- a/gcc/configure
++++ b/gcc/configure
+@@ -763,6 +763,7 @@ SET_MAKE
+ accel_dir_suffix
+ real_target_noncanonical
+ enable_as_accelerator
++with_multilib_list
+ REPORT_BUGS_TEXI
+ REPORT_BUGS_TO
+ PKGVERSION
+@@ -7462,6 +7463,7 @@ else
+ fi
+ 
+ 
++
+ # -------------------------
+ # Checks for other programs
+ # -------------------------
+diff --git a/gcc/configure.ac b/gcc/configure.ac
+index 68b0ee8..f8a1097 100644
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -925,6 +925,7 @@ AC_ARG_WITH(multilib-list,
+ [AS_HELP_STRING([--with-multilib-list], [select multilibs (AArch64, SH and x86-64 only)])],
+ :,
+ with_multilib_list=default)
++AC_SUBST(with_multilib_list)
+ 
+ # -------------------------
+ # Checks for other programs
+
diff --git a/gnu/packages/patches/gcc-6-cross-environment-variables.patch b/gnu/packages/patches/gcc-6-cross-environment-variables.patch
new file mode 100644
index 0000000..285e78f
--- /dev/null
+++ b/gnu/packages/patches/gcc-6-cross-environment-variables.patch
@@ -0,0 +1,65 @@
+Search path environment variables for cross-compilers.  See the discussion
+at <http://gcc.gnu.org/ml/gcc/2013-02/msg00124.html>.
+
+Note: Touch 'C_INCLUDE_PATH' et al. rather than 'CPATH', as discussed
+at <http://bugs.gnu.org/22186>.
+
+--- a/gcc/incpath.c
++++ b/gcc/incpath.c
+@@ -461,8 +461,8 @@ register_include_chains (cpp_reader *pfile, const char *sysroot,
+ 			 int stdinc, int cxx_stdinc, int verbose)
+ {
+   static const char *const lang_env_vars[] =
+-    { "C_INCLUDE_PATH", "CPLUS_INCLUDE_PATH",
+-      "OBJC_INCLUDE_PATH", "OBJCPLUS_INCLUDE_PATH" };
++    { "CROSS_C_INCLUDE_PATH", "CROSS_CPLUS_INCLUDE_PATH",
++      "CROSS_OBJC_INCLUDE_PATH", "CROSS_OBJCPLUS_INCLUDE_PATH" };
+   cpp_options *cpp_opts = cpp_get_options (pfile);
+   size_t idx = (cpp_opts->objc ? 2: 0);
+ 
+@@ -473,7 +473,7 @@ register_include_chains (cpp_reader *pfile, const char *sysroot,
+ 
+   /* CPATH and language-dependent environment variables may add to the
+      include chain.  */
+-  add_env_var_paths ("CPATH", BRACKET);
++  add_env_var_paths ("CROSS_CPATH", BRACKET);
+   add_env_var_paths (lang_env_vars[idx], SYSTEM);
+ 
+   target_c_incpath.extra_pre_includes (sysroot, iprefix, stdinc);
+diff --git a/gcc/system.h b/gcc/system.h
+index 42bc509..af3b9ad 100644
+--- a/gcc/system.h
++++ b/gcc/system.h
+@@ -1063,4 +1063,6 @@ helper_const_non_const_cast (const char *p)
+ /* Get definitions of HOST_WIDE_INT and HOST_WIDEST_INT.  */
+ #include "hwint.h"
+ 
++#define LIBRARY_PATH_ENV "CROSS_LIBRARY_PATH"
++
+ #endif /* ! GCC_SYSTEM_H */
+diff --git a/gcc/tlink.c b/gcc/tlink.c
+index bc358b8..ad6242f 100644
+--- a/gcc/tlink.c
++++ b/gcc/tlink.c
+@@ -458,7 +458,7 @@ recompile_files (void)
+   file *f;
+ 
+   putenv (xstrdup ("COMPILER_PATH="));
+-  putenv (xstrdup ("LIBRARY_PATH="));
++  putenv (xstrdup (LIBRARY_PATH_ENV "="));
+ 
+   while ((f = file_pop ()) != NULL)
+     {
+diff --git a/gcc/gcc.c b/gcc/gcc.c
+index 0f042b0..c23fb0b 100644
+--- a/gcc/gcc.c
++++ b/gcc/gcc.c
+@@ -4264,7 +4264,7 @@ process_command (unsigned int decoded_options_count,
+     }
+ 
+   temp = env.get (LIBRARY_PATH_ENV);
+-  if (temp && *cross_compile == '0')
++  if (temp)
+     {
+       const char *startp, *endp;
+       char *nstore = (char *) alloca (strlen (temp) + 3);
-- 
2.9.3

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

* [PATCH v2 3/4] gnu: Add newlib-arm-none-eabi.
  2016-09-19 20:23 ` [PATCH v2 0/4] Add GCC cross compiler for arm-none-eabi Theodoros Foradis
  2016-09-19 20:23   ` [PATCH v2 1/4] gnu: Add arm-none-eabi cross compiler Theodoros Foradis
  2016-09-19 20:23   ` [PATCH v2 2/4] gnu: Add arm-none-eabi-gcc-6 and patches Theodoros Foradis
@ 2016-09-19 20:23   ` Theodoros Foradis
  2016-09-19 20:23   ` [PATCH v2 4/4] gnu: Add arm-none-eabi-toolchain Theodoros Foradis
  2016-09-27  9:03   ` [PATCH v2 0/4] Add GCC cross compiler for arm-none-eabi Ludovic Courtès
  4 siblings, 0 replies; 29+ messages in thread
From: Theodoros Foradis @ 2016-09-19 20:23 UTC (permalink / raw)
  To: rekado; +Cc: guix-devel

* gnu/packages/embedded.scm (newlib-arm-none-eabi): New procedure.
(newlib-nano-arm-none-eabi): New procedure.
---
 gnu/packages/embedded.scm | 59 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
index 56fbafb..29033b9 100644
--- a/gnu/packages/embedded.scm
+++ b/gnu/packages/embedded.scm
@@ -129,3 +129,62 @@
                       (cons
                        (search-patch "gcc-6-cross-environment-variables.patch")
                        (search-patches "gcc-6-arm-none-eabi-multilib.patch"))))))))
+
+(define (newlib-arm-none-eabi xgcc)
+  (package
+    (name "newlib")
+    (version "2.4.0")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "ftp://sourceware.org/pub/newlib/newlib-"
+                                  version ".tar.gz"))
+              (sha256
+               (base32
+                "01i7qllwicf05vsvh39qj7qp5fdifpvvky0x95hjq39mbqiksnsl"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:out-of-source? #t
+       #:configure-flags '("--target=arm-none-eabi"
+                           "--enable-newlib-io-long-long"
+                           "--enable-newlib-register-fini"
+                           "--disable-newlib-supplied-syscalls"
+                           "--disable-nls")
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'fix-shell-shebangs
+           (lambda _
+             (for-each patch-makefile-SHELL
+                       (find-files "." "Makefile.in")))))))
+    (native-inputs
+     `(("xbinutils" ,xbinutils-arm-none-eabi)
+       ("xgcc" ,xgcc)
+       ("texinfo" ,texinfo)))
+    (home-page "http://www.sourceware.org/newlib/")
+    (synopsis "C library for use on embedded systems")
+    (description "Newlib is a C library intended for use on embedded
+systems.  It is a conglomeration of several library parts that are easily
+usable on embedded products.")
+    (license (license:non-copyleft
+              "https://www.sourceware.org/newlib/COPYING.NEWLIB"))))
+
+(define (newlib-nano-arm-none-eabi xgcc)
+  (package
+    (inherit (newlib-arm-none-eabi xgcc))
+    (name "newlib-nano")
+    (arguments
+     (substitute-keyword-arguments (package-arguments (newlib-arm-none-eabi xgcc))
+       ((#:configure-flags flags)
+        ``("--target=arm-none-eabi"
+           "--enable-multilib"
+           "--disable-newlib-supplied-syscalls"
+           "--enable-newlib-reent-small"
+           "--disable-newlib-fvwrite-in-streamio"
+           "--disable-newlib-fseek-optimization"
+           "--disable-newlib-wide-orient"
+           "--enable-newlib-nano-malloc"
+           "--disable-newlib-unbuf-stream-opt"
+           "--enable-lite-exit"
+           "--enable-newlib-global-atexit"
+           "--enable-newlib-nano-formatted-io"
+           "--disable-nls"))))))
+
-- 
2.9.3

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

* [PATCH v2 4/4] gnu: Add arm-none-eabi-toolchain.
  2016-09-19 20:23 ` [PATCH v2 0/4] Add GCC cross compiler for arm-none-eabi Theodoros Foradis
                     ` (2 preceding siblings ...)
  2016-09-19 20:23   ` [PATCH v2 3/4] gnu: Add newlib-arm-none-eabi Theodoros Foradis
@ 2016-09-19 20:23   ` Theodoros Foradis
  2016-09-27  9:03   ` [PATCH v2 0/4] Add GCC cross compiler for arm-none-eabi Ludovic Courtès
  4 siblings, 0 replies; 29+ messages in thread
From: Theodoros Foradis @ 2016-09-19 20:23 UTC (permalink / raw)
  To: rekado; +Cc: guix-devel

* gnu/packages/embedded.scm (arm-none-eabi-toolchain): New procedure.
(arm-none-eabi-toolchain-4.9, arm-none-eabi-toolchain-nano-4.9): New variables.
(arm-none-eabi-toolchain-6, arm-none-eabi-toolchain-nano-6): New variables.
---
 gnu/packages/embedded.scm | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
index 29033b9..0adbcfa 100644
--- a/gnu/packages/embedded.scm
+++ b/gnu/packages/embedded.scm
@@ -188,3 +188,39 @@ usable on embedded products.")
            "--enable-newlib-nano-formatted-io"
            "--disable-nls"))))))
 
+(define (arm-none-eabi-toolchain xgcc newlib-arm-none-eabi)
+  (let ((newlib (newlib-arm-none-eabi xgcc)))
+    (package
+      (name "arm-none-eabi-toolchain")
+      (version
+       (cond ((string=? (package-name newlib) "newlib")
+              (package-version xgcc))
+             ((string=? (package-name newlib) "newlib-nano")
+              (string-append "nano-" (package-version xgcc)))))
+      (source #f)
+      (build-system trivial-build-system)
+      (arguments '(#:builder (mkdir %output)))
+      (propagated-inputs
+       `(("binutils" ,xbinutils-arm-none-eabi)
+         ("gcc" ,xgcc)
+         ("newlib" ,newlib)))
+      (synopsis "Complete GCC tool chain for ARM bare metal development")
+      (description "This package provides a complete GCC tool chain for ARM
+bare metal development.  This includes the GCC arm-none-eabi cross compiler and
+newlib (or newlib-nano) as the C library.  The supported programming languages
+are C and C++.")
+      (home-page (package-home-page xgcc))
+      (license (package-license xgcc)))))
+
+(define-public arm-none-eabi-toolchain-4.9
+  (arm-none-eabi-toolchain gcc-arm-none-eabi-4.9 newlib-arm-none-eabi))
+
+(define-public arm-none-eabi-toolchain-6
+  (arm-none-eabi-toolchain  gcc-arm-none-eabi-6  newlib-arm-none-eabi))
+
+(define-public arm-none-eabi-toolchain-nano-4.9
+  (arm-none-eabi-toolchain gcc-arm-none-eabi-4.9 newlib-nano-arm-none-eabi))
+
+(define-public arm-none-eabi-toolchain-nano-6
+  (arm-none-eabi-toolchain gcc-arm-none-eabi-6 newlib-nano-arm-none-eabi))
+
-- 
2.9.3

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

* [PATCH v2 0/1] Add GCC cross compiler for arm-none-eabi.
  2016-09-18  6:35 [PATCH 0/3] Add GCC cross compiler for arm-none-eabi Ricardo Wurmus
                   ` (3 preceding siblings ...)
  2016-09-19 20:23 ` [PATCH v2 0/4] Add GCC cross compiler for arm-none-eabi Theodoros Foradis
@ 2016-09-20 10:50 ` Theodoros Foradis
  2016-09-20 10:50   ` [PATCH v2 1/4] gnu: Add arm-none-eabi cross compiler Theodoros Foradis
                     ` (3 more replies)
  2016-09-21  8:30 ` [PATCH 0/3] Add GCC cross compiler for arm-none-eabi Ludovic Courtès
  5 siblings, 4 replies; 29+ messages in thread
From: Theodoros Foradis @ 2016-09-20 10:50 UTC (permalink / raw)
  To: guix-devel


Hello Guix and Ricardo,

The original patch series was working correctly and producing working binaries. There were
some path issues, which I mention later. Some features and flags (present in 6.2.0)
are missing from that version of GCC 4.9, so I added GCC 6.2.0 as an extra option.

Here are the modifications to Ricardo's patches for the arm-none-eabi
bare metal cross compiler:

- Cross-binutils is modified to use binutils 2.5.1, that cross-base provides,
as it is producing working binaries. The version of binutils from the svn commit
that was used by Ricardo is compiling correct binaries as well. Thus, if it is
deemed appropriate, the source for xbinutils can be swapped for the previous one,
with (seemingly) no difference.

- The cross-gcc of the original, was failing to find the newlib-provided headers in
my system. I have set the native-cross-paths as a workaround. Not sure if there
is a better alternative, or if that behavior is my mistake.

- A package for cross GCC 6.2.0 is added, with appropriate patches for multilib
support, taken from the arch linux version of the package.

- Newlib-arm-none-eabi and newlib-nano-arm-none-eabi have been changed to
procedures, taking a cross-gcc as an argument, so as to facilitate building with
either version of gcc.

- An arm-none-eabi-toolchain procedure is declared, to create toolchain packages
for both gcc and newlib versions. The four toolchain variables follow. Not sure
if it's a mistake to include "nano" in the toolchain version.

This is the first patch that I send in guix-devel, so please bear with my mistakes.

Regards,
Theodoros Foradis


* gnu: Add arm-none-eabi-toolchain.
* gnu: Add newlib-arm-none-eabi.
* gnu: Add arm-none-eabi-gcc-6 and patches.
* gnu: Add arm-none-eabi cross compiler.

 gnu/local.mk                                                 |   1 +
 gnu/packages/bootstrap.scm                                   |   1 +
 gnu/packages/embedded.scm                                    | 226 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gnu/packages/patches/gcc-6-arm-none-eabi-multilib.patch      | 201 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gnu/packages/patches/gcc-6-cross-environment-variables.patch |  65 +++++++++++++++++++
 5 files changed, 494 insertions(+)
 create mode 100644 gnu/packages/embedded.scm
 create mode 100644 gnu/packages/patches/gcc-6-arm-none-eabi-multilib.patch
 create mode 100644 gnu/packages/patches/gcc-6-cross-environment-variables.patch

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

* [PATCH v2 1/4] gnu: Add arm-none-eabi cross compiler.
  2016-09-20 10:50 ` [PATCH v2 0/1] " Theodoros Foradis
@ 2016-09-20 10:50   ` Theodoros Foradis
  2016-09-20 10:50   ` [PATCH v2 2/4] gnu: Add arm-none-eabi-gcc-6 and patches Theodoros Foradis
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 29+ messages in thread
From: Theodoros Foradis @ 2016-09-20 10:50 UTC (permalink / raw)
  To: guix-devel

* gnu/packages/bootstrap.scm (glibc-dynamic-linker): Add case for "arm-eabi".
* gnu/packages/embedded.scm: New file.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
---
 gnu/local.mk               |   1 +
 gnu/packages/bootstrap.scm |   1 +
 gnu/packages/embedded.scm  | 119 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 121 insertions(+)
 create mode 100644 gnu/packages/embedded.scm

diff --git a/gnu/local.mk b/gnu/local.mk
index 4076121..caecfa2 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -110,6 +110,7 @@ GNU_SYSTEM_MODULES =				\
   %D%/packages/education.scm			\
   %D%/packages/elf.scm				\
   %D%/packages/elixir.scm			\
+  %D%/packages/embedded.scm			\
   %D%/packages/emacs.scm			\
   %D%/packages/enchant.scm			\
   %D%/packages/engineering.scm			\
diff --git a/gnu/packages/bootstrap.scm b/gnu/packages/bootstrap.scm
index f47a343..f6faba3 100644
--- a/gnu/packages/bootstrap.scm
+++ b/gnu/packages/bootstrap.scm
@@ -171,6 +171,7 @@ successful, or false to signal an error."
 
         ;; XXX: This one is used bare-bones, without a libc, so add a case
         ;; here just so we can keep going.
+        ((string=? system "arm-eabi") "no-ld.so")
         ((string=? system "xtensa-elf") "no-ld.so")
         ((string=? system "avr") "no-ld.so")
         ((string=? system "i686-mingw") "no-ld.so")
diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
new file mode 100644
index 0000000..8650817
--- /dev/null
+++ b/gnu/packages/embedded.scm
@@ -0,0 +1,119 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2016 Theodoros Foradis <theodoros.for@openmailbox.org>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages embedded)
+  #:use-module (guix utils)
+  #:use-module (guix packages)
+  #:use-module (guix download)
+  #:use-module (guix svn-download)
+  #:use-module (guix git-download)
+  #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix build-system gnu)
+  #:use-module (guix build-system trivial)
+  #:use-module (gnu packages)
+  #:use-module (gnu packages bison)
+  #:use-module (gnu packages cross-base)
+  #:use-module (gnu packages flex)
+  #:use-module (gnu packages gcc)
+  #:use-module (gnu packages perl)
+  #:use-module (gnu packages texinfo))
+
+(define-public xbinutils-arm-none-eabi
+  (let ((parent (cross-binutils "arm-none-eabi")))
+    (package
+      (inherit parent)
+      (native-inputs
+       `(("texinfo" ,texinfo)
+         ("perl" ,perl)
+         ("bison" ,bison)
+         ("flex" ,flex)
+         ,@(package-native-inputs parent)))
+      (arguments
+       `(,@(substitute-keyword-arguments (package-arguments parent)
+             ((#:configure-flags flags)
+              `(cons "--enable-multilib"
+                     (delete "--disable-multilib" ,flags)))))))))
+
+;; Commit hashes and SVN revisions for xgcc 4.9 are taken
+;; from https://launchpadlibrarian.net/209776344/release.txt
+;; We must not use the released GCC 4.9 sources here, because the cross-compiler
+;; does not produce working binaries.  Instead we take the very same SVN
+;; revision from the branch that is used for a release of the "GCC ARM
+;; embedded" project on launchpad.
+(define-public gcc-arm-none-eabi-4.9
+  (let ((xgcc (cross-gcc "arm-none-eabi"
+                         xbinutils-arm-none-eabi))
+        (revision "1")
+        (svn-revision 224288))
+    (package (inherit xgcc)
+      (version (string-append (package-version xgcc) "-"
+                              revision "." (number->string svn-revision)))
+      (source
+       (origin
+         (method svn-fetch)
+         (uri (svn-reference
+               (url "svn://gcc.gnu.org/svn/gcc/branches/ARM/embedded-4_9-branch/")
+               (revision svn-revision)))
+         (file-name (string-append "gcc-arm-embedded-" version "-checkout"))
+         (sha256
+          (base32
+           "113r98kygy8rrjfv2pd3z6zlfzbj543pq7xyq8bgh72c608mmsbr"))
+         (patches (origin-patches (package-source xgcc)))))
+      (native-inputs
+       `(("flex" ,flex)
+         ,@(package-native-inputs xgcc)))
+      (arguments
+       `(,@(substitute-keyword-arguments (package-arguments xgcc)
+             ((#:phases phases)
+              `(modify-phases ,phases
+                 (add-after 'unpack 'fix-genmultilib
+                   (lambda _
+                     (substitute* "gcc/genmultilib"
+                       (("#!/bin/sh") (string-append "#!" (which "sh"))))
+                     #t))))
+             ((#:configure-flags flags)
+              `(append (list "--enable-multilib"
+                             "--with-newlib"
+                             "--with-multilib-list=armv6-m,armv7-m,armv7e-m"
+                             "--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm"
+                             "--enable-plugins"
+                             "--disable-decimal-float"
+                             "--disable-libffi"
+                             "--disable-libgomp"
+                             "--disable-libmudflap"
+                             "--disable-libquadmath"
+                             "--disable-libssp"
+                             "--disable-libstdcxx-pch"
+                             "--disable-nls"
+                             "--disable-shared"
+                             "--disable-threads"
+                             "--disable-tls"
+                             "--with-gnu-as"
+                             "--with-gnu-ld")
+                       (delete "--disable-multilib" ,flags))))))
+      (native-search-paths
+       (list (search-path-specification
+              (variable "CROSS_C_INCLUDE_PATH")
+              (files '("arm-none-eabi/include")))
+             (search-path-specification
+              (variable "CROSS_CPLUS_INCLUDE_PATH")
+              (files '("arm-none-eabi/include")))
+             (search-path-specification
+              (variable "CROSS_LIBRARY_PATH")
+              (files '("arm-none-eabi/lib"))))))))
-- 
2.9.3

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

* [PATCH v2 2/4] gnu: Add arm-none-eabi-gcc-6 and patches.
  2016-09-20 10:50 ` [PATCH v2 0/1] " Theodoros Foradis
  2016-09-20 10:50   ` [PATCH v2 1/4] gnu: Add arm-none-eabi cross compiler Theodoros Foradis
@ 2016-09-20 10:50   ` Theodoros Foradis
  2016-09-20 10:50   ` [PATCH v2 3/4] gnu: Add newlib-arm-none-eabi Theodoros Foradis
  2016-09-20 10:50   ` [PATCH v2 4/4] gnu: Add arm-none-eabi-toolchain Theodoros Foradis
  3 siblings, 0 replies; 29+ messages in thread
From: Theodoros Foradis @ 2016-09-20 10:50 UTC (permalink / raw)
  To: guix-devel

* gnu/packages/embedded.scm (gcc-arm-none-eabi-6): New variable.
* gnu/packages/patches/gcc-arm-none-eabi-multilib.patch : New file.
* gnu/packages/patches/gcc-6-cross-environment-variables.patch : New file.
---
 gnu/packages/embedded.scm                          |  12 ++
 .../patches/gcc-6-arm-none-eabi-multilib.patch     | 201 +++++++++++++++++++++
 .../gcc-6-cross-environment-variables.patch        |  65 +++++++
 3 files changed, 278 insertions(+)
 create mode 100644 gnu/packages/patches/gcc-6-arm-none-eabi-multilib.patch
 create mode 100644 gnu/packages/patches/gcc-6-cross-environment-variables.patch

diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
index 8650817..56fbafb 100644
--- a/gnu/packages/embedded.scm
+++ b/gnu/packages/embedded.scm
@@ -117,3 +117,15 @@
              (search-path-specification
               (variable "CROSS_LIBRARY_PATH")
               (files '("arm-none-eabi/lib"))))))))
+
+(define-public gcc-arm-none-eabi-6
+  (package
+    (inherit gcc-arm-none-eabi-4.9)
+    (version (package-version gcc-6))
+    (source (origin (inherit (package-source gcc-6))
+                    (patches
+                     (append
+                      (origin-patches (package-source gcc-6))
+                      (cons
+                       (search-patch "gcc-6-cross-environment-variables.patch")
+                       (search-patches "gcc-6-arm-none-eabi-multilib.patch"))))))))
diff --git a/gnu/packages/patches/gcc-6-arm-none-eabi-multilib.patch b/gnu/packages/patches/gcc-6-arm-none-eabi-multilib.patch
new file mode 100644
index 0000000..442f52b
--- /dev/null
+++ b/gnu/packages/patches/gcc-6-arm-none-eabi-multilib.patch
@@ -0,0 +1,201 @@
+From Anatol Pomozov <anatol.pomozov@gmail.com>
+Taken from Arch Linux arm-none-eabi-gcc package.
+
+Modified version of ARM patch https://gcc.gnu.org/ml/gcc-patches/2012-05/msg00083/enable-with-multilib-list-for-arm.patch
+
+diff --git a/gcc/Makefile.in b/gcc/Makefile.in
+index 4ab7405..6e1ea2c 100644
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -535,6 +535,7 @@ lang_opt_files=@lang_opt_files@ $(srcdir)/c-family/c.opt $(srcdir)/common.opt
+ lang_specs_files=@lang_specs_files@
+ lang_tree_files=@lang_tree_files@
+ target_cpu_default=@target_cpu_default@
++with_multilib_list=@with_multilib_list@
+ OBJC_BOEHM_GC=@objc_boehm_gc@
+ extra_modes_file=@extra_modes_file@
+ extra_opt_files=@extra_opt_files@
+diff --git a/gcc/config.gcc b/gcc/config.gcc
+index cb08a5c..7bded02 100644
+--- a/gcc/config.gcc
++++ b/gcc/config.gcc
+@@ -1072,7 +1072,7 @@ arm*-*-eabi* | arm*-*-symbianelf* | arm*-*-rtems*)
+ 	case ${target} in
+ 	arm*-*-eabi*)
+ 	  tm_file="$tm_file newlib-stdint.h"
+-	  tmake_file="${tmake_file} arm/t-bpabi"
++	  tmake_file="${tmake_file} arm/t-bpabi arm/t-mlibs"
+ 	  use_gcc_stdint=wrap
+ 	  ;;
+ 	arm*-*-rtems*)
+@@ -3684,42 +3684,6 @@ case "${target}" in
+ 			exit 1
+ 		fi
+ 
+-		# Add extra multilibs
+-		if test "x$with_multilib_list" != x; then
+-			arm_multilibs=`echo $with_multilib_list | sed -e 's/,/ /g'`
+-			for arm_multilib in ${arm_multilibs}; do
+-				case ${arm_multilib} in
+-				aprofile)
+-				# Note that arm/t-aprofile is a
+-				# stand-alone make file fragment to be
+-				# used only with itself.  We do not
+-				# specifically use the
+-				# TM_MULTILIB_OPTION framework because
+-				# this shorthand is more
+-				# pragmatic. Additionally it is only
+-				# designed to work without any
+-				# with-cpu, with-arch with-mode
+-				# with-fpu or with-float options.
+-					if test "x$with_arch" != x \
+-					    || test "x$with_cpu" != x \
+-					    || test "x$with_float" != x \
+-					    || test "x$with_fpu" != x \
+-					    || test "x$with_mode" != x ; then
+-					    echo "Error: You cannot use any of --with-arch/cpu/fpu/float/mode with --with-multilib-list=aprofile" 1>&2
+-					    exit 1
+-					fi
+-					tmake_file="${tmake_file} arm/t-aprofile"
+-					break
+-					;;
+-				default)
+-					;;
+-				*)
+-					echo "Error: --with-multilib-list=${with_multilib_list} not supported." 1>&2
+-					exit 1
+-					;;
+-				esac
+-			done
+-		fi
+ 		;;
+ 
+ 	fr*-*-*linux*)
+diff --git a/gcc/config/arm/t-mlibs b/gcc/config/arm/t-mlibs
+new file mode 100644
+index 0000000..5720cf7
+--- /dev/null
++++ b/gcc/config/arm/t-mlibs
+@@ -0,0 +1,89 @@
++# A set of predefined MULTILIB which can be used for different ARM targets.
++# Via the configure option --with-multilib-list, user can customize the
++# final MULTILIB implementation.
++
++comma := ,
++space :=
++space +=
++
++MULTILIB_OPTIONS   = mthumb/marm
++MULTILIB_DIRNAMES  = thumb arm
++MULTILIB_OPTIONS  += march=armv6s-m/march=armv7-m/march=armv7e-m/march=armv7
++MULTILIB_DIRNAMES += armv6-m armv7-m armv7e-m armv7-ar
++MULTILIB_OPTIONS  += mfloat-abi=softfp/mfloat-abi=hard
++MULTILIB_DIRNAMES += softfp fpu
++MULTILIB_OPTIONS  += mfpu=fpv4-sp-d16/mfpu=vfpv3-d16
++MULTILIB_DIRNAMES += fpv4-sp-d16 vfpv3-d16
++
++MULTILIB_MATCHES   = march?armv6s-m=mcpu?cortex-m0
++MULTILIB_MATCHES  += march?armv6s-m=mcpu?cortex-m0plus
++MULTILIB_MATCHES  += march?armv6s-m=mcpu?cortex-m1
++MULTILIB_MATCHES  += march?armv6s-m=march?armv6-m
++MULTILIB_MATCHES  += march?armv7-m=mcpu?cortex-m3
++MULTILIB_MATCHES  += march?armv7e-m=mcpu?cortex-m4
++MULTILIB_MATCHES  += march?armv7e-m=mcpu?cortex-m7
++MULTILIB_MATCHES  += march?armv7=march?armv7-r
++MULTILIB_MATCHES  += march?armv7=march?armv7-a
++MULTILIB_MATCHES  += march?armv7=mcpu?cortex-r4
++MULTILIB_MATCHES  += march?armv7=mcpu?cortex-r4f
++MULTILIB_MATCHES  += march?armv7=mcpu?cortex-r5
++MULTILIB_MATCHES  += march?armv7=mcpu?cortex-r7
++MULTILIB_MATCHES  += march?armv7=mcpu?cortex-a5
++MULTILIB_MATCHES  += march?armv7=mcpu?cortex-a7
++MULTILIB_MATCHES  += march?armv7=mcpu?cortex-a8
++MULTILIB_MATCHES  += march?armv7=mcpu?cortex-a9
++MULTILIB_MATCHES  += march?armv7=mcpu?cortex-a15
++MULTILIB_MATCHES  += mfpu?fpv4-sp-d16=mfpu?fpv5-sp-d16
++MULTILIB_MATCHES  += mfpu?fpv4-sp-d16=mfpu?fpv5-d16
++MULTILIB_MATCHES  += mfpu?vfpv3-d16=mfpu?vfpv3
++MULTILIB_MATCHES  += mfpu?vfpv3-d16=mfpu?vfpv3-fp16
++MULTILIB_MATCHES  += mfpu?vfpv3-d16=mfpu?vfpv3-d16-fp16
++MULTILIB_MATCHES  += mfpu?vfpv3-d16=mfpu?vfpv3xd
++MULTILIB_MATCHES  += mfpu?vfpv3-d16=mfpu?vfpv3xd-fp16
++MULTILIB_MATCHES  += mfpu?vfpv3-d16=mfpu?vfpv4
++MULTILIB_MATCHES  += mfpu?vfpv3-d16=mfpu?vfpv4-d16
++MULTILIB_MATCHES  += mfpu?vfpv3-d16=mfpu?neon
++MULTILIB_MATCHES  += mfpu?vfpv3-d16=mfpu?neon-fp16
++MULTILIB_MATCHES  += mfpu?vfpv3-d16=mfpu?neon-vfpv4
++
++MULTILIB_EXCEPTIONS =
++MULTILIB_REUSE =
++
++MULTILIB_REQUIRED  = mthumb
++MULTILIB_REQUIRED += marm
++MULTILIB_REQUIRED += mfloat-abi=hard
++
++MULTILIB_OSDIRNAMES  = mthumb=!thumb
++MULTILIB_OSDIRNAMES += marm=!arm
++MULTILIB_OSDIRNAMES += mfloat-abi.hard=!fpu
++
++ifneq (,$(findstring armv6-m,$(subst $(comma),$(space),$(with_multilib_list))))
++MULTILIB_REQUIRED   += mthumb/march=armv6s-m
++MULTILIB_OSDIRNAMES += mthumb/march.armv6s-m=!armv6-m
++endif
++
++ifneq (,$(findstring armv7-m,$(subst $(comma),$(space),$(with_multilib_list))))
++MULTILIB_REQUIRED   += mthumb/march=armv7-m
++MULTILIB_OSDIRNAMES += mthumb/march.armv7-m=!armv7-m
++endif
++
++ifneq (,$(findstring armv7e-m,$(subst $(comma),$(space),$(with_multilib_list))))
++MULTILIB_REQUIRED   += mthumb/march=armv7e-m
++MULTILIB_REQUIRED   += mthumb/march=armv7e-m/mfloat-abi=softfp/mfpu=fpv4-sp-d16
++MULTILIB_REQUIRED   += mthumb/march=armv7e-m/mfloat-abi=hard/mfpu=fpv4-sp-d16
++MULTILIB_OSDIRNAMES += mthumb/march.armv7e-m=!armv7e-m
++MULTILIB_OSDIRNAMES += mthumb/march.armv7e-m/mfloat-abi.hard/mfpu.fpv4-sp-d16=!armv7e-m/fpu
++MULTILIB_OSDIRNAMES += mthumb/march.armv7e-m/mfloat-abi.softfp/mfpu.fpv4-sp-d16=!armv7e-m/softfp
++endif
++
++ifneq (,$(filter armv7 armv7-r armv7-a,$(subst $(comma),$(space),$(with_multilib_list))))
++MULTILIB_REQUIRED   += mthumb/march=armv7
++MULTILIB_REQUIRED   += mthumb/march=armv7/mfloat-abi=softfp/mfpu=vfpv3-d16
++MULTILIB_REQUIRED   += mthumb/march=armv7/mfloat-abi=hard/mfpu=vfpv3-d16
++MULTILIB_OSDIRNAMES += mthumb/march.armv7=!armv7-ar/thumb
++MULTILIB_OSDIRNAMES += mthumb/march.armv7/mfloat-abi.hard/mfpu.vfpv3-d16=!armv7-ar/thumb/fpu
++MULTILIB_OSDIRNAMES += mthumb/march.armv7/mfloat-abi.softfp/mfpu.vfpv3-d16=!armv7-ar/thumb/softfp
++MULTILIB_REUSE      += mthumb/march.armv7=marm/march.armv7
++MULTILIB_REUSE      += mthumb/march.armv7/mfloat-abi.softfp/mfpu.vfpv3-d16=marm/march.armv7/mfloat-abi.softfp/mfpu.vfpv3-d16
++MULTILIB_REUSE      += mthumb/march.armv7/mfloat-abi.hard/mfpu.vfpv3-d16=marm/march.armv7/mfloat-abi.hard/mfpu.vfpv3-d16
++endif
+diff --git a/gcc/configure b/gcc/configure
+index 9523773..24952e3 100755
+--- a/gcc/configure
++++ b/gcc/configure
+@@ -763,6 +763,7 @@ SET_MAKE
+ accel_dir_suffix
+ real_target_noncanonical
+ enable_as_accelerator
++with_multilib_list
+ REPORT_BUGS_TEXI
+ REPORT_BUGS_TO
+ PKGVERSION
+@@ -7462,6 +7463,7 @@ else
+ fi
+ 
+ 
++
+ # -------------------------
+ # Checks for other programs
+ # -------------------------
+diff --git a/gcc/configure.ac b/gcc/configure.ac
+index 68b0ee8..f8a1097 100644
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -925,6 +925,7 @@ AC_ARG_WITH(multilib-list,
+ [AS_HELP_STRING([--with-multilib-list], [select multilibs (AArch64, SH and x86-64 only)])],
+ :,
+ with_multilib_list=default)
++AC_SUBST(with_multilib_list)
+ 
+ # -------------------------
+ # Checks for other programs
+
diff --git a/gnu/packages/patches/gcc-6-cross-environment-variables.patch b/gnu/packages/patches/gcc-6-cross-environment-variables.patch
new file mode 100644
index 0000000..285e78f
--- /dev/null
+++ b/gnu/packages/patches/gcc-6-cross-environment-variables.patch
@@ -0,0 +1,65 @@
+Search path environment variables for cross-compilers.  See the discussion
+at <http://gcc.gnu.org/ml/gcc/2013-02/msg00124.html>.
+
+Note: Touch 'C_INCLUDE_PATH' et al. rather than 'CPATH', as discussed
+at <http://bugs.gnu.org/22186>.
+
+--- a/gcc/incpath.c
++++ b/gcc/incpath.c
+@@ -461,8 +461,8 @@ register_include_chains (cpp_reader *pfile, const char *sysroot,
+ 			 int stdinc, int cxx_stdinc, int verbose)
+ {
+   static const char *const lang_env_vars[] =
+-    { "C_INCLUDE_PATH", "CPLUS_INCLUDE_PATH",
+-      "OBJC_INCLUDE_PATH", "OBJCPLUS_INCLUDE_PATH" };
++    { "CROSS_C_INCLUDE_PATH", "CROSS_CPLUS_INCLUDE_PATH",
++      "CROSS_OBJC_INCLUDE_PATH", "CROSS_OBJCPLUS_INCLUDE_PATH" };
+   cpp_options *cpp_opts = cpp_get_options (pfile);
+   size_t idx = (cpp_opts->objc ? 2: 0);
+ 
+@@ -473,7 +473,7 @@ register_include_chains (cpp_reader *pfile, const char *sysroot,
+ 
+   /* CPATH and language-dependent environment variables may add to the
+      include chain.  */
+-  add_env_var_paths ("CPATH", BRACKET);
++  add_env_var_paths ("CROSS_CPATH", BRACKET);
+   add_env_var_paths (lang_env_vars[idx], SYSTEM);
+ 
+   target_c_incpath.extra_pre_includes (sysroot, iprefix, stdinc);
+diff --git a/gcc/system.h b/gcc/system.h
+index 42bc509..af3b9ad 100644
+--- a/gcc/system.h
++++ b/gcc/system.h
+@@ -1063,4 +1063,6 @@ helper_const_non_const_cast (const char *p)
+ /* Get definitions of HOST_WIDE_INT and HOST_WIDEST_INT.  */
+ #include "hwint.h"
+ 
++#define LIBRARY_PATH_ENV "CROSS_LIBRARY_PATH"
++
+ #endif /* ! GCC_SYSTEM_H */
+diff --git a/gcc/tlink.c b/gcc/tlink.c
+index bc358b8..ad6242f 100644
+--- a/gcc/tlink.c
++++ b/gcc/tlink.c
+@@ -458,7 +458,7 @@ recompile_files (void)
+   file *f;
+ 
+   putenv (xstrdup ("COMPILER_PATH="));
+-  putenv (xstrdup ("LIBRARY_PATH="));
++  putenv (xstrdup (LIBRARY_PATH_ENV "="));
+ 
+   while ((f = file_pop ()) != NULL)
+     {
+diff --git a/gcc/gcc.c b/gcc/gcc.c
+index 0f042b0..c23fb0b 100644
+--- a/gcc/gcc.c
++++ b/gcc/gcc.c
+@@ -4264,7 +4264,7 @@ process_command (unsigned int decoded_options_count,
+     }
+ 
+   temp = env.get (LIBRARY_PATH_ENV);
+-  if (temp && *cross_compile == '0')
++  if (temp)
+     {
+       const char *startp, *endp;
+       char *nstore = (char *) alloca (strlen (temp) + 3);
-- 
2.9.3

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

* [PATCH v2 3/4] gnu: Add newlib-arm-none-eabi.
  2016-09-20 10:50 ` [PATCH v2 0/1] " Theodoros Foradis
  2016-09-20 10:50   ` [PATCH v2 1/4] gnu: Add arm-none-eabi cross compiler Theodoros Foradis
  2016-09-20 10:50   ` [PATCH v2 2/4] gnu: Add arm-none-eabi-gcc-6 and patches Theodoros Foradis
@ 2016-09-20 10:50   ` Theodoros Foradis
  2016-09-20 10:50   ` [PATCH v2 4/4] gnu: Add arm-none-eabi-toolchain Theodoros Foradis
  3 siblings, 0 replies; 29+ messages in thread
From: Theodoros Foradis @ 2016-09-20 10:50 UTC (permalink / raw)
  To: guix-devel

* gnu/packages/embedded.scm (newlib-arm-none-eabi): New procedure.
(newlib-nano-arm-none-eabi): New procedure.
---
 gnu/packages/embedded.scm | 59 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
index 56fbafb..29033b9 100644
--- a/gnu/packages/embedded.scm
+++ b/gnu/packages/embedded.scm
@@ -129,3 +129,62 @@
                       (cons
                        (search-patch "gcc-6-cross-environment-variables.patch")
                        (search-patches "gcc-6-arm-none-eabi-multilib.patch"))))))))
+
+(define (newlib-arm-none-eabi xgcc)
+  (package
+    (name "newlib")
+    (version "2.4.0")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "ftp://sourceware.org/pub/newlib/newlib-"
+                                  version ".tar.gz"))
+              (sha256
+               (base32
+                "01i7qllwicf05vsvh39qj7qp5fdifpvvky0x95hjq39mbqiksnsl"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:out-of-source? #t
+       #:configure-flags '("--target=arm-none-eabi"
+                           "--enable-newlib-io-long-long"
+                           "--enable-newlib-register-fini"
+                           "--disable-newlib-supplied-syscalls"
+                           "--disable-nls")
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'fix-shell-shebangs
+           (lambda _
+             (for-each patch-makefile-SHELL
+                       (find-files "." "Makefile.in")))))))
+    (native-inputs
+     `(("xbinutils" ,xbinutils-arm-none-eabi)
+       ("xgcc" ,xgcc)
+       ("texinfo" ,texinfo)))
+    (home-page "http://www.sourceware.org/newlib/")
+    (synopsis "C library for use on embedded systems")
+    (description "Newlib is a C library intended for use on embedded
+systems.  It is a conglomeration of several library parts that are easily
+usable on embedded products.")
+    (license (license:non-copyleft
+              "https://www.sourceware.org/newlib/COPYING.NEWLIB"))))
+
+(define (newlib-nano-arm-none-eabi xgcc)
+  (package
+    (inherit (newlib-arm-none-eabi xgcc))
+    (name "newlib-nano")
+    (arguments
+     (substitute-keyword-arguments (package-arguments (newlib-arm-none-eabi xgcc))
+       ((#:configure-flags flags)
+        ``("--target=arm-none-eabi"
+           "--enable-multilib"
+           "--disable-newlib-supplied-syscalls"
+           "--enable-newlib-reent-small"
+           "--disable-newlib-fvwrite-in-streamio"
+           "--disable-newlib-fseek-optimization"
+           "--disable-newlib-wide-orient"
+           "--enable-newlib-nano-malloc"
+           "--disable-newlib-unbuf-stream-opt"
+           "--enable-lite-exit"
+           "--enable-newlib-global-atexit"
+           "--enable-newlib-nano-formatted-io"
+           "--disable-nls"))))))
+
-- 
2.9.3

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

* [PATCH v2 4/4] gnu: Add arm-none-eabi-toolchain.
  2016-09-20 10:50 ` [PATCH v2 0/1] " Theodoros Foradis
                     ` (2 preceding siblings ...)
  2016-09-20 10:50   ` [PATCH v2 3/4] gnu: Add newlib-arm-none-eabi Theodoros Foradis
@ 2016-09-20 10:50   ` Theodoros Foradis
  3 siblings, 0 replies; 29+ messages in thread
From: Theodoros Foradis @ 2016-09-20 10:50 UTC (permalink / raw)
  To: guix-devel

* gnu/packages/embedded.scm (arm-none-eabi-toolchain): New procedure.
(arm-none-eabi-toolchain-4.9, arm-none-eabi-toolchain-nano-4.9): New variables.
(arm-none-eabi-toolchain-6, arm-none-eabi-toolchain-nano-6): New variables.
---
 gnu/packages/embedded.scm | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
index 29033b9..0adbcfa 100644
--- a/gnu/packages/embedded.scm
+++ b/gnu/packages/embedded.scm
@@ -188,3 +188,39 @@ usable on embedded products.")
            "--enable-newlib-nano-formatted-io"
            "--disable-nls"))))))
 
+(define (arm-none-eabi-toolchain xgcc newlib-arm-none-eabi)
+  (let ((newlib (newlib-arm-none-eabi xgcc)))
+    (package
+      (name "arm-none-eabi-toolchain")
+      (version
+       (cond ((string=? (package-name newlib) "newlib")
+              (package-version xgcc))
+             ((string=? (package-name newlib) "newlib-nano")
+              (string-append "nano-" (package-version xgcc)))))
+      (source #f)
+      (build-system trivial-build-system)
+      (arguments '(#:builder (mkdir %output)))
+      (propagated-inputs
+       `(("binutils" ,xbinutils-arm-none-eabi)
+         ("gcc" ,xgcc)
+         ("newlib" ,newlib)))
+      (synopsis "Complete GCC tool chain for ARM bare metal development")
+      (description "This package provides a complete GCC tool chain for ARM
+bare metal development.  This includes the GCC arm-none-eabi cross compiler and
+newlib (or newlib-nano) as the C library.  The supported programming languages
+are C and C++.")
+      (home-page (package-home-page xgcc))
+      (license (package-license xgcc)))))
+
+(define-public arm-none-eabi-toolchain-4.9
+  (arm-none-eabi-toolchain gcc-arm-none-eabi-4.9 newlib-arm-none-eabi))
+
+(define-public arm-none-eabi-toolchain-6
+  (arm-none-eabi-toolchain  gcc-arm-none-eabi-6  newlib-arm-none-eabi))
+
+(define-public arm-none-eabi-toolchain-nano-4.9
+  (arm-none-eabi-toolchain gcc-arm-none-eabi-4.9 newlib-nano-arm-none-eabi))
+
+(define-public arm-none-eabi-toolchain-nano-6
+  (arm-none-eabi-toolchain gcc-arm-none-eabi-6 newlib-nano-arm-none-eabi))
+
-- 
2.9.3

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

* Re: [PATCH 0/3] Add GCC cross compiler for arm-none-eabi.
  2016-09-18  6:35 [PATCH 0/3] Add GCC cross compiler for arm-none-eabi Ricardo Wurmus
                   ` (4 preceding siblings ...)
  2016-09-20 10:50 ` [PATCH v2 0/1] " Theodoros Foradis
@ 2016-09-21  8:30 ` Ludovic Courtès
  5 siblings, 0 replies; 29+ messages in thread
From: Ludovic Courtès @ 2016-09-21  8:30 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: guix-devel

Hi!

Ricardo Wurmus <rekado@elephly.net> skribis:

> here's a patch series I've been sitting on for about a year.  It's a compiler
> for bare-metal binaries targetting arm-none-eabi.  I'm using this successfully
> to compile ChibiOS for the Axoloti Core board.

Awesome, congrats!

> I've chosen to package the particular compiler version that is used for the
> Axoloti Core, so this is equivalent to what the GNU ARM Embedded Toolchain
> project provides with the "4.9-2015-q2-update" release (see
> https://launchpadlibrarian.net/209776344/release.txt).  I used SVN revisions
> because certain ARM patches are not part of the standard release tarball; they
> are only in SVN.
>
> I did update newlib to the very latest release, however, because it seems to
> work just fine.
>
> I don't know if it's okay to keep older versions of the cross compiler.  For
> version 4.9 the GNU ARM Embedded Toolchain project made another release
> "4.9-2015-q3-update".  It's probably better to at least use the upstream
> versions they used for that release instead of basing things on
> "4.9-2015-q2-update".

OK.  Too bad the released versions lack these bits.

> I have no idea if we can build our own version of 4.9 from a later revision,
> because I don't know exactly what patches I'd need to backport.  If somebody
> knows better I'd appreciate hints.

I don’t know, but I think it’s important to provide release tarballs
rather than intermediate revisions (except of course in the case of this
Axoloti cross-compiler).

Thanks!

Ludo’.

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

* Re: [PATCH 1/3] gnu: Add arm-none-eabi cross compiler.
  2016-09-18  6:35 ` [PATCH 1/3] gnu: Add arm-none-eabi cross compiler Ricardo Wurmus
@ 2016-09-21  8:34   ` Ludovic Courtès
  0 siblings, 0 replies; 29+ messages in thread
From: Ludovic Courtès @ 2016-09-21  8:34 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: guix-devel

Hi!

Ricardo Wurmus <rekado@elephly.net> skribis:

> * gnu/packages/bootstrap.scm (glibc-dynamic-linker): Add case for "arm-eabi".
> * gnu/packages/embedded.scm: New file.
> * gnu/local.mk (GNU_SYSTEM_MODULES): Add it.

[...]

> +;; Commit hashes and SVN revisions for xbinutils and xgcc are taken
> +;; from https://launchpadlibrarian.net/209776344/release.txt
> +
> +(define-public xbinutils-arm-none-eabi

[...]

> +      (arguments
> +       `(,@(substitute-keyword-arguments (package-arguments parent)
> +             ((#:configure-flags flags)
> +              `(cons "--enable-multilib"
> +                     (delete "--disable-multilib" ,flags)))))))))

Why is multilib support needed?  Could you add a comment here?

Also, `,@lst is equivalent to lst.  :-)

> +       `(,@(substitute-keyword-arguments (package-arguments xgcc)
            ^^
Same here.

> +             ((#:configure-flags flags)
> +              `(append (list "--enable-multilib"
> +                             "--with-newlib"
> +                             "--with-multilib-list=armv6-m,armv7-m,armv7e-m"
> +                             "--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm"
> +                             "--enable-plugins"
> +                             "--disable-decimal-float"
> +                             "--disable-libffi"
> +                             "--disable-libgomp"
> +                             "--disable-libmudflap"
> +                             "--disable-libquadmath"
> +                             "--disable-libssp"
> +                             "--disable-libstdcxx-pch"
> +                             "--disable-nls"
> +                             "--disable-shared"
> +                             "--disable-threads"
> +                             "--disable-tls"
> +                             "--with-gnu-as"
> +                             "--with-gnu-ld")
> +                       (delete "--disable-multilib" ,flags)))))))))

Could you add comments explaining briefly where these flags come from?
Normally --with-gnu-* are not needed because ./configure should detect
that.

Thank you,
Ludo’.

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

* Re: [PATCH 2/3] gnu: Add newlib-arm-none-eabi.
  2016-09-18  6:35 ` [PATCH 2/3] gnu: Add newlib-arm-none-eabi Ricardo Wurmus
@ 2016-09-21  8:38   ` Ludovic Courtès
  0 siblings, 0 replies; 29+ messages in thread
From: Ludovic Courtès @ 2016-09-21  8:38 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: guix-devel

Ricardo Wurmus <rekado@elephly.net> skribis:

> * gnu/packages/embedded.scm (newlib-arm-none-eabi): New variable.

[...]

> +       #:configure-flags '("--target=arm-none-eabi"
> +                           "--enable-newlib-io-long-long"
> +                           "--enable-newlib-register-fini"
> +                           "--disable-newlib-supplied-syscalls"
> +                           "--disable-nls")

Maybe a short comment to explain.  :-)

> +       #:phases
> +       (modify-phases %standard-phases
> +         (add-after 'unpack 'fix-shell-shebangs
> +           (lambda _
> +             (setenv "SHELL" (which "sh"))
> +             (setenv "CONFIG_SHELL" (which "sh"))
> +             (substitute* '("libgloss/arm/configure"
> +                            "libgloss/arm/cpu-init/Makefile.in"
> +                            "libgloss/arm/Makefile.in"
> +                            "libgloss/libnosys/Makefile.in"
> +                            "libgloss/Makefile.in")
> +               (("/bin/sh") (which "sh")))

Are they not taken care of by the ‘patch-shebangs’ phase?

Otherwise LGTM, thanks!

Ludo’.

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

* Re: [PATCH 3/3] gnu: Add newlib-nano-arm-none-eabi.
  2016-09-18  6:35 ` [PATCH 3/3] gnu: Add newlib-nano-arm-none-eabi Ricardo Wurmus
@ 2016-09-21  8:40   ` Ludovic Courtès
  2016-10-02 18:47     ` Ricardo Wurmus
  0 siblings, 1 reply; 29+ messages in thread
From: Ludovic Courtès @ 2016-09-21  8:40 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: guix-devel

Ricardo Wurmus <rekado@elephly.net> skribis:

> * gnu/packages/embedded.scm (newlib-nano-arm-none-eabi): New variable.

[...]

> +(define-public newlib-nano-arm-none-eabi
> +  (package (inherit newlib-arm-none-eabi)
> +    (name "newlib-nano")

I think it should be “newlib-minimal”, no?  Or does “nano” have a
special meaning?

Also, make sure to add a synopsis that mentions its minimalness, and
maybe a comment stating what the intended use case is, or how the
feature set was chosen.

Otherwise LGTM, thanks!

Ludo’.

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

* Re: [PATCH v2 0/4] Add GCC cross compiler for arm-none-eabi.
  2016-09-19 20:23 ` [PATCH v2 0/4] Add GCC cross compiler for arm-none-eabi Theodoros Foradis
                     ` (3 preceding siblings ...)
  2016-09-19 20:23   ` [PATCH v2 4/4] gnu: Add arm-none-eabi-toolchain Theodoros Foradis
@ 2016-09-27  9:03   ` Ludovic Courtès
  2016-09-29  9:24     ` Ricardo Wurmus
  4 siblings, 1 reply; 29+ messages in thread
From: Ludovic Courtès @ 2016-09-27  9:03 UTC (permalink / raw)
  To: Theodoros Foradis; +Cc: guix-devel

Hi Theodoros,

Theodoros Foradis <theodoros.for@openmailbox.org> skribis:

> The original patch series was working correctly and producing working binaries. Some
> flags (that I had been using with 6.2.0) are missing from that version of GCC 4.9,
> so I added 6.2.0 as an extra option. I have tested it to produce working binaries.
>
> Here are some modifications to Ricardo's patches for the arm-none-eabi
> bare metal cross compiler. The following changes have been made:
>
> - I have modified xbinutils to use binutils 2.25.1 from cross-base, as it compiles
> correctly with it. The version from the svn commit that was used by Ricardo is compiling
> correct binaries as well. Thus, if it is deemed appropriate, the source for xbinutils can
> be swapped for the previous one, with (seemingly) no difference.
>
> - The xgcc of the original, was failing to find the headers that newlib provided.
> I have set the native-cross-paths as a workaround. Not sure if there is a better
> alternative, or if the failure was my mistake.
>
> - A package for cross GCC 6.2.0 is added, with appropriate patches for multilib
> support.
>
> - Newlib-arm-none-eabi and newlib-nano-arm-none-eabi have been changed to
> procedures, taking an xgcc as argument, so as to facilitate building with
> either version of gcc.
>
> - An arm-none-eabi-toolchain procedure is declared, to create toolchain packages
> for both gcc and newlib version. The four toolchain variables follow. Not sure
> if it's a mistake to include "nano" in the toolchain version.

This all sounds reasonable to me.  Ricardo was interested in using this
toolchain for one specific purpose, so maybe we’ll want to check that it
also works here.  Ricardo: could you comment?

FWIW I had commented on Ricardo’s patch series here:

  https://lists.gnu.org/archive/html/guix-devel/2016-09/msg01379.html

> This is the first patch that I send in guix-devel, so please bear with me.

Welcome!  Sorry that it already took a bit long, but hopefully we’ll
converge real soon!  :-)

Thanks,
Ludo’.

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

* Re: [PATCH v2 0/4] Add GCC cross compiler for arm-none-eabi.
  2016-09-27  9:03   ` [PATCH v2 0/4] Add GCC cross compiler for arm-none-eabi Ludovic Courtès
@ 2016-09-29  9:24     ` Ricardo Wurmus
  2016-09-29 17:39       ` Theodoros Foradis
  2016-10-10 18:09       ` Theodoros Foradis
  0 siblings, 2 replies; 29+ messages in thread
From: Ricardo Wurmus @ 2016-09-29  9:24 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel


Ludovic Courtès <ludo@gnu.org> writes:

> Hi Theodoros,
>
> Theodoros Foradis <theodoros.for@openmailbox.org> skribis:
>
>> The original patch series was working correctly and producing working binaries. Some
>> flags (that I had been using with 6.2.0) are missing from that version of GCC 4.9,
>> so I added 6.2.0 as an extra option. I have tested it to produce working binaries.
>>
>> Here are some modifications to Ricardo's patches for the arm-none-eabi
>> bare metal cross compiler. The following changes have been made:
>>
>> - I have modified xbinutils to use binutils 2.25.1 from cross-base, as it compiles
>> correctly with it. The version from the svn commit that was used by Ricardo is compiling
>> correct binaries as well. Thus, if it is deemed appropriate, the source for xbinutils can
>> be swapped for the previous one, with (seemingly) no difference.
>>
>> - The xgcc of the original, was failing to find the headers that newlib provided.
>> I have set the native-cross-paths as a workaround. Not sure if there is a better
>> alternative, or if the failure was my mistake.
>>
>> - A package for cross GCC 6.2.0 is added, with appropriate patches for multilib
>> support.
>>
>> - Newlib-arm-none-eabi and newlib-nano-arm-none-eabi have been changed to
>> procedures, taking an xgcc as argument, so as to facilitate building with
>> either version of gcc.
>>
>> - An arm-none-eabi-toolchain procedure is declared, to create toolchain packages
>> for both gcc and newlib version. The four toolchain variables follow. Not sure
>> if it's a mistake to include "nano" in the toolchain version.
>
> This all sounds reasonable to me.  Ricardo was interested in using this
> toolchain for one specific purpose, so maybe we’ll want to check that it
> also works here.  Ricardo: could you comment?

The changes seem reasonable.  I wasn’t happy with using fixed SVN
revisions in my patches, so I’m glad that this can be avoided.

I haven’t yet found the time to apply the proposed changes, build the
toolchain and try it with the Axoloti board.  I hope I’ll be able try on
Sunday to first address your comments, Ludo.  Then I’ll check the
suggested changes made by Theodoros (e.g. using different binutils and
doing without SVN).

Theodoros, I see that your patch set includes some of my patches as
well.  The only changes I can see is the addition of the native search
paths and parameterising newlib with xgcc, both of which I’ll add.
After applying my modified patches I would apply your patches that add
“arm-none-eabi-gcc-6” and the “arm-none-eabi-toolchain”.

Is this acceptable?

~~ Ricardo

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

* Re: [PATCH v2 0/4] Add GCC cross compiler for arm-none-eabi.
  2016-09-29  9:24     ` Ricardo Wurmus
@ 2016-09-29 17:39       ` Theodoros Foradis
  2016-10-10 18:09       ` Theodoros Foradis
  1 sibling, 0 replies; 29+ messages in thread
From: Theodoros Foradis @ 2016-09-29 17:39 UTC (permalink / raw)
  To: guix-devel


Ricardo Wurmus writes:

> Ludovic Courtès <ludo@gnu.org> writes:
>
>> Hi Theodoros,
>>
>> Theodoros Foradis <theodoros.for@openmailbox.org> skribis:
>>
>>> The original patch series was working correctly and producing working binaries. Some
>>> flags (that I had been using with 6.2.0) are missing from that version of GCC 4.9,
>>> so I added 6.2.0 as an extra option. I have tested it to produce working binaries.
>>>
>>> Here are some modifications to Ricardo's patches for the arm-none-eabi
>>> bare metal cross compiler. The following changes have been made:
>>>
>>> - I have modified xbinutils to use binutils 2.25.1 from cross-base, as it compiles
>>> correctly with it. The version from the svn commit that was used by Ricardo is compiling
>>> correct binaries as well. Thus, if it is deemed appropriate, the source for xbinutils can
>>> be swapped for the previous one, with (seemingly) no difference.
>>>
>>> - The xgcc of the original, was failing to find the headers that newlib provided.
>>> I have set the native-cross-paths as a workaround. Not sure if there is a better
>>> alternative, or if the failure was my mistake.
>>>
>>> - A package for cross GCC 6.2.0 is added, with appropriate patches for multilib
>>> support.
>>>
>>> - Newlib-arm-none-eabi and newlib-nano-arm-none-eabi have been changed to
>>> procedures, taking an xgcc as argument, so as to facilitate building with
>>> either version of gcc.
>>>
>>> - An arm-none-eabi-toolchain procedure is declared, to create toolchain packages
>>> for both gcc and newlib version. The four toolchain variables follow. Not sure
>>> if it's a mistake to include "nano" in the toolchain version.
>>
>> This all sounds reasonable to me.  Ricardo was interested in using this
>> toolchain for one specific purpose, so maybe we’ll want to check that it
>> also works here.  Ricardo: could you comment?
>
> The changes seem reasonable.  I wasn’t happy with using fixed SVN
> revisions in my patches, so I’m glad that this can be avoided.
>
> I haven’t yet found the time to apply the proposed changes, build the
> toolchain and try it with the Axoloti board.  I hope I’ll be able try on
> Sunday to first address your comments, Ludo.  Then I’ll check the
> suggested changes made by Theodoros (e.g. using different binutils and
> doing without SVN).
>
> Theodoros, I see that your patch set includes some of my patches as
> well.  The only changes I can see is the addition of the native search
> paths and parameterising newlib with xgcc, both of which I’ll add.
> After applying my modified patches I would apply your patches that add
> “arm-none-eabi-gcc-6” and the “arm-none-eabi-toolchain”.
>
> Is this acceptable?
>
> ~~ Ricardo

Yes, actually I did apply my patches on top of yours. It is perfectly
acceptable, with either version of binutils.

Regards,
-- 
Theodoros Foradis

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

* Re: [PATCH 3/3] gnu: Add newlib-nano-arm-none-eabi.
  2016-09-21  8:40   ` Ludovic Courtès
@ 2016-10-02 18:47     ` Ricardo Wurmus
  0 siblings, 0 replies; 29+ messages in thread
From: Ricardo Wurmus @ 2016-10-02 18:47 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel


Ludovic Courtès <ludo@gnu.org> writes:

> Ricardo Wurmus <rekado@elephly.net> skribis:
>
>> * gnu/packages/embedded.scm (newlib-nano-arm-none-eabi): New variable.
>
> [...]
>
>> +(define-public newlib-nano-arm-none-eabi
>> +  (package (inherit newlib-arm-none-eabi)
>> +    (name "newlib-nano")
>
> I think it should be “newlib-minimal”, no?  Or does “nano” have a
> special meaning?

The variant of newlib that targets small systems with limited memory and
other size constraints is commonly called “newlib-nano” on the mailing
lists and in other distributions.  The configure flags also mention
“nano”, as does the documentation, but there’s no separate project for
“newlib nano”.  It’s just newlib with the nano flags.

> Also, make sure to add a synopsis that mentions its minimalness, and
> maybe a comment stating what the intended use case is, or how the
> feature set was chosen.

Okay, I’ll override the synopsis.

~~ Ricardo

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

* Re: [PATCH v2 0/4] Add GCC cross compiler for arm-none-eabi.
  2016-09-29  9:24     ` Ricardo Wurmus
  2016-09-29 17:39       ` Theodoros Foradis
@ 2016-10-10 18:09       ` Theodoros Foradis
  2016-10-10 18:23         ` Ricardo Wurmus
  1 sibling, 1 reply; 29+ messages in thread
From: Theodoros Foradis @ 2016-10-10 18:09 UTC (permalink / raw)
  To: guix-devel

Hi,

I see that the original patches were applied in master. Did you check if
cross-binutils with 2.25.1 source works for your use case?

Would you like me to reformat my patches for gcc-6.2.0, so that they can
be applied on current master, or is there some other issue blocking that?

Regards,
-- 
Theodoros Foradis

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

* Re: [PATCH v2 0/4] Add GCC cross compiler for arm-none-eabi.
  2016-10-10 18:09       ` Theodoros Foradis
@ 2016-10-10 18:23         ` Ricardo Wurmus
  2016-10-11 15:50           ` theodoros.for
  2016-10-16 10:01           ` Ricardo Wurmus
  0 siblings, 2 replies; 29+ messages in thread
From: Ricardo Wurmus @ 2016-10-10 18:23 UTC (permalink / raw)
  To: Theodoros Foradis; +Cc: guix-devel


Theodoros Foradis <teoftw@gmail.com> writes:

> Hi,
>
> I see that the original patches were applied in master. Did you check if
> cross-binutils with 2.25.1 source works for your use case?

Yes, I’m using the regular cross-binutils.  Thanks for the hint!

> Would you like me to reformat my patches for gcc-6.2.0, so that they can
> be applied on current master, or is there some other issue blocking that?

No, it’s good.  I’m going to apply your patches shortly.  (Just haven’t
found the time to do so.)

~~ Ricardo

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

* Re: [PATCH v2 2/4] gnu: Add arm-none-eabi-gcc-6 and patches.
  2016-09-19 20:23   ` [PATCH v2 2/4] gnu: Add arm-none-eabi-gcc-6 and patches Theodoros Foradis
@ 2016-10-10 20:22     ` Ricardo Wurmus
  0 siblings, 0 replies; 29+ messages in thread
From: Ricardo Wurmus @ 2016-10-10 20:22 UTC (permalink / raw)
  To: Theodoros Foradis; +Cc: guix-devel


Hi Theodoros,

> * gnu/packages/embedded.scm (gcc-arm-none-eabi-6): New variable.
> * gnu/packages/patches/gcc-arm-none-eabi-multilib.patch : New file.
> * gnu/packages/patches/gcc-6-cross-environment-variables.patch : New file.

[…]

> diff --git a/gnu/packages/patches/gcc-6-arm-none-eabi-multilib.patch b/gnu/packages/patches/gcc-6-arm-none-eabi-multilib.patch
> new file mode 100644
> index 0000000..442f52b
> --- /dev/null
> +++ b/gnu/packages/patches/gcc-6-arm-none-eabi-multilib.patch
> @@ -0,0 +1,201 @@
> +From Anatol Pomozov <anatol.pomozov@gmail.com>
> +Taken from Arch Linux arm-none-eabi-gcc package.
> +
> +Modified version of ARM patch https://gcc.gnu.org/ml/gcc-patches/2012-05/msg00083/enable-with-multilib-list-for-arm.patch
> +

I’m not sure I understand what this patch does.  Could you please
provide an explanation why this patch is needed?  We usually add short
explanations to the top of each patch.

(No need to resend the patch set; I can add it myself.)

Thanks!

~~ Ricardo

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

* Re: [PATCH v2 0/4] Add GCC cross compiler for arm-none-eabi.
  2016-10-10 18:23         ` Ricardo Wurmus
@ 2016-10-11 15:50           ` theodoros.for
  2016-10-16 10:01           ` Ricardo Wurmus
  1 sibling, 0 replies; 29+ messages in thread
From: theodoros.for @ 2016-10-11 15:50 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: guix-devel

Hi Ricardo,

>> diff --git a/gnu/packages/patches/gcc-6-arm-none-eabi-multilib.patch 
>> b/gnu/packages/patches/gcc-6-arm-none-eabi-multilib.patch
>> new file mode 100644
>> index 0000000..442f52b
>> --- /dev/null
>> +++ b/gnu/packages/patches/gcc-6-arm-none-eabi-multilib.patch
>> @@ -0,0 +1,201 @@
>> +From Anatol Pomozov <anatol.pomozov@gmail.com>
>> +Taken from Arch Linux arm-none-eabi-gcc package.
>> +
>> +Modified version of ARM patch 
>> https://gcc.gnu.org/ml/gcc-patches/2012-05/msg00083/enable-with-multilib-list-for-arm.patch
>> +
> 
> I’m not sure I understand what this patch does.  Could you please
> provide an explanation why this patch is needed?  We usually add short
> explanations to the top of each patch.

This patch enables the use of --with-multilib-list flag, when
configuring gcc 6.2. It makes gcc-6 compatible with the configure-flags
of gcc-arm-none-eabi-4.9.

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

* Re: [PATCH v2 0/4] Add GCC cross compiler for arm-none-eabi.
  2016-10-10 18:23         ` Ricardo Wurmus
  2016-10-11 15:50           ` theodoros.for
@ 2016-10-16 10:01           ` Ricardo Wurmus
  2016-10-23 17:01             ` Theodoros Foradis
  1 sibling, 1 reply; 29+ messages in thread
From: Ricardo Wurmus @ 2016-10-16 10:01 UTC (permalink / raw)
  To: Theodoros Foradis; +Cc: guix-devel


Ricardo Wurmus <rekado@elephly.net> writes:

> Theodoros Foradis <teoftw@gmail.com> writes:
>
>> Hi,
>>
>> I see that the original patches were applied in master. Did you check if
>> cross-binutils with 2.25.1 source works for your use case?
>
> Yes, I’m using the regular cross-binutils.  Thanks for the hint!
>
>> Would you like me to reformat my patches for gcc-6.2.0, so that they can
>> be applied on current master, or is there some other issue blocking that?
>
> No, it’s good.  I’m going to apply your patches shortly.  (Just haven’t
> found the time to do so.)

I’m sorry for the delay, but a variant of your patches is now in master
as of 569f60164920a36e6597fe25e9373f97f89e8860.

Since my patches had changed I needed to modify your patches a little to
ensure they can be applied.  I also made a few other changes:

* I kept the newlib packages as variables, not procedures, using
  package inheritance instead to override the value of xgcc.
* The toolchain generator procedure’s name (rather than the version)
  includes “-nano” when appropriate.  The version of the toolchain
  package is just the version of xgcc.
* Added the patches to the list of patches in “gnu/local.mk”

I successfully built the cross-compiler based on GCC 6 after these
changes, so everything should work as intended.

Thanks again for your contributions!

~~ Ricardo

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

* Re: [PATCH v2 0/4] Add GCC cross compiler for arm-none-eabi.
  2016-10-16 10:01           ` Ricardo Wurmus
@ 2016-10-23 17:01             ` Theodoros Foradis
  2016-11-26  8:55               ` Ricardo Wurmus
  0 siblings, 1 reply; 29+ messages in thread
From: Theodoros Foradis @ 2016-10-23 17:01 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: guix-devel

On 2016-10-16 13:01, Ricardo Wurmus wrote:
> Ricardo Wurmus <rekado@elephly.net> writes:
> 
>> Theodoros Foradis <teoftw@gmail.com> writes:
>> 
>>> Hi,
>>> 
>>> I see that the original patches were applied in master. Did you check 
>>> if
>>> cross-binutils with 2.25.1 source works for your use case?
>> 
>> Yes, I’m using the regular cross-binutils.  Thanks for the hint!
>> 
>>> Would you like me to reformat my patches for gcc-6.2.0, so that they 
>>> can
>>> be applied on current master, or is there some other issue blocking 
>>> that?
>> 
>> No, it’s good.  I’m going to apply your patches shortly.  (Just 
>> haven’t
>> found the time to do so.)
> 
> I’m sorry for the delay, but a variant of your patches is now in master
> as of 569f60164920a36e6597fe25e9373f97f89e8860.
> 
> Since my patches had changed I needed to modify your patches a little 
> to
> ensure they can be applied.  I also made a few other changes:
> 
> * I kept the newlib packages as variables, not procedures, using
>   package inheritance instead to override the value of xgcc.
> * The toolchain generator procedure’s name (rather than the version)
>   includes “-nano” when appropriate.  The version of the toolchain
>   package is just the version of xgcc.
> * Added the patches to the list of patches in “gnu/local.mk”
> 
> I successfully built the cross-compiler based on GCC 6 after these
> changes, so everything should work as intended.
> 
> Thanks again for your contributions!
> 
> ~~ Ricardo

Thanks for modifying the patches. I have tested the resulting toolchains
and they work fine.

The one issue I have observed is that newlib (and newlib-nano), is not
provided as a substitute, when installed with a toolchain containing
xgcc-6. I think that only the original newlib derivations are being
built on hydra (the ones using xgcc-4.9 as their input). How could we
get around that, so that they don't have to be built locally every time?
-- 
Theodoros Foradis

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

* Re: [PATCH v2 0/4] Add GCC cross compiler for arm-none-eabi.
  2016-10-23 17:01             ` Theodoros Foradis
@ 2016-11-26  8:55               ` Ricardo Wurmus
  0 siblings, 0 replies; 29+ messages in thread
From: Ricardo Wurmus @ 2016-11-26  8:55 UTC (permalink / raw)
  To: Theodoros Foradis; +Cc: guix-devel


Theodoros Foradis <theodoros.for@openmailbox.org> writes:

> The one issue I have observed is that newlib (and newlib-nano), is not
> provided as a substitute, when installed with a toolchain containing
> xgcc-6. I think that only the original newlib derivations are being
> built on hydra (the ones using xgcc-4.9 as their input). How could we
> get around that, so that they don't have to be built locally every time?

I cannot reproduce this.  When installing the toolchain for 6.2 I also
get newlib, which contains a reference to the cross compiler in version
6.2.  Maybe this was just a temporary problem with hydra.

-- 
Ricardo

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

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

end of thread, other threads:[~2016-11-26  8:55 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-18  6:35 [PATCH 0/3] Add GCC cross compiler for arm-none-eabi Ricardo Wurmus
2016-09-18  6:35 ` [PATCH 1/3] gnu: Add arm-none-eabi cross compiler Ricardo Wurmus
2016-09-21  8:34   ` Ludovic Courtès
2016-09-18  6:35 ` [PATCH 2/3] gnu: Add newlib-arm-none-eabi Ricardo Wurmus
2016-09-21  8:38   ` Ludovic Courtès
2016-09-18  6:35 ` [PATCH 3/3] gnu: Add newlib-nano-arm-none-eabi Ricardo Wurmus
2016-09-21  8:40   ` Ludovic Courtès
2016-10-02 18:47     ` Ricardo Wurmus
2016-09-19 20:23 ` [PATCH v2 0/4] Add GCC cross compiler for arm-none-eabi Theodoros Foradis
2016-09-19 20:23   ` [PATCH v2 1/4] gnu: Add arm-none-eabi cross compiler Theodoros Foradis
2016-09-19 20:23   ` [PATCH v2 2/4] gnu: Add arm-none-eabi-gcc-6 and patches Theodoros Foradis
2016-10-10 20:22     ` Ricardo Wurmus
2016-09-19 20:23   ` [PATCH v2 3/4] gnu: Add newlib-arm-none-eabi Theodoros Foradis
2016-09-19 20:23   ` [PATCH v2 4/4] gnu: Add arm-none-eabi-toolchain Theodoros Foradis
2016-09-27  9:03   ` [PATCH v2 0/4] Add GCC cross compiler for arm-none-eabi Ludovic Courtès
2016-09-29  9:24     ` Ricardo Wurmus
2016-09-29 17:39       ` Theodoros Foradis
2016-10-10 18:09       ` Theodoros Foradis
2016-10-10 18:23         ` Ricardo Wurmus
2016-10-11 15:50           ` theodoros.for
2016-10-16 10:01           ` Ricardo Wurmus
2016-10-23 17:01             ` Theodoros Foradis
2016-11-26  8:55               ` Ricardo Wurmus
2016-09-20 10:50 ` [PATCH v2 0/1] " Theodoros Foradis
2016-09-20 10:50   ` [PATCH v2 1/4] gnu: Add arm-none-eabi cross compiler Theodoros Foradis
2016-09-20 10:50   ` [PATCH v2 2/4] gnu: Add arm-none-eabi-gcc-6 and patches Theodoros Foradis
2016-09-20 10:50   ` [PATCH v2 3/4] gnu: Add newlib-arm-none-eabi Theodoros Foradis
2016-09-20 10:50   ` [PATCH v2 4/4] gnu: Add arm-none-eabi-toolchain Theodoros Foradis
2016-09-21  8:30 ` [PATCH 0/3] Add GCC cross compiler for arm-none-eabi Ludovic Courtès

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.