From patchwork Mon Sep 18 00:43:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Cournoyer X-Patchwork-Id: 54013 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id CA7F327BBE9; Mon, 18 Sep 2023 01:44:09 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 8BD3427BBE2 for ; Mon, 18 Sep 2023 01:44:06 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qi2Mp-0003hr-Ih; Sun, 17 Sep 2023 20:44:02 -0400 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 1qi2Mm-0003hU-2b for guix-patches@gnu.org; Sun, 17 Sep 2023 20:43:56 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qi2Ml-0000zq-3O; Sun, 17 Sep 2023 20:43:55 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qi2Ms-0001pO-VR; Sun, 17 Sep 2023 20:44:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#65860] [PATCH v2 1/3] gnu: avr: Delay all cross compilation packages. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: maxim.cournoyer@gmail.com, ludo@gnu.org, guix-patches@gnu.org Resent-Date: Mon, 18 Sep 2023 00:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65860 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 65860@debbugs.gnu.org Cc: Maxim Cournoyer , Maxim Cournoyer , Ludovic =?utf-8?q?Court=C3=A8s?= X-Debbugs-Original-Xcc: Maxim Cournoyer , Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 65860-submit@debbugs.gnu.org id=B65860.16949978346977 (code B ref 65860); Mon, 18 Sep 2023 00:44:02 +0000 Received: (at 65860) by debbugs.gnu.org; 18 Sep 2023 00:43:54 +0000 Received: from localhost ([127.0.0.1]:51666 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qi2Mj-0001oQ-PB for submit@debbugs.gnu.org; Sun, 17 Sep 2023 20:43:54 -0400 Received: from mail-qt1-x836.google.com ([2607:f8b0:4864:20::836]:46219) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qi2Mg-0001ny-C2 for 65860@debbugs.gnu.org; Sun, 17 Sep 2023 20:43:52 -0400 Received: by mail-qt1-x836.google.com with SMTP id d75a77b69052e-410af8f75d9so25130921cf.0 for <65860@debbugs.gnu.org>; Sun, 17 Sep 2023 17:43:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694997816; x=1695602616; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zwO2dzNNWv7qD8DUygWO0h5vAK9AGgtrLoa5cJdFFeU=; b=BPbm6+v4vl/3Ns2KtidqjpBlwsX7S42XKSsggxYbo8lo/g8/rdUrKyXTlUfm6IoEM4 O+HFJTki25WvIhTszr9GJBcDVxazXkflr6FAoSs9AIRPb08dq2djb/dmE5Hvye+aKlaY DUOMNigiM9P4agk2IlRZ4lf+aPhIZ1V/d6cZ21G9rrvTan+DlYEJet1wpXRFQ+jpmvZx 7WM+GtCa8iysH01WQaHD+MSNID/APj2j9FJqCH339wRWVumIMsvEnEeNlk2MGsqHyr96 81XAtHbIjT69Qizu+8uNs4UcKnH4ZgIXN8ODXnkEub5VWwPJj1ZS5NuACA8z23M9HdmJ 61Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694997816; x=1695602616; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zwO2dzNNWv7qD8DUygWO0h5vAK9AGgtrLoa5cJdFFeU=; b=NJqkX/1LLoILt8yC6Qx2oh4liTQ8HDijIR5mVUGUl/p3QcrexC72ZZb6UX744CalMl 3a28bFpOxcn9KnysZG8iqtWfu8WCTDSvCxfmoAwTrRe0SO7VY/KIn36O6dYq76NZ49RS 9LRdoehddOsCF1zKgOPB+JJ+TDEx83Kdg2Thfy1udQlhgNcjcmpe7Rjf/QTyktrurt1O I5xbSNKIXznMskEvgkNhnEr9l5XAV/5hPrwIiNsxbiufZyO4GIl48NvSDsgLjbaMt/RH Q7kjjIP+HiAh0bOj7i5AzU6B51JbE3zob54g0CRLDNijN6X8Z4JbjNetMlmoOOkyruEb sQIg== X-Gm-Message-State: AOJu0YyfJmHPdLpleyr/BYNOaZ1kmwl6WASOanziAM41Pt4U0WV/FYHp 93VyLnRDS4J7VmdD13nsWEgkNqUucCs= X-Google-Smtp-Source: AGHT+IEf+VB55YxfLdBc8J8afkU3yVPcufMEUeQcIRqk6HZSc9A3+fgFm7D5aJeCUXm1MLvFaeSosg== X-Received: by 2002:a05:622a:1822:b0:412:2513:fb6 with SMTP id t34-20020a05622a182200b0041225130fb6mr7286051qtc.5.1694997816579; Sun, 17 Sep 2023 17:43:36 -0700 (PDT) Received: from localhost.localdomain (dsl-10-149-131.b2b2c.ca. [72.10.149.131]) by smtp.gmail.com with ESMTPSA id cr8-20020a05622a428800b00403f1a7be90sm2662547qtb.88.2023.09.17.17.43.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 17:43:36 -0700 (PDT) From: Maxim Cournoyer Date: Sun, 17 Sep 2023 20:43:08 -0400 Message-ID: <9431a70a1d444c86ff64f8386740e40e036e6b0a.1694997755.git.maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches Partially addresses . * gnu/packages/avr.scm: Add commentary comment. (avr-gcc): Turn into this... (make-avr-gcc): ... procedure. (avr-libc): Likewise, into... (make-avr-gcc): ... this. Adjust native-inputs accordingly. (avr-toolchain): Likewise, into... (make-avr-toolchain): ... this. * gnu/packages/avr-xyz.scm (simavr) [propagated-inputs]: replace avr-toolchain with a call to the 'make-avr-toolchain' procedure. --- Changes in v2: - Use mlambda for procedures - Fix ((make-avr-toolchain)) typo gnu/packages/avr-xyz.scm | 2 +- gnu/packages/avr.scm | 214 +++++++++++++++++++++------------------ 2 files changed, 119 insertions(+), 97 deletions(-) diff --git a/gnu/packages/avr-xyz.scm b/gnu/packages/avr-xyz.scm index a05157ede78..e8844b8d438 100644 --- a/gnu/packages/avr-xyz.scm +++ b/gnu/packages/avr-xyz.scm @@ -71,7 +71,7 @@ (define-public simavr (string-append "PREFIX=" #$output) (string-append "DESTDIR=" #$output)))) (propagated-inputs - (list avr-toolchain)) + (list (make-avr-toolchain))) (native-inputs (list autoconf which diff --git a/gnu/packages/avr.scm b/gnu/packages/avr.scm index b9bee5e624c..1277634ce5a 100644 --- a/gnu/packages/avr.scm +++ b/gnu/packages/avr.scm @@ -25,6 +25,7 @@ (define-module (gnu packages avr) #:use-module ((guix licenses) #:prefix license:) #:use-module (guix gexp) + #:use-module (guix memoization) #:use-module (guix utils) #:use-module (guix download) #:use-module (guix git-download) @@ -37,113 +38,134 @@ (define-module (gnu packages avr) #:use-module (gnu packages flashing-tools) #:use-module (gnu packages gcc) #:use-module (gnu packages llvm) - #:use-module (gnu packages vim)) + #:use-module (gnu packages vim) + #:export (make-avr-toolchain)) -(define-public avr-binutils +;;; Commentary: +;;; +;;; This module defines a procedure that can be used to create a complete +;;; avr-toolchain package. The procedure must not be used at the top level, +;;; to avoid cyclic module dependencies caused by the (gnu packages +;;; cross-base) module referring to top level bindings from (gnu packages +;;; gcc). +;;; +;;; It also contains packages for working with or targeting the AVR system. +;;; + +(define (make-avr-binutils) (package (inherit (cross-binutils "avr")) (name "avr-binutils"))) -(define avr-gcc - (let ((xgcc (cross-gcc "avr" #:xbinutils avr-binutils))) +(define make-avr-gcc + (mlambda () + (let ((xgcc (cross-gcc "avr" #:xbinutils (make-avr-binutils)))) + (package + (inherit xgcc) + (name "avr-gcc") + (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"))))) + ;; Without a working multilib build, the resulting GCC lacks + ;; support for nearly every AVR chip. + (add-after 'unpack 'fix-genmultilib + (lambda _ + ;; patch-shebang doesn't work here because there are + ;; actually several scripts inside this script, each with + ;; a #!/bin/sh that needs patching. + (substitute* "gcc/genmultilib" + (("#!/bin/sh") (string-append "#!" (which "sh")))))))) + ((#:configure-flags flags) + #~(delete "--disable-multilib" #$flags)))) + (native-search-paths + (list (search-path-specification + (variable "CROSS_C_INCLUDE_PATH") + (files '("avr/include"))) + (search-path-specification + (variable "CROSS_CPLUS_INCLUDE_PATH") + (files '("avr/include"))) + (search-path-specification + (variable "CROSS_OBJC_INCLUDE_PATH") + (files '("avr/include"))) + (search-path-specification + (variable "CROSS_OBJCPLUS_INCLUDE_PATH") + (files '("avr/include"))) + (search-path-specification + (variable "CROSS_LIBRARY_PATH") + (files '("avr/lib"))))) + (native-inputs + `(("gcc" ,gcc) + ,@(package-native-inputs xgcc))))))) + +(define make-avr-libc + (mlambda () (package - (inherit xgcc) - (name "avr-gcc") + (name "avr-libc") + (version "2.0.0") + (source (origin + (method url-fetch) + (uri (string-append "mirror://savannah//avr-libc/avr-libc-" + version ".tar.bz2")) + (sha256 + (base32 + "15svr2fx8j6prql2il2fc0ppwlv50rpmyckaxx38d3gxxv97zpdj")))) + (build-system gnu-build-system) (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"))))) - ;; Without a working multilib build, the resulting GCC lacks - ;; support for nearly every AVR chip. - (add-after 'unpack 'fix-genmultilib - (lambda _ - ;; patch-shebang doesn't work here because there are actually - ;; several scripts inside this script, each with a #!/bin/sh - ;; that needs patching. - (substitute* "gcc/genmultilib" - (("#!/bin/sh") (string-append "#!" (which "sh")))))))) - ((#:configure-flags flags) - #~(delete "--disable-multilib" #$flags)))) - (native-search-paths - (list (search-path-specification - (variable "CROSS_C_INCLUDE_PATH") - (files '("avr/include"))) - (search-path-specification - (variable "CROSS_CPLUS_INCLUDE_PATH") - (files '("avr/include"))) - (search-path-specification - (variable "CROSS_OBJC_INCLUDE_PATH") - (files '("avr/include"))) - (search-path-specification - (variable "CROSS_OBJCPLUS_INCLUDE_PATH") - (files '("avr/include"))) - (search-path-specification - (variable "CROSS_LIBRARY_PATH") - (files '("avr/lib"))))) - (native-inputs - `(("gcc" ,gcc) - ,@(package-native-inputs xgcc)))))) + '(#:out-of-source? #t + #:configure-flags '("--host=avr"))) + (native-inputs `(("avr-binutils" ,(make-avr-binutils)) + ("avr-gcc" ,(make-avr-gcc)))) + (home-page "https://www.nongnu.org/avr-libc/") + (synopsis "The AVR C Library") + (description + "AVR Libc is a project whose goal is to provide a high quality C +library for use with GCC on Atmel AVR microcontrollers.") + (license + (license:non-copyleft "http://www.nongnu.org/avr-libc/LICENSE.txt"))))) -(define avr-libc - (package - (name "avr-libc") - (version "2.0.0") - (source (origin - (method url-fetch) - (uri (string-append "mirror://savannah//avr-libc/avr-libc-" - version ".tar.bz2")) - (sha256 - (base32 - "15svr2fx8j6prql2il2fc0ppwlv50rpmyckaxx38d3gxxv97zpdj")))) - (build-system gnu-build-system) - (arguments - '(#:out-of-source? #t - #:configure-flags '("--host=avr"))) - (native-inputs `(("avr-binutils" ,avr-binutils) - ("avr-gcc" ,avr-gcc))) - (home-page "https://www.nongnu.org/avr-libc/") - (synopsis "The AVR C Library") - (description - "AVR Libc is a project whose goal is to provide a high quality C library -for use with GCC on Atmel AVR microcontrollers.") - (license - (license:non-copyleft "http://www.nongnu.org/avr-libc/LICENSE.txt")))) - -(define-public avr-toolchain - ;; avr-libc checks the compiler version and passes "--enable-device-lib" for avr-gcc > 5.1.0. - ;; It wouldn't install the library for atmega32u4 etc if we didn't use the corret avr-gcc. - (package - (name "avr-toolchain") - (version (package-version avr-gcc)) - (source #f) - (build-system trivial-build-system) - (arguments '(#:builder (begin (mkdir %output) #t))) - (propagated-inputs - `(("avrdude" ,avrdude) - ("binutils" ,avr-binutils) - ("gcc" ,avr-gcc) - ("libc" ,avr-libc))) - (synopsis "Complete GCC tool chain for AVR microcontroller development") - (description "This package provides a complete GCC tool chain for AVR +(define make-avr-toolchain + (mlambda () + (let ((avr-binutils (make-avr-binutils)) + (avr-libc (make-avr-libc)) + (avr-gcc (make-avr-gcc))) + ;; avr-libc checks the compiler version and passes "--enable-device-lib" + ;; for avr-gcc > 5.1.0. It wouldn't install the library for atmega32u4 + ;; etc if we didn't use the corret avr-gcc. + (package + (name "avr-toolchain") + (version (package-version avr-gcc)) + (source #f) + (build-system trivial-build-system) + (arguments '(#:builder (begin (mkdir %output) #t))) + (propagated-inputs + `(("avrdude" ,avrdude) + ("binutils" ,avr-binutils) + ("gcc" ,avr-gcc) + ("libc" ,avr-libc))) + (synopsis "Complete GCC tool chain for AVR microcontroller development") + (description "This package provides a complete GCC tool chain for AVR microcontroller development. This includes the GCC AVR cross compiler and avrdude for firmware flashing. The supported programming languages are C and C++.") - (home-page (package-home-page avr-libc)) - (license (package-license avr-gcc)))) + (home-page (package-home-page avr-libc)) + (license (package-license avr-gcc)))))) (define-public microscheme (package