GNU bug report logs - #73277
[PATCH 1/2] gnu: Add mipsel-none-elf-toolchain variant.

Previous Next

Package: guix-patches;

Reported by: manolis837 <at> gmail.com

Date: Sun, 15 Sep 2024 19:04:02 UTC

Severity: normal

Tags: patch

To reply to this bug, email your comments to 73277 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#73277; Package guix-patches. (Sun, 15 Sep 2024 19:04:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to manolis837 <at> gmail.com:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Sun, 15 Sep 2024 19:04:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: manolis837 <at> gmail.com
To: guix-patches <at> gnu.org
Cc: Manolis Ragkousis <manolis837 <at> gmail.com>
Subject: [PATCH 1/2] gnu: Add mipsel-none-elf-toolchain variant.
Date: Sun, 15 Sep 2024 22:03:30 +0300
From: Manolis Ragkousis <manolis837 <at> 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(-)

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 <at> gnu.org>
 ;;; Copyright © 2022, 2023 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
 ;;; Copyright © 2023 Janneke Nieuwenhuizen <janneke <at> gnu.org>
+;;; Copyright © 2024 Manolis Fragkiskos Ragkousis <manolis837 <at> 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))))

base-commit: 61b6c7ceb1e2c3baf9cdfbd05e6ad4f6d2dc2a3c
-- 
2.46.0





Information forwarded to guix-patches <at> gnu.org:
bug#73277; Package guix-patches. (Mon, 16 Sep 2024 12:02:02 GMT) Full text and rfc822 format available.

Message #8 received at 73277 <at> debbugs.gnu.org (full text, mbox):

From: Jean-Pierre De Jesus Diaz <jean <at> foundation.xyz>
To: 73277 <at> debbugs.gnu.org
Cc: manolis837 <at> gmail.com
Subject: Re: [PATCH 1/2] gnu: Add mipsel-none-elf-toolchain variant.
Date: Mon, 16 Sep 2024 12:00:17 +0000
Hello,

Just letting you know that using `cross-gcc-toolchain` is preferred
and since the usage
is to provide a PS1 SDK I think you can add this to the list of bare
metal targets in Guix.

See `guix build --list-targets', for example it contains avr,
xtensa-ath9k-elf and or1k-elf.

This can be done by adding a variable to:

- `guix/platforms/mips.scm'

So, this should allow to add this target as an argument to your
`psn00bsdk' package:

For example:

(arguments
  (list #:target "mipsel-none-elf"
        ...))

And the build system will:

1. Automayically add the cross-gcc compiler.
2. Will also cross-compile inputs (excluding native-inputs, of course).

So that will allow you to unbundle the dependencies as you could just build
each one independently for that target (or for all ones, if the
library supports it).

With this though you'll probably need to create a separate package for
the tools and
one for the code that runs on the PS1 itself.

You can take inspiration from the existing bare-metal targets and
packages compiled
like this (which are few), there is firmware on
`gnu/packages/firmware.scm' that does
this.  Also the QMK firmware for keyboards use the Guix
cross-compilation mechanism
too.

Additionally, you can provide the toolchain as a package on the
`gnu/package/cross-toolchain.scm` module.




This bug report was last modified 276 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.