all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Mitchell Schmeisser via Guix-patches via <guix-patches@gnu.org>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: 61765@debbugs.gnu.org
Subject: [bug#61765] custom toolchain blog post
Date: Mon, 13 Mar 2023 09:52:32 -0400	[thread overview]
Message-ID: <e0a66bab-2bca-cbd2-2e3b-c893c0391a1d@librem.one> (raw)
In-Reply-To: <87zg8jwkqc.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 3523 bytes --]

Here are two patches with minor fixes.

Sorry about the code formatting... Does anyone have any tips for getting 
emacs to format scheme code in markdown?


Thanks,

Mitchell


On 3/11/23 07:11, Ludovic Courtès wrote:
> Hi Mitchel,
>
> (Please keep the issue Cc’d.)
>
> Apologies for the delay!
>
> Mitchell Schmeisser <mitchellschmeisser@librem.one> skribis:
>
>>> One thing that’s not clear to me: with this in place, can you do “guix
>>> build --target=arm-zephyr-eabi hello”, for instance?  If not, what’s
>>> missing to support it?
>> You cannot. I do not know how to describe it in a succinct way but
>> suffice to say the applications need to know they are targeting Zephyr
>> when they are written. The application will include a `prj.conf` which
>> is analogous to a custom defconfig in the Linux kernel.
>> Either in this file, or somewhere in the CMakeLists.txt a `BOARD`
>> variable is set to specify a specific board definition.
>> These board definitions contain information about the architecture and
>> the CMake scripts themselves pick the toolchain.
>>
>> It's not that it's impossible to implement something like `guix build
>> --target=arm-zephyr-eabi k64f-hello-world` but the k64f-hello-world
>> would be written in such a way that the target is implicit in the
>> package.
> OK.  To put it differently, a typical POSIX program won’t work on
> Zephyr; programs have to target the Zephyr interfaces, right?
>
>> The way I envision the `--target/system` flags being used in this
>> context is `guix build --target=arm-linux-gnueabihf k64f-hello-world`
>> which will still produce the correct firmware but will allow the
>> firmware to be staged to another machine which will be responsible for
>> the final deployment over some transport.
> Or rather:
>
>    guix build --target=arm-zephyr-eabi k64f-hello-world
>
> ?
>
>>> I wonder if it would be worth mentioning
>>> <https://guix.gnu.org/manual/en/html_node/Platforms.html> too, and how
>>> one would go about adding a  module.  WDYT?
>> I considered trying to add Zephyr platforms but I'm not sure it's worth
>> the effort.
>> In addition to the patch to the website I attached another post(in org)
>> which describes how I integrated this toolchain into the Guix
>> infrastructure to allow defining firmware packages.
>> Maybe there will be additional information in there which can help you
>> understand where I'm going with all of this.
>>
>> There will be a part 3 (and possibly more) about how to practically use
>> this stuff in a real project.
> Woow.  :-)
>
>>  From 0920ec7d951354c94c3da277d58e54b587522622 Mon Sep 17 00:00:00 2001
>> From: Mitchell Schmeisser <mitchellschmeisser@librem.one>
>> Date: Mon, 27 Feb 2023 10:20:32 -0500
>> Subject: [PATCH] website: Add toolchain blog post
>>
>> website/blog/custom-toolchains-with-guix.md: New file
> I pushed it under the drafts directory for now, to leave others a bit
> more time to comment before we publish.  I followed up with a commit
> editing things a bit, mostly fixing typographical issues,
> spelling/capitalization, code formatting, and removing tabs.
>
>    https://git.savannah.gnu.org/cgit/guix/guix-artwork.git/tree/website/drafts/custom-toolchains-with-guix.md
>
> (BTW, I made slight modifications to some of the code snippets to!  One
> package was using (append (list …) (package-native-inputs …)), which
> really works “by chance” I guess; you should use ‘modify-inputs’
> instead.)
>
> Let me know if anything’s amiss!
>
> Thanks,
> Ludo’.

[-- Attachment #2: 0001-website-custom-toolchains-with-guix-Code-fix.patch --]
[-- Type: text/x-patch, Size: 8351 bytes --]

From 0f6c28345a51e20004bc16b73bda1c0e5ccb7f4c Mon Sep 17 00:00:00 2001
From: Mitchell Schmeisser <mitchellschmeisser@librem.one>
Date: Mon, 13 Mar 2023 09:36:36 -0400
Subject: [PATCH 1/2] website: custom-toolchains-with-guix: Code fix

* website/drafts/custom-toolchains-with-guix.md: Removed unnecessary
native-inputs from gcc-arm-zephyr-eabi-toolchain code block.
---
 website/drafts/custom-toolchains-with-guix.md | 176 +++++++++---------
 1 file changed, 84 insertions(+), 92 deletions(-)

diff --git a/website/drafts/custom-toolchains-with-guix.md b/website/drafts/custom-toolchains-with-guix.md
index cbc491f..fb491c6 100644
--- a/website/drafts/custom-toolchains-with-guix.md
+++ b/website/drafts/custom-toolchains-with-guix.md
@@ -195,98 +195,90 @@ commits to use for each of the tools).
 ```scheme
 (define-public gcc-arm-zephyr-eabi-12
   (let ((xgcc (cross-gcc "arm-zephyr-eabi"
-                         #:xbinutils zephyr-binutils)))
-    (package
-      (inherit xgcc)
-      (version "12.1.0")
-      (source (origin
-                (method git-fetch)
-                (uri (git-reference
-                      (url "https://github.com/zephyrproject-rtos/gcc")
-                      (commit "0218469df050c33479a1d5be3e5239ac0eb351bf")))
-                (file-name (git-file-name (package-name xgcc) version))
-                (sha256
-                 (base32
-                  "1s409qmidlvzaw1ns6jaanigh3azcxisjplzwn7j2n3s33b76zjk"))
-                (patches (search-patches
-                          "gcc-12-cross-environment-variables.patch"
-                          "gcc-cross-gxx-include-dir.patch"))))
-      (native-inputs (modify-inputs (package-native-inputs xgcc)
-                       ;; Get rid of stock ISL
-                       (delete "isl")
-                       ;; Add additional dependencies that xgcc doesn't have
-                       ;; including our special ISL
-                       (prepend flex
-                                perl
-                                python-3
-                                gmp
-                                isl-0.15
-                                texinfo
-                                python
-                                mpc
-                                mpfr
-                                zlib)))
-      (arguments
-       (substitute-keyword-arguments (package-arguments xgcc)
-         ((#:phases phases)
-          `(modify-phases ,phases
-             (add-after 'unpack 'fix-genmultilib
-               (lambda _
-                 (patch-shebang "gcc/genmultilib")))
-
-             (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")))))))
-
-         ((#:configure-flags flags)
-          ;; The configure flags are largely identical to the flags used by the
-          ;; "GCC ARM embedded" project.
-          `(append (list
-                    "--enable-multilib"
-                    "--with-newlib"
-                    "--with-multilib-list=rmprofile"
-                    "--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm"
-                    "--enable-plugins"
-                    "--disable-decimal-float"
-                    "--disable-libffi"
-                    "--disable-libgomp"
-                    "--disable-libmudflap"
-                    "--disable-libquadmath"
-                    "--disable-libssp"
-                    "--disable-libstdcxx-pch"
-                    "--disable-nls"
-                    "--disable-shared"
-                    "--disable-threads"
-                    "--disable-tls"
-                    "--with-gnu-ld"
-                    "--with-gnu-as"
-                    "--enable-initfini-array")
-                   (delete "--disable-multilib"
-                           ,flags)))))
-      (native-search-paths
-       (list (search-path-specification
-              (variable "CROSS_C_INCLUDE_PATH")
-              (files '("arm-zephyr-eabi/include")))
-             (search-path-specification
-              (variable "CROSS_CPLUS_INCLUDE_PATH")
-              (files '("arm-zephyr-eabi/include" "arm-zephyr-eabi/c++"
-                       "arm-zephyr-eabi/c++/arm-zephyr-eabi")))
-             (search-path-specification
-              (variable "CROSS_LIBRARY_PATH")
-              (files '("arm-zephyr-eabi/lib")))))
-      (home-page "https://zephyrproject.org")
-      (synopsis "GCC for the Zephyr RTOS"))))
+						 #:xbinutils zephyr-binutils)))
+	(package
+	  (inherit xgcc)
+	  (version "12.1.0")
+	  (source (origin
+				(method git-fetch)
+				(uri (git-reference
+					  (url "https://github.com/zephyrproject-rtos/gcc")
+					  (commit "0218469df050c33479a1d5be3e5239ac0eb351bf")))
+				(file-name (git-file-name (package-name xgcc) version))
+				(sha256
+				 (base32
+				  "1s409qmidlvzaw1ns6jaanigh3azcxisjplzwn7j2n3s33b76zjk"))
+				(patches (search-patches
+						  "gcc-12-cross-environment-variables.patch"
+						  "gcc-cross-gxx-include-dir.patch"))))
+	  (native-inputs (modify-inputs (package-native-inputs xgcc)
+					   ;; Get rid of stock ISL
+					   (delete "isl")
+					   ;; Add additional dependencies that xgcc doesn't have
+					   ;; including our special ISL
+					   (prepend flex
+								isl-0.15)))
+	  (arguments
+	   (substitute-keyword-arguments (package-arguments xgcc)
+		 ((#:phases phases)
+		  `(modify-phases ,phases
+			 (add-after 'unpack 'fix-genmultilib
+			   (lambda _
+				 (patch-shebang "gcc/genmultilib")))
+
+			 (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")))))))
+
+		 ((#:configure-flags flags)
+		  ;; The configure flags are largely identical to the flags used by the
+		  ;; "GCC ARM embedded" project.
+		  `(append (list
+					"--enable-multilib"
+					"--with-newlib"
+					"--with-multilib-list=rmprofile"
+					"--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm"
+					"--enable-plugins"
+					"--disable-decimal-float"
+					"--disable-libffi"
+					"--disable-libgomp"
+					"--disable-libmudflap"
+					"--disable-libquadmath"
+					"--disable-libssp"
+					"--disable-libstdcxx-pch"
+					"--disable-nls"
+					"--disable-shared"
+					"--disable-threads"
+					"--disable-tls"
+					"--with-gnu-ld"
+					"--with-gnu-as"
+					"--enable-initfini-array")
+				   (delete "--disable-multilib"
+						   ,flags)))))
+	  (native-search-paths
+	   (list (search-path-specification
+			  (variable "CROSS_C_INCLUDE_PATH")
+			  (files '("arm-zephyr-eabi/include")))
+			 (search-path-specification
+			  (variable "CROSS_CPLUS_INCLUDE_PATH")
+			  (files '("arm-zephyr-eabi/include" "arm-zephyr-eabi/c++"
+					   "arm-zephyr-eabi/c++/arm-zephyr-eabi")))
+			 (search-path-specification
+			  (variable "CROSS_LIBRARY_PATH")
+			  (files '("arm-zephyr-eabi/lib")))))
+	  (home-page "https://zephyrproject.org")
+	  (synopsis "GCC for the Zephyr RTOS"))))
 ```
 
 This GCC can be built like so.
-- 
2.39.1


[-- Attachment #3: 0002-website-custom-toolchains-with-guix-Update-reference.patch --]
[-- Type: text/x-patch, Size: 1412 bytes --]

From 25a65c6ace2a3df43d6c3c6d6e23062a51419025 Mon Sep 17 00:00:00 2001
From: Mitchell Schmeisser <mitchellschmeisser@librem.one>
Date: Mon, 13 Mar 2023 09:39:22 -0400
Subject: [PATCH 2/2] website: custom-toolchains-with-guix: Update reference
 URL

* website/drafts/custom-toolchains-with-guix.md: Changed url from
"latest" to 3.1 which was the current version at the time of writting.
---
 website/drafts/custom-toolchains-with-guix.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/website/drafts/custom-toolchains-with-guix.md b/website/drafts/custom-toolchains-with-guix.md
index fb491c6..ffc3b1a 100644
--- a/website/drafts/custom-toolchains-with-guix.md
+++ b/website/drafts/custom-toolchains-with-guix.md
@@ -447,7 +447,7 @@ for a given board.
 
 There are standard locations the build system will look for the SDK. We are not using any of them.
 Our SDK lives in the store, immutable forever.
-According to [the Zephyr documentation](https://docs.zephyrproject.org/latest/develop/west/without-west.html), the variable `ZEPHYR_SDK_INSTALL_DIR` needs to point to our custom spot.
+According to [the Zephyr documentation](https://docs.zephyrproject.org/3.1.0/develop/west/without-west.html), the variable `ZEPHYR_SDK_INSTALL_DIR` needs to point to our custom spot.
 
 We also need to grab the CMake files from the
 [repository](https://github.com/zephyrproject-rtos/sdk-ng)
-- 
2.39.1


  parent reply	other threads:[~2023-03-13 13:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-24 18:51 [bug#61765] custom toolchain blog post Mitchell Schmeisser via Guix-patches via
2023-02-27 12:50 ` Ludovic Courtès
2023-02-27 15:35   ` Mitchell Schmeisser via Guix-patches
2023-03-11 12:11     ` Ludovic Courtès
2023-03-11 16:50       ` Mitchell Schmeisser via Guix-patches via
2023-03-13 13:52       ` Mitchell Schmeisser via Guix-patches via [this message]
2023-03-15 14:45         ` Ludovic Courtès
2023-03-16  1:55           ` Mitchell Schmeisser via Guix-patches via

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e0a66bab-2bca-cbd2-2e3b-c893c0391a1d@librem.one \
    --to=guix-patches@gnu.org \
    --cc=61765@debbugs.gnu.org \
    --cc=ludo@gnu.org \
    --cc=mitchellschmeisser@librem.one \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.