[PATCH 0/4] Resolve a circular module dependencies in embedded modules

  • Done
  • quality assurance status badge
Details
2 participants
  • Ludovic Courtès
  • Maxim Cournoyer
Owner
unassigned
Submitted by
Maxim Cournoyer
Severity
normal
Merged with
M
M
Maxim Cournoyer wrote on 11 Sep 2023 06:19
cover.1694405985.git.maxim.cournoyer@gmail.com
This series is the culmination of at least a day of effort tracking down the
source of a module dependency cycle (!). The last commit adds some guide
lines in the hope to avoid a repeat (perhaps 'lint' could be taught to
automate these checks).


Maxim Cournoyer (4):
gnu: avr: Delay all cross compilation packages.
gnu: embedded: Turn packages using top-level variables into
procedures.
gnu: Remove extraneous imports.
doc: Add new 'Circular Module Dependencies' section.

doc/contributing.texi | 56 ++++++
gnu/packages/admin.scm | 5 -
gnu/packages/avr-xyz.scm | 2 +-
gnu/packages/avr.scm | 67 ++++---
gnu/packages/axoloti.scm | 6 +-
gnu/packages/base.scm | 1 -
gnu/packages/bootloaders.scm | 2 -
gnu/packages/cran.scm | 2 -
gnu/packages/embedded.scm | 322 +++++++++++++++++--------------
gnu/packages/emulators.scm | 3 -
gnu/packages/firmware.scm | 4 -
gnu/packages/kde.scm | 3 -
gnu/packages/libcanberra.scm | 6 +-
gnu/packages/libreoffice.scm | 4 -
gnu/packages/linphone.scm | 4 -
gnu/packages/mes.scm | 5 -
gnu/packages/mingw.scm | 6 -
gnu/packages/raspberry-pi.scm | 2 +-
gnu/packages/serialization.scm | 5 +-
gnu/packages/sync.scm | 2 -
gnu/packages/syncthing.scm | 2 -
gnu/packages/telephony.scm | 12 --
gnu/packages/terminals.scm | 1 -
gnu/packages/version-control.scm | 2 -
gnu/packages/video.scm | 7 -
gnu/packages/wm.scm | 3 -
26 files changed, 286 insertions(+), 248 deletions(-)


base-commit: 2eb6df537c36da8bf8e81ff698421f6fb1bfd1ab
--
2.41.0
M
M
Maxim Cournoyer wrote on 11 Sep 2023 06:25
[PATCH 1/4] gnu: avr: Delay all cross compilation packages.
(address . 65860@debbugs.gnu.org)(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
dbe1824a3b222919340538d30ef3948092ba9bc7.1694406359.git.maxim.cournoyer@gmail.com

* 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.
---

gnu/packages/avr-xyz.scm | 2 +-
gnu/packages/avr.scm | 66 +++++++++++++++++++++++++---------------
2 files changed, 42 insertions(+), 26 deletions(-)

Toggle diff (121 lines)
diff --git a/gnu/packages/avr-xyz.scm b/gnu/packages/avr-xyz.scm
index a05157ede7..e8844b8d43 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 9c623a9626..abca60eeac 100644
--- a/gnu/packages/avr.scm
+++ b/gnu/packages/avr.scm
@@ -38,15 +38,27 @@ (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)
+ (let ((xgcc (cross-gcc "avr" #:xbinutils (make-avr-binutils))))
(package
(inherit xgcc)
(name "avr-gcc")
@@ -99,7 +111,7 @@ (define avr-gcc
`(("gcc" ,gcc)
,@(package-native-inputs xgcc))))))
-(define avr-libc
+(define (make-avr-libc)
(package
(name "avr-libc")
(version "2.0.0")
@@ -114,8 +126,8 @@ (define avr-libc
(arguments
'(#:out-of-source? #t
#:configure-flags '("--host=avr")))
- (native-inputs `(("avr-binutils" ,avr-binutils)
- ("avr-gcc" ,avr-gcc)))
+ (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
@@ -124,27 +136,31 @@ (define avr-libc
(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)
+ (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
--
2.41.0
M
M
Maxim Cournoyer wrote on 11 Sep 2023 06:25
[PATCH 2/4] gnu: embedded: Turn packages using top-level variables into procedures.
(address . 65860@debbugs.gnu.org)(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
29c22d0230290ead9ca04fa3b01c17abfbdd3ed5.1694406359.git.maxim.cournoyer@gmail.com

Before this change, simply adding the following import:

modified gnu/packages/firmware.scm
@@ -42,6 +42,7 @@ (define-module (gnu packages firmware)
#:use-module (gnu packages admin)
#:use-module (gnu packages autotools)
#:use-module (gnu packages assembly)
+ #:use-module (gnu packages avr)
#:use-module (gnu packages backup)
#:use-module (gnu packages base)
#:use-module (gnu packages bash)

Would cause byte compilation and/or evaluation to fail due to a circular
module dependency.

* gnu/packages/embedded.scm: Add commentary.
(gcc-arm-none-eabi-4.9, gcc-arm-none-eabi-6, newlib-arm-none-eabi)
(newlib-nano-arm-none-eabi, gcc-arm-none-eabi-7-2018-q2-update)
(newlib-arm-none-eabi-7-2018-q2-update)
(newlib-nano-arm-none-eabi-7-2018-q2-update)
(arm-none-eabi-toolchain-4.9, arm-none-eabi-nano-toolchain-4.9)
(arm-none-eabi-toolchain-6, arm-none-eabi-nano-toolchain-6)
(arm-none-eabi-toolchain-7-2018-q2-update, gdb-arm-none-eabi)
(propeller-binutils, propeller-gcc-6, propeller-gcc-4)
(propeller-gcc, propeller-toolchain, propeller-development-suite)
(gcc-vc4): Turn into procedures, prefixing the procedure name with 'make-',
and adjust all users.
(make-libstdc++-arm-none-eabi) [arguments]: Avoid an unused warning.
(arm-none-eabi-toolchain): Rename to...
(make-arm-none-eabi-toolchain): ... this.
* gnu/packages/raspberry-pi.scm (raspi-arm-chainloader) [native-inputs]:
Replace gcc-arm-none-eabi-6 with (make-arm-none-eabi-toolchain).
* gnu/packages/axoloti.scm (axoloti-runtime)
[inputs]: Replace arm-none-eabi-nano-toolchain-4.9
with (make-arm-none-eabi-nano-toolchain-4.9).
(axoloti-patcher): Likewise.
(axoloti-patcher-next) [inputs]: Replace
arm-none-eabi-nano-toolchain-7-2018-q2-update
with (make-arm-none-eabi-nano-toolchain-7-2018-q2-update).
---

gnu/packages/axoloti.scm | 6 +-
gnu/packages/embedded.scm | 322 +++++++++++++++++++---------------
gnu/packages/raspberry-pi.scm | 2 +-
3 files changed, 186 insertions(+), 144 deletions(-)

Toggle diff (398 lines)
diff --git a/gnu/packages/axoloti.scm b/gnu/packages/axoloti.scm
index e0dd22c627..7b36922860 100644
--- a/gnu/packages/axoloti.scm
+++ b/gnu/packages/axoloti.scm
@@ -199,7 +199,7 @@ (define-public axoloti-runtime
;; for compiling patches
("make" ,gnu-make)
;; for compiling firmware
- ("cross-toolchain" ,arm-none-eabi-nano-toolchain-4.9)
+ ("cross-toolchain" ,(make-arm-none-eabi-nano-toolchain-4.9))
;; for uploading compiled patches and firmware
("dfu-util" ,dfu-util-for-axoloti)))
(native-inputs
@@ -339,7 +339,7 @@ (define-public axoloti-patcher
(assoc-ref ant:%standard-phases 'strip-jar-timestamps)))))
(inputs
`(("icedtea" ,icedtea "jdk")
- ("cross-toolchain" ,arm-none-eabi-nano-toolchain-4.9)
+ ("cross-toolchain" ,(make-arm-none-eabi-nano-toolchain-4.9))
("java-simple-xml" ,java-simple-xml)
("java-rsyntaxtextarea" ,java-rsyntaxtextarea)
("java-usb4java" ,java-usb4java)
@@ -572,7 +572,7 @@ (define-public axoloti-patcher-next
(assoc-ref ant:%standard-phases 'strip-jar-timestamps)))))
(inputs
`(("jdk" ,icedtea "jdk")
- ("cross-toolchain" ,arm-none-eabi-nano-toolchain-7-2018-q2-update)
+ ("cross-toolchain" ,(make-arm-none-eabi-nano-toolchain-7-2018-q2-update))
;; for compiling patches
("make" ,gnu-make)
;; for uploading compiled patches and firmware
diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
index 325013a627..c84262b825 100644
--- a/gnu/packages/embedded.scm
+++ b/gnu/packages/embedded.scm
@@ -11,7 +11,7 @@
;;; Copyright © 2020, 2021, 2022 Simon South <simon@simonsouth.net>
;;; Copyright © 2021 Morgan Smith <Morgan.J.Smith@outlook.com>
;;; Copyright © 2022 Mathieu Othacehe <othacehe@gnu.org>
-;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2022, 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2023 Janneke Nieuwenhuizen <janneke@gnu.org>
;;;
;;; This file is part of GNU Guix.
@@ -73,14 +73,49 @@ (define-module (gnu packages embedded)
#:use-module (gnu packages tls)
#:use-module (gnu packages version-control)
#:use-module (gnu packages xorg)
- #:use-module (srfi srfi-1))
+ #:use-module (srfi srfi-1)
+ #:export (make-gcc-arm-none-eabi-4.9
+ make-gcc-arm-none-eabi-6
+ make-gcc-arm-none-eabi-7-2018-q2-update
+
+ make-gcc-vc4
+
+ make-newlib-arm-none-eabi
+ make-newlib-arm-none-eabi-7-2018-q2-update
+
+ make-newlib-nano-arm-none-eabi
+ make-newlib-nano-arm-none-eabi-7-2018-q2-update
+
+ make-arm-none-eabi-toolchain-4.9
+ make-arm-none-eabi-toolchain-6
+ make-arm-none-eabi-toolchain-7-2018-q2-update
+
+ make-arm-none-eabi-nano-toolchain-4.9
+ make-arm-none-eabi-nano-toolchain-6
+ make-arm-none-eabi-nano-toolchain-7-2018-q2-update
+
+ make-gdb-arm-none-eabi
+
+ make-propeller-gcc
+ make-propeller-gcc-4
+ make-propeller-gcc-6
+ make-propeller-toolchain
+ make-propeller-development-suite))
+
+;;; Commentary:
+;;;
+;;; This modules contains toolchain generators as well as packages for use in
+;;; embedded contexts. Note: the toolchain and specialized packages are
+;;; procedures, so as to delay their references to top level bindings such as
+;;; 'gcc' or 'cross-gcc', etc.
+;;;
;; We must not use the released GCC sources here, because the cross-compiler
;; does not produce working binaries. Instead we take the very same SVN
;; revision from the branch that is used for a release of the "GCC ARM
;; embedded" project on launchpad.
;; See https://launchpadlibrarian.net/218827644/release.txt
-(define-public gcc-arm-none-eabi-4.9
+(define (make-gcc-arm-none-eabi-4.9)
(let ((xgcc (cross-gcc "arm-none-eabi"
#:xgcc gcc-4.9
#:xbinutils (cross-binutils "arm-none-eabi")))
@@ -167,9 +202,9 @@ (define-public gcc-arm-none-eabi-4.9
(variable "CROSS_LIBRARY_PATH")
(files '("arm-none-eabi/lib"))))))))
-(define-public gcc-arm-none-eabi-6
+(define (make-gcc-arm-none-eabi-6)
(package
- (inherit gcc-arm-none-eabi-4.9)
+ (inherit (make-gcc-arm-none-eabi-4.9))
(version (package-version gcc-6))
(source (origin (inherit (package-source gcc-6))
(patches
@@ -178,7 +213,7 @@ (define-public gcc-arm-none-eabi-6
(search-patches "gcc-6-cross-environment-variables.patch"
"gcc-6-arm-none-eabi-multilib.patch")))))))
-(define-public newlib-arm-none-eabi
+(define (make-newlib-arm-none-eabi)
(package
(name "newlib")
(version "2.4.0")
@@ -211,7 +246,7 @@ (define-public newlib-arm-none-eabi
#t)))))
(native-inputs
`(("xbinutils" ,(cross-binutils "arm-none-eabi"))
- ("xgcc" ,gcc-arm-none-eabi-4.9)
+ ("xgcc" ,(make-gcc-arm-none-eabi-4.9))
("texinfo" ,texinfo)))
(home-page "https://www.sourceware.org/newlib/")
(synopsis "C library for use on embedded systems")
@@ -221,68 +256,70 @@ (define-public newlib-arm-none-eabi
(license (license:non-copyleft
"https://www.sourceware.org/newlib/COPYING.NEWLIB"))))
-(define-public newlib-nano-arm-none-eabi
- (package (inherit newlib-arm-none-eabi)
- (name "newlib-nano")
- (arguments
- (substitute-keyword-arguments (package-arguments newlib-arm-none-eabi)
- ;; The configure flags are identical to the flags used by the "GCC ARM
- ;; embedded" project. They optimize newlib for use on small embedded
- ;; systems with limited memory.
- ((#:configure-flags flags)
- ''("--target=arm-none-eabi"
- "--enable-multilib"
- "--disable-newlib-supplied-syscalls"
- "--enable-newlib-reent-small"
- "--disable-newlib-fvwrite-in-streamio"
- "--disable-newlib-fseek-optimization"
- "--disable-newlib-wide-orient"
- "--enable-newlib-nano-malloc"
- "--disable-newlib-unbuf-stream-opt"
- "--enable-lite-exit"
- "--enable-newlib-global-atexit"
- "--enable-newlib-nano-formatted-io"
- "--disable-nls"))
- ((#:phases phases)
- `(modify-phases ,phases
- ;; XXX: Most arm toolchains offer both *.a and *_nano.a as newlib
- ;; and newlib-nano respectively. The headers are usually
- ;; arm-none-eabi/include/newlib.h for newlib and
- ;; arm-none-eabi/include/newlib-nano/newlib.h for newlib-nano. We
- ;; have two different toolchain packages for each which works but
- ;; is a little strange.
- (add-after 'install 'hardlink-newlib
- (lambda* (#:key outputs #:allow-other-keys)
- (let ((out (assoc-ref outputs "out")))
- ;; The nano.specs file says that newlib-nano files should end
- ;; in "_nano.a" instead of just ".a". Note that this applies
- ;; to all the multilib folders too.
- (for-each
- (lambda (file)
- (link file
- (string-append
- ;; Strip ".a" off the end
- (substring file 0 (- (string-length file) 2))
- ;; Add "_nano.a" onto the end
- "_nano.a")))
- (find-files
- out
- "^(libc.a|libg.a|librdimon.a|libstdc\\+\\+.a|libsupc\\+\\+.a)$"))
+(define (make-newlib-nano-arm-none-eabi)
+ (let ((base (make-newlib-arm-none-eabi)))
+ (package
+ (inherit base)
+ (name "newlib-nano")
+ (arguments
+ (substitute-keyword-arguments (package-arguments base)
+ ;; The configure flags are identical to the flags used by the "GCC ARM
+ ;; embedded" project. They optimize newlib for use on small embedded
+ ;; systems with limited memory.
+ ((#:configure-flags _)
+ ''("--target=arm-none-eabi"
+ "--enable-multilib"
+ "--disable-newlib-supplied-syscalls"
+ "--enable-newlib-reent-small"
+ "--disable-newlib-fvwrite-in-streamio"
+ "--disable-newlib-fseek-optimization"
+ "--disable-newlib-wide-orient"
+ "--enable-newlib-nano-malloc"
+ "--disable-newlib-unbuf-stream-opt"
+ "--enable-lite-exit"
+ "--enable-newlib-global-atexit"
+ "--enable-newlib-nano-formatted-io"
+ "--disable-nls"))
+ ((#:phases phases)
+ `(modify-phases ,phases
+ ;; XXX: Most arm toolchains offer both *.a and *_nano.a as newlib
+ ;; and newlib-nano respectively. The headers are usually
+ ;; arm-none-eabi/include/newlib.h for newlib and
+ ;; arm-none-eabi/include/newlib-nano/newlib.h for newlib-nano. We
+ ;; have two different toolchain packages for each which works but
+ ;; is a little strange.
+ (add-after 'install 'hardlink-newlib
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((out (assoc-ref outputs "out")))
+ ;; The nano.specs file says that newlib-nano files should end
+ ;; in "_nano.a" instead of just ".a". Note that this applies
+ ;; to all the multilib folders too.
+ (for-each
+ (lambda (file)
+ (link file
+ (string-append
+ ;; Strip ".a" off the end
+ (substring file 0 (- (string-length file) 2))
+ ;; Add "_nano.a" onto the end
+ "_nano.a")))
+ (find-files
+ out
+ "^(libc.a|libg.a|librdimon.a|libstdc\\+\\+.a|libsupc\\+\\+.a)$"))
- ;; newlib.h is usually in this location instead so both
- ;; newlib and newlib-nano can be in the toolchain at the same
- ;; time
- (mkdir (string-append out "/arm-none-eabi/include/newlib-nano"))
- (symlink
- "../newlib.h"
- (string-append out "/arm-none-eabi/include/newlib-nano/newlib.h"))
- #t)))))))
- (synopsis "Newlib variant for small systems with limited memory")))
+ ;; newlib.h is usually in this location instead so both
+ ;; newlib and newlib-nano can be in the toolchain at the same
+ ;; time
+ (mkdir (string-append out "/arm-none-eabi/include/newlib-nano"))
+ (symlink
+ "../newlib.h"
+ (string-append out "/arm-none-eabi/include/newlib-nano/newlib.h"))
+ #t)))))))
+ (synopsis "Newlib variant for small systems with limited memory"))))
;;; The following definitions are for the "7-2018-q2-update" variant of the
;;; ARM cross toolchain as offered on https://developer.arm.com
-(define-public gcc-arm-none-eabi-7-2018-q2-update
+(define (make-gcc-arm-none-eabi-7-2018-q2-update)
(let ((xgcc (cross-gcc "arm-none-eabi"
#:xgcc gcc-7
#:xbinutils (cross-binutils "arm-none-eabi")))
@@ -370,13 +407,14 @@ (define-public gcc-arm-none-eabi-7-2018-q2-update
(variable "CROSS_LIBRARY_PATH")
(files '("arm-none-eabi/lib"))))))))
-(define-public newlib-arm-none-eabi-7-2018-q2-update
+(define (make-newlib-arm-none-eabi-7-2018-q2-update)
;; This is the same commit as used for the 7-2018-q2-update release
;; according to the release.txt.
- (let ((commit "3ccfb407af410ba7e54ea0da11ae1e40b554a6f4")
+ (let ((base ((make-newlib-arm-none-eabi)))
+ (commit "3ccfb407af410ba7e54ea0da11ae1e40b554a6f4")
(revision "0"))
(package
- (inherit newlib-arm-none-eabi)
+ (inherit base)
(version (git-version "3.0.0" revision commit))
(source
(origin
@@ -389,7 +427,7 @@ (define-public newlib-arm-none-eabi-7-2018-q2-update
(base32
"1dq23fqrk75g1a4v7569fvnnw5q440zawbxi3w0g05n8jlqsmvcy"))))
(arguments
- (substitute-keyword-arguments (package-arguments newlib-arm-none-eabi)
+ (substitute-keyword-arguments (package-arguments base)
;; The configure flags are identical to the flags used by the "GCC ARM
;; embedded" project.
((#:configure-flags flags)
@@ -399,15 +437,17 @@ (define-public newlib-arm-none-eabi-7-2018-q2-update
,flags))))
(native-inputs
`(("xbinutils" ,(cross-binutils "arm-none-eabi"))
- ("xgcc" ,gcc-arm-none-eabi-7-2018-q2-update)
+ ("xgcc" ,(make-gcc-arm-none-eabi-7-2018-q2-update))
("texinfo" ,texinfo))))))
-(define-public newlib-nano-arm-none-eabi-7-2018-q2-update
- (package (inherit newlib-arm-none-eabi-7-2018-q2-update)
- (name "newlib-nano")
- (arguments
- (package-arguments newlib-nano-arm-none-eabi))
- (synopsis "Newlib variant for small systems with limited memory")))
+(define-public (make-newlib-nano-arm-none-eabi-7-2018-q2-update)
+ (let ((base (make-newlib-arm-none-eabi-7-2018-q2-update)))
+ (package
+ (inherit base)
+ (name "newlib-nano")
+ (arguments
+ (package-arguments base))
+ (synopsis "Newlib variant for small systems with limited memory"))))
(define (make-libstdc++-arm-none-eabi xgcc newlib)
@@ -416,7 +456,7 @@ (define (make-libstdc++-arm-none-eabi xgcc newlib)
(name "libstdc++-arm-none-eabi")
(arguments
(substitute-keyword-arguments (package-arguments libstdc++)
- ((#:configure-flags flags)
+ ((#:configure-flags _)
``("--target=arm-none-eabi"
"--host=arm-none-eabi"
"--disable-libstdcxx-pch"
@@ -434,7 +474,7 @@ (define (make-libstdc++-arm-none-eabi xgcc newlib)
("xgcc" ,xgcc)
,@(package-native-inputs libstdc++))))))
-(define (arm-none-eabi-toolchain xgcc newlib)
+(define (make-arm-none-eabi-toolchain xgcc newlib)
"Produce a cross-compiler toolchain package with the compiler XGCC and the C
library variant NEWLIB."
(let ((newlib-with-xgcc (package (inherit newlib)
@@ -474,31 +514,31 @@ (define (arm-none-eabi-toolchain xgcc newlib)
(home-page (package-home-page xgcc))
(license (package-license xgcc)))))
-(define-public arm-none-eabi-toolchain-4.9
- (arm-none-eabi-toolchain gcc-arm-none-eabi-4.9
- newlib-arm-none-eabi))
+(define (make-arm-none-eabi-toolchain-4.9)
+ (make-arm-none-eabi-toolchain (make-gcc-arm-none-eabi-4.9)
+ (make-newlib-arm-none-eabi)))
-(define-public arm-none-eabi-nano-toolchain-4.9
- (arm-none-eabi-toolchain gcc-arm-none-eabi-4.9
- newlib-nano-arm-none-eabi))
+(define (make-arm-none-eabi-nano-toolchain-4.9)
+ (make-arm-none-eabi-toolchain (make-gcc-arm-none-eabi-4.9)
+ (make-newlib-nano-arm-none-eabi)))
-(define-public arm-none-eabi-toolchain-6
- (arm-none-eabi-toolchain gcc-arm-none-eabi-6
- newlib-arm-none-eabi))
+(define (make-arm-none-eabi-toolchain-6)
+ (make-arm-none-eabi-toolchain (make-gcc-arm-none-eabi-6)
+ (make-newlib-arm-none-eabi)))
-(define-public arm-none-eabi-nano-toolchain-6
- (arm-none-eabi-toolchain gcc-arm-none-eabi-6
- newlib-nano-arm-none-eabi))
+(define (make-arm-none-eabi-nano-toolchain-6)
+ (make-arm-none-eabi-toolchain (make-gcc-arm-none-eabi-6)
+ (make-newlib-nano-arm-none-eabi)))
-(define-public arm-none-eabi-toolchain-7-2018-q2-update
- (arm-none-eabi-toolchain gcc-arm-none-eabi-7-2018-q2-update
- newlib-arm-none-eabi-7-2018-q2-update))
+(define (make-arm-none-eabi-toolchain-7-2018-q2-update)
+ (make-arm-none-eabi-toolchain (make-gcc-arm-none-eabi-7-2018-q2-update)
+ (make-newlib-arm-none-eabi-7-2018-q2-update)))
-(define-public arm-none-eabi-nano-toolchain-7-2018-q2-update
- (arm-none-eabi-toolchain gcc-arm-none-eabi-7-2018-q2-update
- newlib-nano-arm-none-eabi-7-2018-q2-update))
+(define (make-arm-none-eabi-nano-toolchain-7-2018-q2-update)
+ (make-arm-none-eabi-toolchain (make-gcc-arm-none-eabi-7-2018-q2-update)
+ (make-newlib-nano-arm-none-eabi-7-2018-q2-update)))
-(define-public gdb-arm-none-eabi
+(define (make-gdb-arm-none-eabi)
(package
(inherit gdb)
(name "gdb-arm-none-eabi")
@@ -647,7 +687,7 @@ (define-public openocd
;; personal correspondence with the developers in July 2017, more recent
;; versions are currently incompatible with the "Simple Libraries".
-(define propeller-binutils
+(define (make-propeller-binutils)
(let ((xbinutils (cross-binutils "propeller-elf"))
(commit "4c46ecbe79ffbecd2ce918497ace5b956736b5a3")
(revision "2"))
@@ -683,9 +723,9 @@ (define propeller-binutils
("dejagnu" ,dejagnu)
,@(package-native-inputs xbinutils))))))
-(define-public propeller-gcc-6
+(define (make-propeller-gcc-6)
(let ((xgcc (cross-gcc "propeller-elf"
- #:xbinutils propeller-binutils))
+ #:xbinutils (make-propeller-binutils)))
(commit "b4f45a4725e0b6d0af59e594c4e3e35ca4105867")
(revision "1"))
(package (inherit xgcc)
@@ -719,8 +759,8 @@ (define-public propeller-gcc-6
(home
This message was truncated. Download the full message here.
M
M
Maxim Cournoyer wrote on 11 Sep 2023 06:25
[PATCH 3/4] gnu: Remove extraneous imports.
(address . 65860@debbugs.gnu.org)(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
bc65388b056610e75bd56abb4bc3481e3b9c0035.1694406359.git.maxim.cournoyer@gmail.com
Found by running 'guild compile -W3 gnu/packages/$module.scm', using guild
from the upcoming Guile.

* gnu/packages/admin.scm: Remove extraneous imports.
* gnu/packages/avr.scm: Likewise.
* gnu/packages/base.scm: Likewise.
* gnu/packages/bootloaders.scm: Likewise.
* gnu/packages/firmware.scm: Likewise.
* gnu/packages/linphone.scm: Likewise.
* gnu/packages/telephony.scm: Likewise.
* gnu/packages/cran.scm: Likewise.
* gnu/packages/kde.scm: Likewise.
* gnu/packages/libcanberra.scm: Likewise.
* gnu/packages/libreoffice.scm: Likewise.
* gnu/packages/mes.scm: Likewise.
* gnu/packages/mingw.scm: Likewise.
* gnu/packages/serialization.scm: Likewise.
* gnu/packages/sync.scm: Likewise.
* gnu/packages/syncthing.scm: Likewise.
* gnu/packages/terminals.scm: Likewise.
* gnu/packages/version-control.scm: Likewise.
* gnu/packages/video.scm: Likewise.
* gnu/packages/wm.scm: Likewise.
* gnu/packages/emulators.scm: Likewise.
---

gnu/packages/admin.scm | 5 -----
gnu/packages/avr.scm | 1 -
gnu/packages/base.scm | 1 -
gnu/packages/bootloaders.scm | 2 --
gnu/packages/cran.scm | 2 --
gnu/packages/emulators.scm | 3 ---
gnu/packages/firmware.scm | 4 ----
gnu/packages/kde.scm | 3 ---
gnu/packages/libcanberra.scm | 6 +-----
gnu/packages/libreoffice.scm | 4 ----
gnu/packages/linphone.scm | 4 ----
gnu/packages/mes.scm | 5 -----
gnu/packages/mingw.scm | 6 ------
gnu/packages/serialization.scm | 5 +----
gnu/packages/sync.scm | 2 --
gnu/packages/syncthing.scm | 2 --
gnu/packages/telephony.scm | 12 ------------
gnu/packages/terminals.scm | 1 -
gnu/packages/version-control.scm | 2 --
gnu/packages/video.scm | 7 -------
gnu/packages/wm.scm | 3 ---
21 files changed, 2 insertions(+), 78 deletions(-)

Toggle diff (460 lines)
diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index 5d586e6f36..a1229c11d0 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -101,7 +101,6 @@ (define-module (gnu packages admin)
#:use-module (gnu packages acl)
#:use-module (gnu packages algebra)
#:use-module (gnu packages attr)
- #:use-module (gnu packages autogen)
#:use-module (gnu packages autotools)
#:use-module (gnu packages base)
#:use-module (gnu packages bash)
@@ -112,7 +111,6 @@ (define-module (gnu packages admin)
#:use-module (gnu packages compression)
#:use-module (gnu packages crates-graphics)
#:use-module (gnu packages crates-io)
- #:use-module (gnu packages cross-base)
#:use-module (gnu packages crypto)
#:use-module (gnu packages cryptsetup)
#:use-module (gnu packages curl)
@@ -140,7 +138,6 @@ (define-module (gnu packages admin)
#:use-module (gnu packages inkscape)
#:use-module (gnu packages kerberos)
#:use-module (gnu packages libbsd)
- #:use-module (gnu packages libftdi)
#:use-module (gnu packages libunwind)
#:use-module (gnu packages libusb)
#:use-module (gnu packages linux)
@@ -160,11 +157,9 @@ (define-module (gnu packages admin)
#:use-module (gnu packages perl-check)
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages polkit)
- #:use-module (gnu packages popt)
#:use-module (gnu packages python)
#:use-module (gnu packages python-build)
#:use-module (gnu packages python-crypto)
- #:use-module (gnu packages python-web)
#:use-module (gnu packages python-xyz)
#:use-module (gnu packages qt)
#:use-module (gnu packages readline)
diff --git a/gnu/packages/avr.scm b/gnu/packages/avr.scm
index abca60eeac..2c107c6f60 100644
--- a/gnu/packages/avr.scm
+++ b/gnu/packages/avr.scm
@@ -31,7 +31,6 @@ (define-module (gnu packages avr)
#:use-module (guix packages)
#:use-module (guix build-system gnu)
#:use-module (guix build-system trivial)
- #:use-module (gnu packages)
#:use-module (gnu packages check)
#:use-module (gnu packages compression)
#:use-module (gnu packages cross-base)
diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm
index 5a3d5aced5..702e243270 100644
--- a/gnu/packages/base.scm
+++ b/gnu/packages/base.scm
@@ -49,7 +49,6 @@ (define-module (gnu packages base)
#:use-module (gnu packages bash)
#:use-module (gnu packages bison)
#:use-module (gnu packages ed)
- #:use-module (gnu packages gawk)
#:use-module (gnu packages gcc)
#:use-module (gnu packages guile)
#:use-module (gnu packages multiprecision)
diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
index 1c47636341..1124eca837 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -36,8 +36,6 @@
(define-module (gnu packages bootloaders)
#:use-module (gnu packages)
- #:use-module (gnu packages admin)
- #:use-module (gnu packages algebra)
#:use-module (gnu packages assembly)
#:use-module (gnu packages base)
#:use-module (gnu packages disk)
diff --git a/gnu/packages/cran.scm b/gnu/packages/cran.scm
index b6a01a99b0..dc3efcaf43 100644
--- a/gnu/packages/cran.scm
+++ b/gnu/packages/cran.scm
@@ -62,7 +62,6 @@ (define-module (gnu packages cran)
#:use-module (guix utils)
#:use-module (guix build-system gnu)
#:use-module (guix build-system r)
- #:use-module (gnu packages)
#:use-module (gnu packages algebra)
#:use-module (gnu packages autotools)
#:use-module (gnu packages base)
@@ -79,7 +78,6 @@ (define-module (gnu packages cran)
#:use-module (gnu packages ghostscript)
#:use-module (gnu packages gl)
#:use-module (gnu packages gnome)
- #:use-module (gnu packages graph)
#:use-module (gnu packages gtk)
#:use-module (gnu packages haskell-xyz)
#:use-module (gnu packages icu4c)
diff --git a/gnu/packages/emulators.scm b/gnu/packages/emulators.scm
index 1d50c9ef01..ce61f935fb 100644
--- a/gnu/packages/emulators.scm
+++ b/gnu/packages/emulators.scm
@@ -56,7 +56,6 @@ (define-module (gnu packages emulators)
#:use-module (gnu packages bash)
#:use-module (gnu packages bison)
#:use-module (gnu packages boost)
- #:use-module (gnu packages build-tools)
#:use-module (gnu packages cdrom)
#:use-module (gnu packages check)
#:use-module (gnu packages compression)
@@ -72,7 +71,6 @@ (define-module (gnu packages emulators)
#:use-module (gnu packages freedesktop)
#:use-module (gnu packages fribidi)
#:use-module (gnu packages game-development)
- #:use-module (gnu packages gcc)
#:use-module (gnu packages gettext)
#:use-module (gnu packages gl)
#:use-module (gnu packages glib)
@@ -102,7 +100,6 @@ (define-module (gnu packages emulators)
#:use-module (gnu packages upnp)
#:use-module (gnu packages video)
#:use-module (gnu packages vulkan)
- #:use-module (gnu packages wxwidgets)
#:use-module (gnu packages xdisorg)
#:use-module (gnu packages xiph)
#:use-module (gnu packages xml)
diff --git a/gnu/packages/firmware.scm b/gnu/packages/firmware.scm
index 2e2c4af796..cbb24230de 100644
--- a/gnu/packages/firmware.scm
+++ b/gnu/packages/firmware.scm
@@ -40,7 +40,6 @@ (define-module (gnu packages firmware)
#:use-module (guix build-system trivial)
#:use-module (gnu packages)
#:use-module (gnu packages admin)
- #:use-module (gnu packages autotools)
#:use-module (gnu packages assembly)
#:use-module (gnu packages backup)
#:use-module (gnu packages base)
@@ -58,7 +57,6 @@ (define-module (gnu packages firmware)
#:use-module (gnu packages gettext)
#:use-module (gnu packages glib)
#:use-module (gnu packages gnome)
- #:use-module (gnu packages gnupg)
#:use-module (gnu packages gtk)
#:use-module (gnu packages hardware)
#:use-module (gnu packages libusb)
@@ -71,13 +69,11 @@ (define-module (gnu packages firmware)
#:use-module (gnu packages polkit)
#:use-module (gnu packages protobuf)
#:use-module (gnu packages python)
- #:use-module (gnu packages python-build)
#:use-module (gnu packages python-xyz)
#:use-module (gnu packages shells)
#:use-module (gnu packages sqlite)
#:use-module (gnu packages tls)
#:use-module (gnu packages version-control)
- #:use-module (gnu packages web)
#:use-module (gnu packages xml)
#:use-module (ice-9 match))
diff --git a/gnu/packages/kde.scm b/gnu/packages/kde.scm
index 9e5ac767b8..20fbb41d73 100644
--- a/gnu/packages/kde.scm
+++ b/gnu/packages/kde.scm
@@ -36,13 +36,11 @@
(define-module (gnu packages kde)
#:use-module (guix build-system cmake)
#:use-module (guix build-system qt)
- #:use-module (guix deprecation)
#:use-module (guix download)
#:use-module (guix gexp)
#:use-module (guix git-download)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix packages)
- #:use-module (guix utils)
#:use-module (gnu packages)
#:use-module (gnu packages algebra)
#:use-module (gnu packages apr)
@@ -69,7 +67,6 @@ (define-module (gnu packages kde)
#:use-module (gnu packages gettext)
#:use-module (gnu packages ghostscript)
#:use-module (gnu packages gimp)
- #:use-module (gnu packages gl)
#:use-module (gnu packages glib)
#:use-module (gnu packages gnome)
#:use-module (gnu packages gperf)
diff --git a/gnu/packages/libcanberra.scm b/gnu/packages/libcanberra.scm
index c0ec47a445..cf38ac113e 100644
--- a/gnu/packages/libcanberra.scm
+++ b/gnu/packages/libcanberra.scm
@@ -25,10 +25,8 @@ (define-module (gnu packages libcanberra)
#:use-module (gnu packages)
#:use-module (guix packages)
#:use-module (guix download)
- #:use-module (guix git-download)
#:use-module (guix build-system gnu)
#:use-module (guix build-system python)
- #:use-module (guix utils)
#:use-module (gnu packages autotools)
#:use-module (gnu packages gstreamer)
#:use-module (gnu packages gtk)
@@ -36,9 +34,7 @@ (define-module (gnu packages libcanberra)
#:use-module (gnu packages linux)
#:use-module (gnu packages pulseaudio)
#:use-module (gnu packages pkg-config)
- #:use-module (gnu packages python)
- #:use-module (gnu packages xiph)
- #:use-module ((srfi srfi-1) #:select (alist-delete)))
+ #:use-module (gnu packages xiph))
(define-public libcanberra
(package
diff --git a/gnu/packages/libreoffice.scm b/gnu/packages/libreoffice.scm
index d06166e64a..71131ca1f3 100644
--- a/gnu/packages/libreoffice.scm
+++ b/gnu/packages/libreoffice.scm
@@ -44,7 +44,6 @@ (define-module (gnu packages libreoffice)
#:use-module (ice-9 match)
#:use-module (gnu packages)
#:use-module (gnu packages aidc)
- #:use-module (gnu packages aspell)
#:use-module (gnu packages autotools)
#:use-module (gnu packages base)
#:use-module (gnu packages bison)
@@ -73,10 +72,8 @@ (define-module (gnu packages libreoffice)
#:use-module (gnu packages hunspell)
#:use-module (gnu packages icu4c)
#:use-module (gnu packages image)
- #:use-module (gnu packages java)
#:use-module (gnu packages linux)
#:use-module (gnu packages logging)
- #:use-module (gnu packages m4)
#:use-module (gnu packages maths)
#:use-module (gnu packages nss)
#:use-module (gnu packages openldap)
@@ -87,7 +84,6 @@ (define-module (gnu packages libreoffice)
#:use-module (gnu packages python)
#:use-module (gnu packages rdf)
#:use-module (gnu packages scanner)
- #:use-module (gnu packages textutils)
#:use-module (gnu packages tls)
#:use-module (gnu packages version-control)
#:use-module (gnu packages xml)
diff --git a/gnu/packages/linphone.scm b/gnu/packages/linphone.scm
index 7d87ee602c..48a30f32d0 100644
--- a/gnu/packages/linphone.scm
+++ b/gnu/packages/linphone.scm
@@ -34,11 +34,8 @@ (define-module (gnu packages linphone)
#:use-module (gnu packages documentation)
#:use-module (gnu packages gettext)
#:use-module (gnu packages gl)
- #:use-module (gnu packages glib)
#:use-module (gnu packages gnome)
- #:use-module (gnu packages gnome-xyz)
#:use-module (gnu packages graphviz)
- #:use-module (gnu packages gtk)
#:use-module (gnu packages image)
#:use-module (gnu packages linux)
#:use-module (gnu packages ncurses)
@@ -49,7 +46,6 @@ (define-module (gnu packages linphone)
#:use-module (gnu packages python)
#:use-module (gnu packages python-xyz)
#:use-module (gnu packages qt)
- #:use-module (gnu packages java)
#:use-module (gnu packages sqlite)
#:use-module (gnu packages telephony)
#:use-module (gnu packages tls)
diff --git a/gnu/packages/mes.scm b/gnu/packages/mes.scm
index 4176977375..a7924d943d 100644
--- a/gnu/packages/mes.scm
+++ b/gnu/packages/mes.scm
@@ -24,15 +24,10 @@
(define-module (gnu packages mes)
#:use-module (gnu packages)
#:use-module (gnu packages base)
- #:use-module (gnu packages bash)
- #:use-module (gnu packages bootstrap)
- #:use-module (gnu packages compression)
#:use-module (gnu packages cross-base)
- #:use-module (gnu packages gcc)
#:use-module (gnu packages graphviz)
#:use-module (gnu packages guile)
#:use-module (gnu packages man)
- #:use-module (gnu packages package-management)
#:use-module (gnu packages perl)
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages texinfo)
diff --git a/gnu/packages/mingw.scm b/gnu/packages/mingw.scm
index 4eeefe1490..0ac6f0e767 100644
--- a/gnu/packages/mingw.scm
+++ b/gnu/packages/mingw.scm
@@ -22,16 +22,10 @@
(define-module (gnu packages mingw)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (gnu packages)
- #:use-module (gnu packages base)
#:use-module (gnu packages cross-base)
- #:use-module (gnu packages gcc)
- #:use-module (gnu packages compression)
- #:use-module (gnu packages multiprecision)
#:use-module (guix build-system gnu)
#:use-module (guix packages)
#:use-module (guix download)
- #:use-module (guix utils)
- #:use-module (ice-9 match)
#:export (make-mingw-w64))
(define* (make-mingw-w64 machine
diff --git a/gnu/packages/serialization.scm b/gnu/packages/serialization.scm
index c17d417d5e..d0b4bd2735 100644
--- a/gnu/packages/serialization.scm
+++ b/gnu/packages/serialization.scm
@@ -52,8 +52,6 @@ (define-module (gnu packages serialization)
#:use-module (gnu packages boost)
#:use-module (gnu packages check)
#:use-module (gnu packages compression)
- #:use-module (gnu packages cmake)
- #:use-module (gnu packages cpp)
#:use-module (gnu packages databases)
#:use-module (gnu packages documentation)
#:use-module (gnu packages gcc)
@@ -64,8 +62,7 @@ (define-module (gnu packages serialization)
#:use-module (gnu packages python-build)
#:use-module (gnu packages python-check)
#:use-module (gnu packages python-science)
- #:use-module (gnu packages python-xyz)
- #:use-module (gnu packages perl))
+ #:use-module (gnu packages python-xyz))
(define-public avro-cpp-1.9
(package
diff --git a/gnu/packages/sync.scm b/gnu/packages/sync.scm
index 8235332cb0..c4410c67fd 100644
--- a/gnu/packages/sync.scm
+++ b/gnu/packages/sync.scm
@@ -50,7 +50,6 @@ (define-module (gnu packages sync)
#:use-module (gnu packages freedesktop)
#:use-module (gnu packages glib)
#:use-module (gnu packages gnome)
- #:use-module (gnu packages golang)
#:use-module (gnu packages graphviz)
#:use-module (gnu packages image)
#:use-module (gnu packages kde-frameworks)
@@ -62,7 +61,6 @@ (define-module (gnu packages sync)
#:use-module (gnu packages perl)
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages python)
- #:use-module (gnu packages python-xyz)
#:use-module (gnu packages qt)
#:use-module (gnu packages readline)
#:use-module (gnu packages rsync)
diff --git a/gnu/packages/syncthing.scm b/gnu/packages/syncthing.scm
index 414395251b..57f5235616 100644
--- a/gnu/packages/syncthing.scm
+++ b/gnu/packages/syncthing.scm
@@ -38,9 +38,7 @@ (define-module (gnu packages syncthing)
#:use-module (gnu packages golang)
#:use-module (gnu packages gtk)
#:use-module (gnu packages linux)
- #:use-module (gnu packages python)
#:use-module (gnu packages python-crypto)
- #:use-module (gnu packages python-xyz)
#:use-module (gnu packages time))
(define-public syncthing
diff --git a/gnu/packages/telephony.scm b/gnu/packages/telephony.scm
index aa65c4eaad..42158784ca 100644
--- a/gnu/packages/telephony.scm
+++ b/gnu/packages/telephony.scm
@@ -44,7 +44,6 @@ (define-module (gnu packages telephony)
#:use-module (guix gexp)
#:use-module (gnu packages)
#:use-module (gnu packages admin)
- #:use-module (gnu packages aidc)
#:use-module (gnu packages algebra)
#:use-module (gnu packages autotools)
#:use-module (gnu packages avahi)
@@ -52,23 +51,17 @@ (define-module (gnu packages telephony)
#:use-module (gnu packages base)
#:use-module (gnu packages boost)
#:use-module (gnu packages check)
- #:use-module (gnu packages compression)
#:use-module (gnu packages cpp)
- #:use-module (gnu packages crypto)
#:use-module (gnu packages databases)
#:use-module (gnu packages sqlite)
#:use-module (gnu packages docbook)
#:use-module (gnu packages documentation)
#:use-module (gnu packages file)
#:use-module (gnu packages protobuf)
- #:use-module (gnu packages gettext)
#:use-module (gnu packages gl)
#:use-module (gnu packages glib)
- #:use-module (gnu packages gnome)
#:use-module (gnu packages gnupg)
- #:use-module (gnu packages gtk)
#:use-module (gnu packages image)
- #:use-module (gnu packages libcanberra)
#:use-module (gnu packages libusb)
#:use-module (gnu packages linphone)
#:use-module (gnu packages linux)
@@ -77,7 +70,6 @@ (define-module (gnu packages telephony)
#:use-module (gnu packages ncurses)
#:use-module (gnu packages netpbm)
#:use-module (gnu packages networking)
- #:use-module (gnu packages pcre)
#:use-module (gnu packages perl)
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages pulseaudio)
@@ -85,12 +77,8 @@ (define-module (gnu packages telephony)
#:use-module (gnu packages qt)
#:use-module (gnu packages samba)
#:use-module (gnu packages security-token)
- #:use-module (gnu packages serialization)
#:use-module (gnu packages speech)
#:use-module (gnu packages tls)
- #:use-module (gnu packages upnp)
- #:use-module (gnu packages video)
- #:use-module (gnu packages webkit)
#:use-module (gnu packages xiph)
#:use-module (gnu packages xorg)
#:use-module (gnu packages xml)
diff --git a/gnu/packages/terminals.scm b/gnu/packages/terminals.scm
index 43aeac9fd7..aedf9309e0 100644
--- a/gnu/packages/terminals.scm
+++ b/gnu/packages/terminals.scm
@@ -102,7 +102,6 @@ (define-module (gnu packages terminals)
#:use-module (gnu packages protobuf)
#:use-module (gnu packages python)
#:use-module (gnu packages python-check)
- #:use-module (gnu packages python-web)
#:use-module (gnu packages python-xyz)
#:use-module (gnu packages qt)
#:use-module (gnu packages serialization)
diff --git a/gnu/packages/version-control.scm b/gnu/packages/version-control.scm
index 86dcea908c..cf3c4d4e19 100644
--- a/gnu/packages/version-control.scm
+++ b/gnu/packages/version-control.scm
@@ -115,7 +115,6 @@ (define-module (gnu packages version-control)
#:use-module (gnu packages ncurses)
#:use-module (gnu packages ssh)
#:use-module (gnu packages web)
- #:use-module (gnu packages openstack)
#:use-module (gnu packages pcre)
#:use-module (gnu packages perl)
#:use-module (gnu packages perl-check)
@@ -128,7 +127,6 @@ (define-module (gnu packages version-control)
#:use-module (gnu packages python-web)
#:use-module (gnu packages python-xyz)
#:use-module (gnu packages readline)
- #:use-module (gnu packages rsync)
#:use-module (gnu packages ruby)
#:use-module (gnu packages sqlite)
#:use-module (gnu packages texinfo)
diff --git a/gnu/packages/video.scm b/gnu/packages/video.scm
index 153fe354d5..d959a7bcc4 100644
--- a/gnu/packages/video.scm
+++ b/gnu/packages/video.scm
@@ -117,10 +117,8 @@ (define-module (gnu packages video)
#:use-module (gnu packages bash)
#:use-module (gnu packages bi
This message was truncated. Download the full message here.
M
M
Maxim Cournoyer wrote on 11 Sep 2023 06:26
[PATCH 4/4] doc: Add new 'Circular Module Dependencies' section.
(address . 65860@debbugs.gnu.org)
cd03c264f30168e220dcc63f5e112bf518b92f2d.1694406360.git.maxim.cournoyer@gmail.com
* doc/contributing.texi (Circular Module Dependencies): New subsection.

---

doc/contributing.texi | 56 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)

Toggle diff (76 lines)
diff --git a/doc/contributing.texi b/doc/contributing.texi
index a0da871f1a..67ceff4fdb 100644
--- a/doc/contributing.texi
+++ b/doc/contributing.texi
@@ -449,6 +449,7 @@ Packaging Guidelines
* Version Numbers:: When the name is not enough.
* Synopses and Descriptions:: Helping users find the right package.
* Snippets versus Phases:: Whether to use a snippet, or a build phase.
+* Cyclic Module Dependencies:: Going full circle.
* Emacs Packages:: Your Elisp fix.
* Python Modules:: A touch of British comedy.
* Perl Modules:: Little pearls.
@@ -720,6 +721,61 @@ Snippets versus Phases
using build phases. Refer to the @code{origin} record documentation for
more information (@pxref{origin Reference}).
+@node Cyclic Module Dependencies
+@subsection Cyclic Module Dependencies
+
+While there cannot be circular dependencies between packages, Guile's
+lax module loading mechanism allows circular dependencies between Guile
+modules, which doesn't cause problems as long as the following
+conditions are followed for two modules part of a dependency cycle:
+
+@cindex rules to cope with circular module dependencies
+@enumerate
+@item
+Macros are not shared between the co-dependent modules
+@item
+Top-level variables are only referenced in delayed (@i{thunked}) package
+fields: @code{arguments}, @code{native-inputs}, @code{inputs},
+@code{propagated-inputs} or @code{replacement}
+@item
+Procedures referencing top-level variables from another module are not
+called at the top level of a module themselves.
+@end enumerate
+
+Straying away from the above rules may work while there are no
+dependency cycles between modules, but given such cycles are confusing
+and difficult to troubleshoot, it is best to follow the rules to avoid
+introducing problems down the line.
+
+@noindent
+Here is a common trap to avoid:
+
+@lisp
+(define-public avr-binutils
+ (package
+ (inherit (cross-binutils "avr"))
+ (name "avr-binutils")))
+@end lisp
+
+In the above example, the @code{avr-binutils} package was defined in the
+module @code{(gnu packages avr)}, and the @code{cross-binutils}
+procedure in @code{(gnu packages cross-base)}. Because the
+@code{inherit} field is not delayed (thunked), it is evaluated at the
+top level at load time, which is problematic in the presence of module
+dependency cycles. This could be resolved by turning the package into a
+procedure instead, like:
+
+@lisp
+(define (make-avr-binutils)
+ (package
+ (inherit (cross-binutils "avr"))
+ (name "avr-binutils")))
+@end lisp
+
+Care would need to be taken to ensure the above procedure is only ever
+used in a package delayed fields or within another procedure also not
+called at the top level.
+
@node Emacs Packages
@subsection Emacs Packages
--
2.41.0
L
L
Ludovic Courtès wrote on 13 Sep 2023 22:06
Re: [bug#65860] [PATCH 3/4] gnu: Remove extraneous imports.
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
87cyylltx7.fsf@gnu.org
Hi,

Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:

Toggle quote (3 lines)
> Found by running 'guild compile -W3 gnu/packages/$module.scm', using guild
> from the upcoming Guile.

Excellent, go for it!

(The was the motivation for ‘-Wunused-modules’.)

Ludo’.
L
L
Ludovic Courtès wrote on 13 Sep 2023 22:27
Re: bug#65860: [PATCH 0/4] Resolve a circular module dependencies in embedded modules
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)(address . 65860@debbugs.gnu.org)
87r0n1kedj.fsf_-_@gnu.org
Hi,

Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:

Toggle quote (12 lines)
> Partially addresses https://issues.guix.gnu.org/65716.
>
> * 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.

[...]

Toggle quote (42 lines)
>
> Before this change, simply adding the following import:
>
> modified gnu/packages/firmware.scm
> @@ -42,6 +42,7 @@ (define-module (gnu packages firmware)
> #:use-module (gnu packages admin)
> #:use-module (gnu packages autotools)
> #:use-module (gnu packages assembly)
> + #:use-module (gnu packages avr)
> #:use-module (gnu packages backup)
> #:use-module (gnu packages base)
> #:use-module (gnu packages bash)
>
> Would cause byte compilation and/or evaluation to fail due to a circular
> module dependency.
>
> * gnu/packages/embedded.scm: Add commentary.
> (gcc-arm-none-eabi-4.9, gcc-arm-none-eabi-6, newlib-arm-none-eabi)
> (newlib-nano-arm-none-eabi, gcc-arm-none-eabi-7-2018-q2-update)
> (newlib-arm-none-eabi-7-2018-q2-update)
> (newlib-nano-arm-none-eabi-7-2018-q2-update)
> (arm-none-eabi-toolchain-4.9, arm-none-eabi-nano-toolchain-4.9)
> (arm-none-eabi-toolchain-6, arm-none-eabi-nano-toolchain-6)
> (arm-none-eabi-toolchain-7-2018-q2-update, gdb-arm-none-eabi)
> (propeller-binutils, propeller-gcc-6, propeller-gcc-4)
> (propeller-gcc, propeller-toolchain, propeller-development-suite)
> (gcc-vc4): Turn into procedures, prefixing the procedure name with 'make-',
> and adjust all users.
> (make-libstdc++-arm-none-eabi) [arguments]: Avoid an unused warning.
> (arm-none-eabi-toolchain): Rename to...
> (make-arm-none-eabi-toolchain): ... this.
> * gnu/packages/raspberry-pi.scm (raspi-arm-chainloader) [native-inputs]:
> Replace gcc-arm-none-eabi-6 with (make-arm-none-eabi-toolchain).
> * gnu/packages/axoloti.scm (axoloti-runtime)
> [inputs]: Replace arm-none-eabi-nano-toolchain-4.9
> with (make-arm-none-eabi-nano-toolchain-4.9).
> (axoloti-patcher): Likewise.
> (axoloti-patcher-next) [inputs]: Replace
> arm-none-eabi-nano-toolchain-7-2018-q2-update
> with (make-arm-none-eabi-nano-toolchain-7-2018-q2-update).

People will lose the ability to install those toolchains, for instance
with ‘guix install propeller-toolchain’, or to upgrade profiles that
contain them (though ‘guix install axoloti-runtime’ is still good, for
instance).

I’m not sure whether that’s acceptable, but we should check with known
users of this, such as Ricardo.

I’ve always felt that these toolchains should be provided as part of the
“regular” cross-compilation framework in cross-base.scm. Packages that
always need to be cross-compiled (to AVR microcontrollers, etc.) would
have a hardcoded #:target in their ‘arguments’ field. I forgot why this
was rejected.

Thanks,
Ludo’.
M
M
Maxim Cournoyer wrote on 14 Sep 2023 05:10
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 65860@debbugs.gnu.org)
8734zhv49z.fsf@gmail.com
Hi,

Ludovic Courtès <ludo@gnu.org> writes:

Toggle quote (35 lines)
> Hi,
>
> Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:
>
>> Partially addresses <https://issues.guix.gnu.org/65716>.
>>
>> * 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.
>
> [...]
>
>> Fixes <https://issues.guix.gnu.org/65716>.
>>
>> Before this change, simply adding the following import:
>>
>> modified gnu/packages/firmware.scm
>> @@ -42,6 +42,7 @@ (define-module (gnu packages firmware)
>> #:use-module (gnu packages admin)
>> #:use-module (gnu packages autotools)
>> #:use-module (gnu packages assembly)
>> + #:use-module (gnu packages avr)
>> #:use-module (gnu packages backup)
>> #:use-module (gnu packages base)
>> #:use-module (gnu packages bash)
>>
>> Would cause byte compilation and/or evaluation to fail due to a circular
>> module dependency.

[...]

Toggle quote (8 lines)
> People will lose the ability to install those toolchains, for instance
> with ‘guix install propeller-toolchain’, or to upgrade profiles that
> contain them (though ‘guix install axoloti-runtime’ is still good, for
> instance).
>
> I’m not sure whether that’s acceptable, but we should check with known
> users of this, such as Ricardo.

It's a pity to loose that ability (it's also a pity to not be able to
simply 'guix install gcc-cross-some-target', for the same reason) but
the statu quo where pulling (gnu packages avr) causes hard to grasp
failures is worst, in my opinion. I wasn't able to work on adding
packages dependent on (gnu packages avr) for that reason. Debugging was
a pain.

Toggle quote (6 lines)
> I’ve always felt that these toolchains should be provided as part of the
> “regular” cross-compilation framework in cross-base.scm. Packages that
> always need to be cross-compiled (to AVR microcontrollers, etc.) would
> have a hardcoded #:target in their ‘arguments’ field. I forgot why this
> was rejected.

That'd be an improvement, I think. Right now we have to call a
procedure in the input fields everywhere, it's not very elegant. Until
then, the change proposed here seems the best we can do. I've been
adding new avr-dependent firmware packages in (gnu packages firmware)
happily on top of it.

--
Thanks,
Maxim
L
L
Ludovic Courtès wrote on 14 Sep 2023 11:10
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)(address . 65860@debbugs.gnu.org)
87o7i5glwr.fsf@gnu.org
Hi,

Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:

Toggle quote (2 lines)
> Ludovic Courtès <ludo@gnu.org> writes:

[...]

Toggle quote (15 lines)
>> People will lose the ability to install those toolchains, for instance
>> with ‘guix install propeller-toolchain’, or to upgrade profiles that
>> contain them (though ‘guix install axoloti-runtime’ is still good, for
>> instance).
>>
>> I’m not sure whether that’s acceptable, but we should check with known
>> users of this, such as Ricardo.
>
> It's a pity to loose that ability (it's also a pity to not be able to
> simply 'guix install gcc-cross-some-target', for the same reason) but
> the statu quo where pulling (gnu packages avr) causes hard to grasp
> failures is worst, in my opinion. I wasn't able to work on adding
> packages dependent on (gnu packages avr) for that reason. Debugging was
> a pain.

Oh yes, I’ve been there, so I can tell you I sympathize. :-)

I agree that this needs to be addressed. I wondered whether/how hard we
should search for a different solution.

Toggle quote (9 lines)
>> I’ve always felt that these toolchains should be provided as part of the
>> “regular” cross-compilation framework in cross-base.scm. Packages that
>> always need to be cross-compiled (to AVR microcontrollers, etc.) would
>> have a hardcoded #:target in their ‘arguments’ field. I forgot why this
>> was rejected.
>
> That'd be an improvement, I think. Right now we have to call a
> procedure in the input fields everywhere, it's not very elegant.

BTW, another issue with the package-returning procedures: they return a
fresh package object at each call, which defeats caching. I think you
should be able to observe it with:

GUIX_PROFILING=object-cache guix build axoloti-runtime -d --no-grafts

The effect will be more acute on the build farms since they compute
derivations for everything that depends on these toolchains.

The solution would be to make those procedures memoizing, with ‘mlambda’
or similar.

Ludo’.
M
M
Maxim Cournoyer wrote on 17 Sep 2023 22:27
Re: [bug#65860] [PATCH 3/4] gnu: Remove extraneous imports.
(name . Ludovic Courtès)(address . ludo@gnu.org)
87y1h47dgr.fsf@gmail.com
Hi,

Ludovic Courtès <ludo@gnu.org> writes:

Toggle quote (9 lines)
> Hi,
>
> Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:
>
>> Found by running 'guild compile -W3 gnu/packages/$module.scm', using guild
>> from the upcoming Guile.
>
> Excellent, go for it!

Great, I've installed this single commit to master.

--
Thanks,
Maxim
M
M
Maxim Cournoyer wrote on 18 Sep 2023 02:43
[PATCH v2 0/3] Resolve a circular module dependencies in embedded modules
(address . 65860@debbugs.gnu.org)(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
cover.1694997755.git.maxim.cournoyer@gmail.com
This series is the culmination of at least a day of effort tracking down the
source of a module dependency cycle (!). The last commit adds some guidelines
in the hope to avoid a repeat (perhaps 'lint' could be taught to
automate these checks).

Changes in v2:
- Use mlambda for procedures
- Fix ((make-avr-toolchain)) typo
- Use mlambda for procedures

Maxim Cournoyer (3):
gnu: avr: Delay all cross compilation packages.
gnu: embedded: Turn packages using top-level variables into
procedures.
doc: Add new 'Circular Module Dependencies' section.

doc/contributing.texi | 56 ++
gnu/packages/avr-xyz.scm | 2 +-
gnu/packages/avr.scm | 214 +++---
gnu/packages/axoloti.scm | 6 +-
gnu/packages/embedded.scm | 1227 ++++++++++++++++++---------------
gnu/packages/raspberry-pi.scm | 2 +-
6 files changed, 838 insertions(+), 669 deletions(-)


base-commit: fc1b4756e36857e66986a30a6652ee988f8f30fd
--
2.41.0
M
M
Maxim Cournoyer wrote on 18 Sep 2023 02:43
[PATCH v2 1/3] gnu: avr: Delay all cross compilation packages.
(address . 65860@debbugs.gnu.org)(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
9431a70a1d444c86ff64f8386740e40e036e6b0a.1694997755.git.maxim.cournoyer@gmail.com

* 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(-)

Toggle diff (258 lines)
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
--
2.41.0
M
M
Maxim Cournoyer wrote on 18 Sep 2023 02:43
[PATCH v2 2/3] gnu: embedded: Turn packages using top-level variables into procedures.
(address . 65860@debbugs.gnu.org)(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
a54f810ef408b3a91cf6d1b0b1c81380b4fea0b7.1694997755.git.maxim.cournoyer@gmail.com

Before this change, simply adding the following import:

modified gnu/packages/firmware.scm
@@ -42,6 +42,7 @@ (define-module (gnu packages firmware)
#:use-module (gnu packages admin)
#:use-module (gnu packages autotools)
#:use-module (gnu packages assembly)
+ #:use-module (gnu packages avr)
#:use-module (gnu packages backup)
#:use-module (gnu packages base)
#:use-module (gnu packages bash)

Would cause byte compilation and/or evaluation to fail due to a circular
module dependency.

* gnu/packages/embedded.scm: Add commentary.
(gcc-arm-none-eabi-4.9, gcc-arm-none-eabi-6, newlib-arm-none-eabi)
(newlib-nano-arm-none-eabi, gcc-arm-none-eabi-7-2018-q2-update)
(newlib-arm-none-eabi-7-2018-q2-update)
(newlib-nano-arm-none-eabi-7-2018-q2-update)
(arm-none-eabi-toolchain-4.9, arm-none-eabi-nano-toolchain-4.9)
(arm-none-eabi-toolchain-6, arm-none-eabi-nano-toolchain-6)
(arm-none-eabi-toolchain-7-2018-q2-update, gdb-arm-none-eabi)
(propeller-binutils, propeller-gcc-6, propeller-gcc-4)
(propeller-gcc, propeller-toolchain, propeller-development-suite)
(gcc-vc4): Turn into procedures, prefixing the procedure name with 'make-',
and adjust all users.
(make-libstdc++-arm-none-eabi) [arguments]: Avoid an unused warning.
(arm-none-eabi-toolchain): Rename to...
(make-arm-none-eabi-toolchain): ... this.
* gnu/packages/raspberry-pi.scm (raspi-arm-chainloader) [native-inputs]:
Replace gcc-arm-none-eabi-6 with (make-arm-none-eabi-toolchain).
* gnu/packages/axoloti.scm (axoloti-runtime)
[inputs]: Replace arm-none-eabi-nano-toolchain-4.9
with (make-arm-none-eabi-nano-toolchain-4.9).
(axoloti-patcher): Likewise.
(axoloti-patcher-next) [inputs]: Replace
arm-none-eabi-nano-toolchain-7-2018-q2-update
with (make-arm-none-eabi-nano-toolchain-7-2018-q2-update).

---

Changes in v2:
- Use mlambda for procedures

gnu/packages/axoloti.scm | 6 +-
gnu/packages/embedded.scm | 1227 ++++++++++++++++++---------------
gnu/packages/raspberry-pi.scm | 2 +-
3 files changed, 663 insertions(+), 572 deletions(-)

Toggle diff (389 lines)
diff --git a/gnu/packages/axoloti.scm b/gnu/packages/axoloti.scm
index e0dd22c627c..7b369228603 100644
--- a/gnu/packages/axoloti.scm
+++ b/gnu/packages/axoloti.scm
@@ -199,7 +199,7 @@ (define-public axoloti-runtime
;; for compiling patches
("make" ,gnu-make)
;; for compiling firmware
- ("cross-toolchain" ,arm-none-eabi-nano-toolchain-4.9)
+ ("cross-toolchain" ,(make-arm-none-eabi-nano-toolchain-4.9))
;; for uploading compiled patches and firmware
("dfu-util" ,dfu-util-for-axoloti)))
(native-inputs
@@ -339,7 +339,7 @@ (define-public axoloti-patcher
(assoc-ref ant:%standard-phases 'strip-jar-timestamps)))))
(inputs
`(("icedtea" ,icedtea "jdk")
- ("cross-toolchain" ,arm-none-eabi-nano-toolchain-4.9)
+ ("cross-toolchain" ,(make-arm-none-eabi-nano-toolchain-4.9))
("java-simple-xml" ,java-simple-xml)
("java-rsyntaxtextarea" ,java-rsyntaxtextarea)
("java-usb4java" ,java-usb4java)
@@ -572,7 +572,7 @@ (define-public axoloti-patcher-next
(assoc-ref ant:%standard-phases 'strip-jar-timestamps)))))
(inputs
`(("jdk" ,icedtea "jdk")
- ("cross-toolchain" ,arm-none-eabi-nano-toolchain-7-2018-q2-update)
+ ("cross-toolchain" ,(make-arm-none-eabi-nano-toolchain-7-2018-q2-update))
;; for compiling patches
("make" ,gnu-make)
;; for uploading compiled patches and firmware
diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
index 325013a627c..42abd3398f0 100644
--- a/gnu/packages/embedded.scm
+++ b/gnu/packages/embedded.scm
@@ -11,7 +11,7 @@
;;; Copyright © 2020, 2021, 2022 Simon South <simon@simonsouth.net>
;;; Copyright © 2021 Morgan Smith <Morgan.J.Smith@outlook.com>
;;; Copyright © 2022 Mathieu Othacehe <othacehe@gnu.org>
-;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2022, 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2023 Janneke Nieuwenhuizen <janneke@gnu.org>
;;;
;;; This file is part of GNU Guix.
@@ -34,6 +34,7 @@ (define-module (gnu packages embedded)
#:use-module (guix packages)
#:use-module (guix download)
#:use-module (guix gexp)
+ #:use-module (guix memoization)
#:use-module (guix svn-download)
#:use-module (guix git-download)
#:use-module ((guix licenses) #:prefix license:)
@@ -73,442 +74,519 @@ (define-module (gnu packages embedded)
#:use-module (gnu packages tls)
#:use-module (gnu packages version-control)
#:use-module (gnu packages xorg)
- #:use-module (srfi srfi-1))
+ #:use-module (srfi srfi-1)
+ #:export (make-gcc-arm-none-eabi-4.9
+ make-gcc-arm-none-eabi-6
+ make-gcc-arm-none-eabi-7-2018-q2-update
+
+ make-gcc-vc4
+
+ make-newlib-arm-none-eabi
+ make-newlib-arm-none-eabi-7-2018-q2-update
+
+ make-newlib-nano-arm-none-eabi
+ make-newlib-nano-arm-none-eabi-7-2018-q2-update
+
+ make-arm-none-eabi-toolchain-4.9
+ make-arm-none-eabi-toolchain-6
+ make-arm-none-eabi-toolchain-7-2018-q2-update
+
+ make-arm-none-eabi-nano-toolchain-4.9
+ make-arm-none-eabi-nano-toolchain-6
+ make-arm-none-eabi-nano-toolchain-7-2018-q2-update
+
+ make-gdb-arm-none-eabi
+
+ make-propeller-gcc
+ make-propeller-gcc-4
+ make-propeller-gcc-6
+ make-propeller-toolchain
+ make-propeller-development-suite))
+
+;;; Commentary:
+;;;
+;;; This modules contains toolchain generators as well as packages for use in
+;;; embedded contexts. Note: the toolchain and specialized packages are
+;;; procedures, so as to delay their references to top level bindings such as
+;;; 'gcc' or 'cross-gcc', etc.
+;;;
;; We must not use the released GCC sources here, because the cross-compiler
;; does not produce working binaries. Instead we take the very same SVN
;; revision from the branch that is used for a release of the "GCC ARM
;; embedded" project on launchpad.
;; See https://launchpadlibrarian.net/218827644/release.txt
-(define-public gcc-arm-none-eabi-4.9
- (let ((xgcc (cross-gcc "arm-none-eabi"
- #:xgcc gcc-4.9
- #:xbinutils (cross-binutils "arm-none-eabi")))
- (revision "1")
- (svn-revision 227977))
- (package (inherit xgcc)
- (version (string-append (package-version xgcc) "-"
- revision "." (number->string svn-revision)))
- (source
- (origin
- (method svn-fetch)
- (uri (svn-reference
- (url "svn://gcc.gnu.org/svn/gcc/branches/ARM/embedded-4_9-branch/")
- (revision svn-revision)))
- (file-name (string-append "gcc-arm-embedded-" version "-checkout"))
- (sha256
- (base32
- "113r98kygy8rrjfv2pd3z6zlfzbj543pq7xyq8bgh72c608mmsbr"))
+(define make-gcc-arm-none-eabi-4.9
+ (mlambda ()
+ (let ((xgcc (cross-gcc "arm-none-eabi"
+ #:xgcc gcc-4.9
+ #:xbinutils (cross-binutils "arm-none-eabi")))
+ (revision "1")
+ (svn-revision 227977))
+ (package
+ (inherit xgcc)
+ (version (string-append (package-version xgcc) "-"
+ revision "." (number->string svn-revision)))
+ (source
+ (origin
+ (method svn-fetch)
+ (uri (svn-reference
+ (url "svn://gcc.gnu.org/svn/gcc/branches/ARM/\
+embedded-4_9-branch/")
+ (revision svn-revision)))
+ (file-name (string-append "gcc-arm-embedded-" version "-checkout"))
+ (sha256
+ (base32
+ "113r98kygy8rrjfv2pd3z6zlfzbj543pq7xyq8bgh72c608mmsbr"))
- (patches (cons (search-patch "gcc-4.9-inline.patch")
- ;; Remove the one patch that doesn't apply to this 4.9
- ;; snapshot (the patch is for 4.9.4 and later but this
- ;; svn snapshot is older).
- (remove (lambda (patch)
- (string=? (basename patch)
- "gcc-arm-bug-71399.patch"))
- (origin-patches (package-source xgcc)))))))
- (native-inputs
- `(("flex" ,flex)
- ("gcc@5" ,gcc-5)
- ,@(package-native-inputs 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)
- ;; 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=armv6-m,armv7-m,armv7e-m"
- "--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")
- (delete "--disable-multilib" #$flags)))))
- (native-search-paths
- (list (search-path-specification
- (variable "CROSS_C_INCLUDE_PATH")
- (files '("arm-none-eabi/include")))
- (search-path-specification
- (variable "CROSS_CPLUS_INCLUDE_PATH")
- (files '("arm-none-eabi/include"
- "arm-none-eabi/include/c++"
- "arm-none-eabi/include/c++/arm-none-eabi")))
- (search-path-specification
- (variable "CROSS_LIBRARY_PATH")
- (files '("arm-none-eabi/lib"))))))))
+ (patches (cons (search-patch "gcc-4.9-inline.patch")
+ ;; Remove the one patch that doesn't apply to this
+ ;; 4.9 snapshot (the patch is for 4.9.4 and later
+ ;; but this svn snapshot is older).
+ (remove (lambda (patch)
+ (string=? (basename patch)
+ "gcc-arm-bug-71399.patch"))
+ (origin-patches (package-source xgcc)))))))
+ (native-inputs
+ `(("flex" ,flex)
+ ("gcc@5" ,gcc-5)
+ ,@(package-native-inputs 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)
+ ;; 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=armv6-m,armv7-m,armv7e-m"
+ "--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")
+ (delete "--disable-multilib" #$flags)))))
+ (native-search-paths
+ (list (search-path-specification
+ (variable "CROSS_C_INCLUDE_PATH")
+ (files '("arm-none-eabi/include")))
+ (search-path-specification
+ (variable "CROSS_CPLUS_INCLUDE_PATH")
+ (files '("arm-none-eabi/include"
+ "arm-none-eabi/include/c++"
+ "arm-none-eabi/include/c++/arm-none-eabi")))
+ (search-path-specification
+ (variable "CROSS_LIBRARY_PATH")
+ (files '("arm-none-eabi/lib")))))))))
-(define-public gcc-arm-none-eabi-6
- (package
- (inherit gcc-arm-none-eabi-4.9)
- (version (package-version gcc-6))
- (source (origin (inherit (package-source gcc-6))
- (patches
- (append
- (origin-patches (package-source gcc-6))
- (search-patches "gcc-6-cross-environment-variables.patch"
- "gcc-6-arm-none-eabi-multilib.patch")))))))
+(define make-gcc-arm-none-eabi-6
+ (mlambda ()
+ (package
+ (inherit (make-gcc-arm-none-eabi-4.9))
+ (version (package-version gcc-6))
+ (source (origin
+ (inherit (package-source gcc-6))
+ (patches
+ (append
+ (origin-patches (package-source gcc-6))
+ (search-patches "gcc-6-cross-environment-variables.patch"
+ "gcc-6-arm-none-eabi-multilib.patch"))))))))
-(define-public newlib-arm-none-eabi
- (package
- (name "newlib")
- (version "2.4.0")
- (source (origin
- (method url-fetch)
- (uri (string-append "ftp://sourceware.org/pub/newlib/newlib-"
- version ".tar.gz"))
- (sha256
- (base32
- "01i7qllwicf05vsvh39qj7qp5fdifpvvky0x95hjq39mbqiksnsl"))))
- (build-system gnu-build-system)
- (arguments
- `(#:out-of-source? #t
- ;; The configure flags are identical to the flags used by the "GCC ARM
- ;; embedded" project.
- #:configure-flags '("--target=arm-none-eabi"
- "--enable-newlib-io-long-long"
- "--enable-newlib-register-fini"
- "--disable-newlib-supplied-syscalls"
- "--disable-nls")
- #:phases
- (modify-phases %standard-phases
- (add-after 'unpack 'fix-references-to-/bin/sh
- (lambda _
- (substitute* '("libgloss/arm/cpu-init/Makefile.in"
- "libgloss/arm/Makefile.in"
- "libgloss/libnosys/Makefile.in"
- "libgloss/Makefile.in")
- (("/bin/sh") (which "sh")))
- #t)))))
- (native-inputs
- `(("xbinutils" ,(cross-binutils "arm-none-eabi"))
- ("xgcc" ,gcc-arm-none-eabi-4.9)
- ("texinfo" ,texinfo)))
- (home-page "https://www.sourceware.org/newlib/")
- (synopsis "C library for use on embedded systems")
- (description "Newlib is a C library intended for use on embedded
+(define make-newlib-arm-none-eabi
+ (mlambda ()
+ (package
+ (name "newlib")
+ (version "2.4.0")
+ (source (origin
+ (method url-fetch)
+ (uri (string-append "ftp://sourceware.org/pub/newlib/newlib-"
+ version ".tar.gz"))
+ (sha256
+ (base32
+ "01i7qllwicf05vsvh39qj7qp5fdifpvvky0x95hjq39mbqiksnsl"))))
+ (build-system gnu-build-system)
+ (arguments
+ `(#:out-of-source? #t
+ ;; The configure flags are identical to the flags used by the "GCC ARM
+ ;; embedded" project.
+ #:configure-flags '("--target=arm-none-eabi"
+ "--enable-newlib-io-long-long"
+ "--enable-newlib-register-fini"
+ "--disable-newlib-supplied-syscalls"
+ "--disable-nls")
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'fix-references-to-/bin/sh
+ (lambda _
+ (substitute* '("libgloss/arm/cpu-init/Makefile.in"
+ "libgloss/arm/Makefile.in"
+ "libgloss/libnosys/Makefile.in"
+ "libgloss/Makefile.in")
+ (("/bin/sh") (which "sh")))
+ #t)))))
+ (native-inputs
+ `(("xbinutils" ,(cross-binutils "arm-none-eabi"))
+ ("xgcc" ,(make-gcc-arm-none-eabi-4.9))
+ ("texinfo" ,texinfo)))
+ (home-page "https://www.sourceware.org/newlib/")
+ (synopsis "C library for use on embedded systems")
+ (description "Newlib is a C library intended for use on embedded
systems. It is a conglomeration of several library parts that are easily
usable on embedded products.")
- (license (license:non-copyleft
- "https://www.sourceware.org/newlib/COPYING.NEWLIB"))))
+ (license (license:non-copyleft
+ "https://www.sourceware.org/newlib/COPYING.NEWLIB")))))
-(define-public newlib-nano-arm-none-eabi
- (package (inherit newlib-arm-none-eabi)
- (name "newlib-nano")
- (arguments
- (substitute-keyword-arguments (package-arguments newlib-arm-none-eabi)
- ;; The configure flags are iden
This message was truncated. Download the full message here.
M
M
Maxim Cournoyer wrote on 18 Sep 2023 02:43
[PATCH v2 3/3] doc: Add new 'Circular Module Dependencies' section.
(address . 65860@debbugs.gnu.org)(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
c2b54357d9f705ce0d561f660139b7e7570f195e.1694997755.git.maxim.cournoyer@gmail.com
* doc/contributing.texi (Circular Module Dependencies): New subsection.

---

(no changes since v1)

doc/contributing.texi | 56 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)

Toggle diff (76 lines)
diff --git a/doc/contributing.texi b/doc/contributing.texi
index 156a6cb19e1..d99751f42cb 100644
--- a/doc/contributing.texi
+++ b/doc/contributing.texi
@@ -513,6 +513,7 @@ Packaging Guidelines
* Version Numbers:: When the name is not enough.
* Synopses and Descriptions:: Helping users find the right package.
* Snippets versus Phases:: Whether to use a snippet, or a build phase.
+* Cyclic Module Dependencies:: Going full circle.
* Emacs Packages:: Your Elisp fix.
* Python Modules:: A touch of British comedy.
* Perl Modules:: Little pearls.
@@ -784,6 +785,61 @@ Snippets versus Phases
using build phases. Refer to the @code{origin} record documentation for
more information (@pxref{origin Reference}).
+@node Cyclic Module Dependencies
+@subsection Cyclic Module Dependencies
+
+While there cannot be circular dependencies between packages, Guile's
+lax module loading mechanism allows circular dependencies between Guile
+modules, which doesn't cause problems as long as the following
+conditions are followed for two modules part of a dependency cycle:
+
+@cindex rules to cope with circular module dependencies
+@enumerate
+@item
+Macros are not shared between the co-dependent modules
+@item
+Top-level variables are only referenced in delayed (@i{thunked}) package
+fields: @code{arguments}, @code{native-inputs}, @code{inputs},
+@code{propagated-inputs} or @code{replacement}
+@item
+Procedures referencing top-level variables from another module are not
+called at the top level of a module themselves.
+@end enumerate
+
+Straying away from the above rules may work while there are no
+dependency cycles between modules, but given such cycles are confusing
+and difficult to troubleshoot, it is best to follow the rules to avoid
+introducing problems down the line.
+
+@noindent
+Here is a common trap to avoid:
+
+@lisp
+(define-public avr-binutils
+ (package
+ (inherit (cross-binutils "avr"))
+ (name "avr-binutils")))
+@end lisp
+
+In the above example, the @code{avr-binutils} package was defined in the
+module @code{(gnu packages avr)}, and the @code{cross-binutils}
+procedure in @code{(gnu packages cross-base)}. Because the
+@code{inherit} field is not delayed (thunked), it is evaluated at the
+top level at load time, which is problematic in the presence of module
+dependency cycles. This could be resolved by turning the package into a
+procedure instead, like:
+
+@lisp
+(define (make-avr-binutils)
+ (package
+ (inherit (cross-binutils "avr"))
+ (name "avr-binutils")))
+@end lisp
+
+Care would need to be taken to ensure the above procedure is only ever
+used in a package delayed fields or within another procedure also not
+called at the top level.
+
@node Emacs Packages
@subsection Emacs Packages
--
2.41.0
M
M
Maxim Cournoyer wrote on 18 Sep 2023 02:52
Re: bug#65860: [PATCH 0/4] Resolve a circular module dependencies in embedded modules
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 65860@debbugs.gnu.org)
877coo715m.fsf@gmail.com
Hi Ludovic,

Ludovic Courtès <ludo@gnu.org> writes:

[...]

Toggle quote (3 lines)
> I agree that this needs to be addressed. I wondered whether/how hard we
> should search for a different solution.

OK. I think the current situation needs to be resolved ASAP, but longer
term I'm definitely willing to revisit our strategy when it comes to
cross compiler toolchains.

[...]

Toggle quote (12 lines)
> BTW, another issue with the package-returning procedures: they return a
> fresh package object at each call, which defeats caching. I think you
> should be able to observe it with:
>
> GUIX_PROFILING=object-cache guix build axoloti-runtime -d --no-grafts
>
> The effect will be more acute on the build farms since they compute
> derivations for everything that depends on these toolchains.
>
> The solution would be to make those procedures memoizing, with ‘mlambda’
> or similar.

I haven't tried measuring the impact, but I've use mlambda in the v2
just sent; thanks for the suggesting it!

--
Thanks,
Maxim
L
L
Ludovic Courtès wrote on 25 Sep 2023 16:07
control message for bug #65860
(address . control@debbugs.gnu.org)
87ttri5ost.fsf@gnu.org
merge 65860 66063
quit
M
M
Maxim Cournoyer wrote on 25 Sep 2023 19:58
Re: bug#66063: [PATCH v2 0/3] Resolve a circular module dependencies in embedded modules
(name . Ludovic Courtès)(address . ludo@gnu.org)
871qem2kzh.fsf_-_@gmail.com
Hi,

Maxim Cournoyer <maxim.cournoyer@gmail.com> writes:

Toggle quote (30 lines)
> Hi Ludovic,
>
> Ludovic Courtès <ludo@gnu.org> writes:
>
> [...]
>
>> I agree that this needs to be addressed. I wondered whether/how hard we
>> should search for a different solution.
>
> OK. I think the current situation needs to be resolved ASAP, but longer
> term I'm definitely willing to revisit our strategy when it comes to
> cross compiler toolchains.
>
> [...]
>
>> BTW, another issue with the package-returning procedures: they return a
>> fresh package object at each call, which defeats caching. I think you
>> should be able to observe it with:
>>
>> GUIX_PROFILING=object-cache guix build axoloti-runtime -d --no-grafts
>>
>> The effect will be more acute on the build farms since they compute
>> derivations for everything that depends on these toolchains.
>>
>> The solution would be to make those procedures memoizing, with ‘mlambda’
>> or similar.
>
> I haven't tried measuring the impact, but I've use mlambda in the v2
> just sent; thanks for the suggesting it!

I've now pushed this series. If we can make AVR a native
target/platform in Guix, that may make things simpler/nicer, but
otherwise, this is at least resolved.

--
Thanks,
Maxim
Closed
?