diff mbox series

[bug#48767,2/6] gnu: Add gcc-msp430.

Message ID SN6PR05MB4031E5913CC5D130D8F4B056C5A69@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 (gcc-msp430): New variable.
---
 gnu/packages/bootstrap.scm |  1 +
 gnu/packages/embedded.scm  | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+)

Comments

M Sept. 26, 2021, 3:51 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 (gcc-msp430): New variable.
> ---
>  gnu/packages/bootstrap.scm |  1 +
>  gnu/packages/embedded.scm  | 33 +++++++++++++++++++++++++++++++++
>  2 files changed, 34 insertions(+)
> 
> diff --git a/gnu/packages/bootstrap.scm b/gnu/packages/bootstrap.scm
> index c598cedc0a..54a028e977 100644
> --- a/gnu/packages/bootstrap.scm
> +++ b/gnu/packages/bootstrap.scm
> @@ -311,6 +311,7 @@ or false to signal an error."
>          ((string=? system "arm-eabi") "no-ld.so")
>          ((string=? system "xtensa-elf") "no-ld.so")
>          ((string=? system "avr") "no-ld.so")
> +        ((string=? system "msp430-elf") "no-ld.so")
>          ((string=? system "propeller-elf") "no-ld.so")
>          ((string=? system "i686-mingw") "no-ld.so")
>          ((string=? system "x86_64-mingw") "no-ld.so")
> diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
> index f1f17e83a7..7073168b57 100644
> --- a/gnu/packages/embedded.scm
> +++ b/gnu/packages/embedded.scm
> @@ -530,6 +530,39 @@ languages are C and C++.")
>       `(("unzip" ,unzip)))
>      (license license:bsd-3)))
>  
> +(define-public gcc-msp430
> +  (let ((xgcc (cross-gcc "msp430-elf"
> +                         #:xgcc gcc-9
> +                         #:xbinutils (cross-binutils "msp430-elf"))))
> +    (package
> +      (inherit xgcc)
> +      (name "gcc-msp430")
> +      (arguments
> +       (substitute-keyword-arguments (package-arguments xgcc)
> +         ((#:phases phases)
> +          `(modify-phases ,phases
> +             (add-after 'set-paths 'augment-CPLUS_INCLUDE_PATH
> +               (lambda* (#:key inputs #:allow-other-keys)
> +                 (let ((gcc (assoc-ref inputs  "gcc")))
> +                   ;; Remove the default compiler from CPLUS_INCLUDE_PATH to
> +                   ;; prevent header conflict with the GCC from native-inputs.
> +                   (setenv "CPLUS_INCLUDE_PATH"
> +                           (string-join
> +                            (delete (string-append gcc "/include/c++")
> +                                    (string-split (getenv "CPLUS_INCLUDE_PATH")
> +                                                  #\:))
> +                            ":"))
> +                   (format #t
> +                           "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
> +                           (getenv "CPLUS_INCLUDE_PATH")))))))))
> +      (native-search-paths

Shouldn't these be 'search-paths' instead of 'native-search-paths',
as "gcc-msp430" is a cross-compiler?  (I know other GCC cross-compiler
packages in (gnu packages embedded) are using native-search-paths as well,
but I don't understand why.)

> +       (list (search-path-specification
> +              (variable "CROSS_C_INCLUDE_PATH")
> +              (files '("msp430-elf/include")))
> +             (search-path-specification
> +              (variable "CROSS_LIBRARY_PATH")
> +              (files '("msp430-elf/lib"))))))))

Greetings,
Maxime.
diff mbox series

Patch

diff --git a/gnu/packages/bootstrap.scm b/gnu/packages/bootstrap.scm
index c598cedc0a..54a028e977 100644
--- a/gnu/packages/bootstrap.scm
+++ b/gnu/packages/bootstrap.scm
@@ -311,6 +311,7 @@  or false to signal an error."
         ((string=? system "arm-eabi") "no-ld.so")
         ((string=? system "xtensa-elf") "no-ld.so")
         ((string=? system "avr") "no-ld.so")
+        ((string=? system "msp430-elf") "no-ld.so")
         ((string=? system "propeller-elf") "no-ld.so")
         ((string=? system "i686-mingw") "no-ld.so")
         ((string=? system "x86_64-mingw") "no-ld.so")
diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
index f1f17e83a7..7073168b57 100644
--- a/gnu/packages/embedded.scm
+++ b/gnu/packages/embedded.scm
@@ -530,6 +530,39 @@  languages are C and C++.")
      `(("unzip" ,unzip)))
     (license license:bsd-3)))
 
+(define-public gcc-msp430
+  (let ((xgcc (cross-gcc "msp430-elf"
+                         #:xgcc gcc-9
+                         #:xbinutils (cross-binutils "msp430-elf"))))
+    (package
+      (inherit xgcc)
+      (name "gcc-msp430")
+      (arguments
+       (substitute-keyword-arguments (package-arguments xgcc)
+         ((#:phases phases)
+          `(modify-phases ,phases
+             (add-after 'set-paths 'augment-CPLUS_INCLUDE_PATH
+               (lambda* (#:key inputs #:allow-other-keys)
+                 (let ((gcc (assoc-ref inputs  "gcc")))
+                   ;; Remove the default compiler from CPLUS_INCLUDE_PATH to
+                   ;; prevent header conflict with the GCC from native-inputs.
+                   (setenv "CPLUS_INCLUDE_PATH"
+                           (string-join
+                            (delete (string-append gcc "/include/c++")
+                                    (string-split (getenv "CPLUS_INCLUDE_PATH")
+                                                  #\:))
+                            ":"))
+                   (format #t
+                           "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
+                           (getenv "CPLUS_INCLUDE_PATH")))))))))
+      (native-search-paths
+       (list (search-path-specification
+              (variable "CROSS_C_INCLUDE_PATH")
+              (files '("msp430-elf/include")))
+             (search-path-specification
+              (variable "CROSS_LIBRARY_PATH")
+              (files '("msp430-elf/lib"))))))))
+
 (define-public libjaylink
   (package
     (name "libjaylink")