~ruther/guix-exprs

b88f695d769b60a57a4e5d8b5b91d60ed869a928 — Rutherther 6 months ago e884308
fix: missing new functions for arm none eabi toolchain
1 files changed, 107 insertions(+), 0 deletions(-)

M ruther/packages/embedded.scm
M ruther/packages/embedded.scm => ruther/packages/embedded.scm +107 -0
@@ 11,6 11,8 @@
  #:use-module (gnu packages flex)
  #:use-module (gnu packages cross-base)
  #:use-module (gnu packages texinfo)
  #:use-module (guix build-system gnu)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix build utils)
  #:use-module (gnu packages gcc)



@@ 20,6 22,111 @@
            arm-none-eabi-nano-toolchain-12.3.rel1
            arm-none-eabi-toolchain-12.3.rel1))

(define make-newlib-arm-none-eabi
  (mlambda ()
    (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
         ;; The configure flags are identical to the flags used by the "GCC ARM
         ;; embedded" project.
         #: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-references-to-/bin/sh
             (lambda _
               (substitute* (find-files "libgloss" "^Makefile\\.in$")
                 (("/bin/sh") (which "sh")))
               #t)))))
      (native-inputs
       `(("xbinutils" ,(cross-binutils "arm-none-eabi"))
         ("xgcc" ,(make-gcc-arm-none-eabi-4.9))
         ("texinfo" ,texinfo)))
      (home-page "https://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 make-newlib-nano-arm-none-eabi
  (mlambda ()
    (let ((base (make-newlib-arm-none-eabi)))
      (package
        (inherit base)
        (name "newlib-nano")
        (arguments
         (substitute-keyword-arguments (package-arguments base)
           ;; The configure flags are identical to the flags used by the "GCC
           ;; ARM embedded" project.  They optimize newlib for use on small
           ;; embedded systems with limited memory.
           ((#:configure-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"))
           ((#:phases phases)
            `(modify-phases ,phases
               ;; XXX: Most arm toolchains offer both *.a and *_nano.a as
               ;; newlib and newlib-nano respectively.  The headers are
               ;; usually arm-none-eabi/include/newlib.h for newlib and
               ;; arm-none-eabi/include/newlib-nano/newlib.h for newlib-nano.
               ;; We have two different toolchain packages for each which
               ;; works but is a little strange.
               (add-after 'install 'hardlink-newlib
                 (lambda* (#:key outputs #:allow-other-keys)
                   (let ((out (assoc-ref outputs "out")))
                     ;; The nano.specs file says that newlib-nano files should
                     ;; end in "_nano.a" instead of just ".a".  Note that this
                     ;; applies to all the multilib folders too.
                     (for-each
                      (lambda (file)
                        (link file
                              (string-append
                               ;; Strip ".a" off the end
                               (substring file 0 (- (string-length file) 2))
                               ;; Add "_nano.a" onto the end
                               "_nano.a")))
                      (find-files
                       out
                       "^(libc.a|libg.a|librdimon.a|libstdc\\+\\+.a|\
libsupc\\+\\+.a)$"))

                     ;; newlib.h is usually in this location instead so both
                     ;; newlib and newlib-nano can be in the toolchain at the
                     ;; same time
                     (mkdir (string-append
                             out "/arm-none-eabi/include/newlib-nano"))
                     (symlink
                      "../newlib.h"
                      (string-append
                       out
                       "/arm-none-eabi/include/newlib-nano/newlib.h")))))))))
        (synopsis "Newlib variant for small systems with limited memory")))))

(define make-base-newlib-arm-none-eabi-7-2018-q2-update
  ;; This is the same commit as used for the 7-2018-q2-update release
  ;; according to the release.txt.

Do not follow this link