diff mbox series

[bug#48767,3/6] gnu: Add newlib-msp430.

Message ID SN6PR05MB40312BC5DD6C91D909E7C1E0C5A69@SN6PR05MB4031.namprd05.prod.outlook.com
State New
Headers show
Series [bug#48767,1/6] gnu: Add gcc-msp430-support-files. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Morgan Smith Sept. 26, 2021, 2:51 p.m. UTC
From: Morgan Smith <Morgan.J.Smith@outlook.com>

* gnu/packages/embedded.scm (newlib-msp430): New variable.
---
 gnu/packages/embedded.scm | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

Comments

M Sept. 26, 2021, 4:04 p.m. UTC | #1
Morgan.J.Smith@outlook.com schreef op zo 26-09-2021 om 10:51 [-0400]:
> From: Morgan Smith <Morgan.J.Smith@outlook.com>
> 
> * gnu/packages/embedded.scm (newlib-msp430): New variable.
> ---
>  gnu/packages/embedded.scm | 35 +++++++++++++++++++++++++++++++++++
>  1 file changed, 35 insertions(+)
> 
> diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
> index 7073168b57..49f3eda5fb 100644
> --- a/gnu/packages/embedded.scm
> +++ b/gnu/packages/embedded.scm
> @@ -563,6 +563,41 @@ languages are C and C++.")
>                (variable "CROSS_LIBRARY_PATH")
>                (files '("msp430-elf/lib"))))))))
>  
> +(define-public newlib-msp430
> +  (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)

There already is a newlib package: newlib-arm-none-eabi.
Could you use (package (inherit "newlib-msp430") ...) to reduce duplication?
Also, could you
  
   (a) change the name to, say, "newlib-msp430"
or (b) instead of defining a new "newlib" package, keep a single newlib package
and make the architecture-dependent tweaks depend on (%current-target-system)?

such that "newlib@2.4.0" is an unambigious specification (or, at least, not
more ambigious than it was before), usable for "specification->package"?

> +    (arguments
> +     `(#:out-of-source? #t
> +       #:phases
> +       (modify-phases %standard-phases
> +         (add-after 'unpack 'fix-references-to-/bin/sh
> +           (lambda _
> +             (substitute* '("libgloss/msp430/Makefile.in"
> +                            "libgloss/libnosys/Makefile.in"
> +                            "libgloss/Makefile.in")
> +               (("/bin/sh") (which "sh"))))))

This duplication can be removed by inheriting from 'newlib-arm-none-eabi'.

> +       #:configure-flags '("--target=msp430-elf")))

I'd suggest adding #:target "msp430-elf" to 'arguments' instead
of setting #:configure-flags directly.  That way, guix knows we are
cross-compiling and won't try to run tests and won't try to
run 'ldconfig'.

Greetings,
Maxime.
diff mbox series

Patch

diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
index 7073168b57..49f3eda5fb 100644
--- a/gnu/packages/embedded.scm
+++ b/gnu/packages/embedded.scm
@@ -563,6 +563,41 @@  languages are C and C++.")
               (variable "CROSS_LIBRARY_PATH")
               (files '("msp430-elf/lib"))))))))
 
+(define-public newlib-msp430
+  (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
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'fix-references-to-/bin/sh
+           (lambda _
+             (substitute* '("libgloss/msp430/Makefile.in"
+                            "libgloss/libnosys/Makefile.in"
+                            "libgloss/Makefile.in")
+               (("/bin/sh") (which "sh"))))))
+       #:configure-flags '("--target=msp430-elf")))
+    (native-inputs
+     `(("xbinutils" ,(cross-binutils "msp430-elf"))
+       ("xgcc" ,gcc-msp430)
+       ("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-public libjaylink
   (package
     (name "libjaylink")