diff mbox series

[bug#73277,1/2] gnu: Add mipsel-none-elf-toolchain variant.

Message ID 7c35f8694833a9371d84c51ce4a07119358e187e.1726426231.git.manolis837@gmail.com
State New
Headers show
Series [bug#73277,1/2] gnu: Add mipsel-none-elf-toolchain variant. | expand

Commit Message

Manolis Ragkousis Sept. 15, 2024, 7:03 p.m. UTC
From: Manolis Ragkousis <manolis837@gmail.com>

* gnu/packages/embedded.scm (make-mipsel-none-elf-toolchain-ps1): New procedure.
  (make-gcc-mipsel-none-elf, make-mipsel-none-elf-toolchain): New variables.

Change-Id: I8d4e1f5601bf255703750f95862d9427013e38e7
---
 gnu/packages/embedded.scm | 86 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 85 insertions(+), 1 deletion(-)


base-commit: 61b6c7ceb1e2c3baf9cdfbd05e6ad4f6d2dc2a3c
diff mbox series

Patch

diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
index bee65663b6..8779cc5e71 100644
--- a/gnu/packages/embedded.scm
+++ b/gnu/packages/embedded.scm
@@ -13,6 +13,7 @@ 
 ;;; Copyright © 2022 Mathieu Othacehe <othacehe@gnu.org>
 ;;; Copyright © 2022, 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;; Copyright © 2023 Janneke Nieuwenhuizen <janneke@gnu.org>
+;;; Copyright © 2024 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -101,7 +102,9 @@  (define-module (gnu packages embedded)
             make-propeller-gcc-4
             make-propeller-gcc-6
             make-propeller-toolchain
-            make-propeller-development-suite))
+            make-propeller-development-suite
+
+            make-mipsel-none-elf-toolchain-ps1))
 
 ;;; Commentary:
 ;;;
@@ -1859,3 +1862,84 @@  (define-public ts4900-utils
 @item tssilomon
 @end itemize")
       (license license:bsd-2))))
+
+(define make-gcc-mipsel-none-elf
+  (mlambda ()
+    (let ((xgcc (cross-gcc "mipsel-none-elf"
+                           #:xgcc gcc
+                           #:xbinutils (cross-binutils "mipsel-none-elf"))))
+      (package
+        (inherit xgcc)
+        (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")))))
+                (add-after 'unpack 'fix-genmultilib
+                  (lambda _
+                    (substitute* "gcc/genmultilib"
+                      (("#!/bin/sh") (string-append "#!" (which "sh"))))))))
+           ((#:configure-flags flags)
+            #~(append (list "--target=mipsel-none-elf"
+                            "--disable-docs"
+                            "--disable-nls"
+                            "--disable-werror"
+                            "--disable-libada"
+                            "--disable-libssp"
+                            "--disable-libquadmath"
+                            "--disable-threads"
+                            "--disable-libgomp"
+                            "--disable-libstdcxx-pch"
+                            "--disable-hosted-libstdcxx"
+                            "--enable-languages=c,c++"
+                            "--without-isl"
+                            "--without-headers"
+                            "--with-float=soft"
+                            "--with-gnu-as"
+                            "--with-gnu-ld")
+                      #$flags))))))))
+
+(define make-mipsel-none-elf-toolchain
+  (mlambda (xgcc)
+    "Produce a cross-compiler toolchain package with the compiler XGCC."
+    (let ()
+      (package
+        (name "mipsel-none-elf-toolchain")
+        (version (package-version xgcc))
+        (source #f)
+        (build-system trivial-build-system)
+        (arguments
+         '(#:modules ((guix build union))
+           #:builder
+           (begin
+             (use-modules (ice-9 match)
+                          (guix build union))
+             (match %build-inputs
+               (((names . directories) ...)
+                (union-build (assoc-ref %outputs "out")
+                             directories))))))
+        (propagated-inputs
+         `(("binutils" ,(cross-binutils "mipsel-none-elf"))
+           ("gcc" ,xgcc)))
+        (synopsis "")
+        (description "")
+        (home-page (package-home-page xgcc))
+        (license (package-license xgcc))))))
+
+(define make-mipsel-none-elf-toolchain-ps1
+  (mlambda () 
+    (make-mipsel-none-elf-toolchain (make-gcc-mipsel-none-elf))))