From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id QMi9Ak+n/GNegwAAbAwnHQ (envelope-from ) for ; Mon, 27 Feb 2023 13:51:27 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id 8N/XAk+n/GOkZgEA9RJhRA (envelope-from ) for ; Mon, 27 Feb 2023 13:51:27 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 4AC4732F10 for ; Mon, 27 Feb 2023 13:51:26 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pWcy8-0007wJ-2f; Mon, 27 Feb 2023 07:51:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pWcy6-0007w7-Ek for guix-patches@gnu.org; Mon, 27 Feb 2023 07:51:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pWcy6-0005Dl-5d for guix-patches@gnu.org; Mon, 27 Feb 2023 07:51:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pWcy5-0007yx-OB for guix-patches@gnu.org; Mon, 27 Feb 2023 07:51:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#61765] custom toolchain blog post Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 27 Feb 2023 12:51:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61765 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: Mitchell Schmeisser Cc: 61765@debbugs.gnu.org Received: via spool by 61765-submit@debbugs.gnu.org id=B61765.167750224030647 (code B ref 61765); Mon, 27 Feb 2023 12:51:01 +0000 Received: (at 61765) by debbugs.gnu.org; 27 Feb 2023 12:50:40 +0000 Received: from localhost ([127.0.0.1]:46322 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pWcxj-0007yE-Oy for submit@debbugs.gnu.org; Mon, 27 Feb 2023 07:50:40 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56592) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pWcxf-0007xz-76 for 61765@debbugs.gnu.org; Mon, 27 Feb 2023 07:50:37 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pWcxX-000549-Rq; Mon, 27 Feb 2023 07:50:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=m4LxqpM70vTqYlcOQzHLLm129vQLAZDx26OQndnNqwU=; b=j7jvrifrwXp0e3zJ5P8G XGPcLoCVPFiEOgTSqR5hS/qGWJdc7uChAiyaWyMoJUl0wQRQbvf7DXb84RXUvCrmJxIAD1Eyj6ABN yZk6FmwbK9MfdxWa7JgQnvjNUpbRETey+5OEV3Y+3GicJL/5GQtOkjAQLcpsYgdXf5JCz2zorAcN8 GtJ/tbkyqaUPHqcZVwTzrFUyzzIq9DzJo2yeQhs/56wlSPbdVH3UnnbDuIEeSlcHFcqn1R6mGPRDx WIWdS0e0SI5gEb6RvdLLNN36GPCfsuLgFc3EnCLCs8/rxw57Z3aAkSH956f72CcPILsxDpNBXvN+m eT17Fk039gYI2g==; Received: from [193.50.110.164] (helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pWcxP-0003ss-WF; Mon, 27 Feb 2023 07:50:27 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <87sfeuucab.fsf@librem.one> Date: Mon, 27 Feb 2023 13:50:17 +0100 In-Reply-To: <87sfeuucab.fsf@librem.one> (Mitchell Schmeisser's message of "Fri, 24 Feb 2023 13:51:56 -0500") Message-ID: <87fsarmfw6.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Seal: i=1; s=key1; d=yhetil.org; t=1677502286; a=rsa-sha256; cv=none; b=ZYenRIfE667D/IFfMa88rFn98lo1XzC8Ip6HXZd4Qdmjwp4I+nn18EU/DPPBRX1BMQXkFH 2+rZ+I0WAF0CZ9iYrCmMh9d/4bdr7WIlNpnw9neLtupwKxdLhSzHoP6Z2JbsLS2TVYw4FQ /eUgi5abpW/xh6JZXFFtenexW7XfQIp6haxDD+RZBRfz7uduM1mySiDB25B6h/9A5TfUgD q4YOZ5Vn21ZGAllmPs3soZGNC9WHC7+eL8+lBoNXfx3lfr4X3+jADvL52Jhv4sfM0PWKHM jRqti3LWA4XV6a3jvbeo/DviyzXzKq2mZxNxdd/J7pCbWoxE+BlcwdzhtvDnNQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=j7jvrifr; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1677502286; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=m4LxqpM70vTqYlcOQzHLLm129vQLAZDx26OQndnNqwU=; b=pNVAVdKL5O9y2ByBHKmssF8tvC+ASL2wOaYaWkK6X/3OCaHqM/XFo5WbgsKsDARaCT1i2i nj3kWiUh24ELQo8QoVNaiwZ31yQ7cv2et0mVIu9Ajb9z/GQr/LGerZglr4uJ/PCVBQY5de HCfgmBNKyExpHWRP4NVzStHmhmy4PcvLxwB2dKxVbpdjz0WWfGwB+pr8WAgEXcIk7Xm1Po yiS9SROdQszFuQWpnZqVynukzVqhgEB1hzyG//kOxMXVKXKmyzKc5oGsDosP7/4Pu4trc6 LgWefkds83QK3cTaB7/HgAVJGc56x9Xf0wC/K8/bhKluC2pdFAgE//gwQyis5w== X-Spam-Score: -2.59 X-Migadu-Queue-Id: 4AC4732F10 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=j7jvrifr; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Scanner: scn1.migadu.com X-Migadu-Spam-Score: -2.59 X-TUID: B0+MGdS0qxz7 Hello Mitchell, Mitchell Schmeisser skribis: > Here is a rough draft of my toolchain post. > I hope it can make an interesting contribution to the Guix literature. Yay, definitely! >>>From 4f6c43091ffd67cdbc5f041e496f61bc8a06070e Mon Sep 17 00:00:00 2001 > From: Mitchell Schmeisser > Date: Fri, 24 Feb 2023 13:02:05 -0500 > Subject: [PATCH] website: Add custom toolchain blog post > > * website/posts/custom-toolchains-with-guix.md: New file. This looks great to me! It=E2=80=99s useful insight for anyone who might w= ant to add a cross-compilation target to Guix or simply learn how this is implemented. > +++ b/website/posts/custom-toolchains-with-guix.md > @@ -0,0 +1,557 @@ > +# Table of Contents > + > +1. [Overview](#org2633a51) > +2. [Anatomy of a toolchain](#orgc440e9e) > +3. [Bootstrapping a Toolchain](#orgd42b6c3) > +4. [Defining the Packages](#org55042c5) > + 1. [Binutils](#org67da1ec) > + 2. [GCC sans libc](#org82d6f83) > + 3. [Newlib(-nano)](#orgf6bafbc) > + 4. [Complete toolchain](#org052f2a2) > +5. [Integrating with Zephyr Build System](#orgc3f87f4) > + 1. [Testing](#org9f3c314) > + > +All code is available at [guix-zephyr](https://github.com/paperclip4465/= guix-zephyr) channel. > + > + > + You can remove the table of contents and all the HTML snippets that pandoc added=E2=80=94I don=E2=80=99t think that works as expected with Haun= t/CommonMark. > +# Overview You can drop the heading. > +In order to deploy embedded software using Guix we first need to teach G= uix > +how to build it. Since Guix bootstraps everything this means we must tea= ch Guix > +how to build our toolchain. > + > +The [Zephyr Project](https://zephyrproject.org) uses its own fork of GCC= with custom configs for > +the architectures supported by the project. We want blog posts to be widely accessible so I would recommend providing more context in the intro. In particular, I=E2=80=99d suggest: 1. Mentioning that Guix supports cross-compilation (not everyone is aware of that), with a link to . 2. Adding a couple of sentences saying what Zephyr is (I didn=E2=80=99t k= now about it before :-)). 3. Saying a few words as to why Zephyr uses a GCC fork. 4. Clearly stating that you added support for cross-compilation to Zephyr with Guix in a channel, linking to said channel, and that this is what the remainder of the post will describe. You can check out posts at for inspiration. > +# Anatomy of a toolchain > + > +Toolchains are responsible for taking high level descriptions of programs > +and lowering them down to a series of equivalent machine instructions. > +This process involves more than just a compiler. The compiler uses the `= binutils` > +to manipulate it's internal representation down to a given architecture. > +It also needs the use of the C standard library as well as a few other l= ibraries > +needed for some compiler optimizations. > + > +The C library provides the interface to the underlying kernel. System ca= lls like `write` > +and `read` are provided by `Glibc` on most Linux distributions. > > +In embedded systems smaller implementations like `newlib` and `newlib-na= no` are used. I=E2=80=99d suggest not using fixed-width font (backquotes) for proper noun= s; you can write =E2=80=9Cglibc=E2=80=9D or =E2=80=9Cthe GNU C Library (glibc)= =E2=80=9D, =E2=80=9CBinutils=E2=80=9D or =E2=80=9Cthe GNU Binary Utilities (Binutils)=E2=80=9D, etc. > +First thing we need to build is the `arm-zephyr-eabi` binutils. > +This is very easy in Guix. > + > + (define-module (zephyr packages zephyr) > + #:use-module (guix packages)) > + > + (define-public arm-zephyr-eabi-binutils > + (let ((xbinutils (cross-binutils "arm-zephyr-eabi"))) > + (package > + (inherit xbinutils) > + (name "arm-zephyr-eabi-binutils") > + (version "2.38") > + (source > + (origin (method git-fetch) > + (uri (git-reference > + (url "https://github.com/zephyrproject-rtos/binutils-gdb") > + (commit "6a1be1a6a571957fea8b130e4ca2dcc65e753469"))) > + (file-name (git-file-name name version)) > + (sha256 (base32 "0ylnl48jj5jk3jrmvfx5zf8byvwg7g7my7jwwyqw3a95qcyh= 0isr")))) > + (arguments > + `(#:tests? #f > + ,@(substitute-keyword-arguments (package-arguments xbinutils) > + ((#:configure-flags flags) > + `(cons "--program-prefix=3Darm-zephyr-eabi-" ,flags))))) > + (native-inputs > + (append > + (list texinfo > + bison > + flex > + gmp > + dejagnu) > + (package-native-inputs xbinutils))) > + (home-page "https://zephyrproject.org") > + (synopsis "binutils for zephyr RTOS")))) Code snippets should be written like this, without leading indentation: ```scheme (define =E2=80=A6) ``` This will enable syntax highlighting. > +We can test our package definition using the `-L` flag with `guix build` > +to add our packages. > + > + guix build -L guix-zephyr zephyr-binutils > + > + /gnu/store/...-zephyr-binutils-2.38 Likewise: ``` guix build foo ``` > +# Integrating with Zephyr Build System > + > +Zephyr uses CMake as it's build system. It contains numerous CMake s/it's/its/ One thing that=E2=80=99s not clear to me: with this in place, can you do = =E2=80=9Cguix build --target=3Darm-zephyr-eabi hello=E2=80=9D, for instance? If not, wha= t=E2=80=99s missing to support it? It would be great if you could finish with a short conclusion stating, for instance, the key takeaway message, lessons learned, and/or your thoughts on how this could benefit others in the broader community. I wonder if it would be worth mentioning too, and how one would go about adding a module. WDYT? Could you send an updated patch? Thanks for contributing this article! Ludo=E2=80=99.