help-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help with channel build system and package


From: Jesse
Subject: Re: Help with channel build system and package
Date: Thu, 8 Feb 2024 09:32:44 -0500
User-agent: Mozilla Thunderbird

Thanks for taking a look Carlo!

On 2/7/24 22:37, Carlo Zancanaro wrote:
Hi Jesse,

I know very little about what you're trying to do, but there's one thing
that looked wrong to me:

On Wed, Feb 07 2024, Jesse wrote:
...
     (build-system crosstool-ng)
...
This isn't a build system, right? It's just the package? I think you may
want crosstool-ng-build-system here.

You are totally correct here. I changed this to "(build-system crosstool-ng-build-system)" and I don't get the same error now. I also then realized I was missing "  #:use-module (embedded-dev build-system crosstool-ng)" from the list of modules in the package define-module expression in the packages/crosstool-ng.scm file. I also tracked down some other missing modules.

However, now I get this:

guix build -v3 -L embedded-dev ct-ng-riscv64-unknown-elf
guix build: warning: invalid argument list
guix build: warning: source expression failed to match any pattern
error: crosstool-ng-build-system: unbound variable
hint: Did you forget `(use-modules (embedded-dev build-system crosstool-ng))'?

guix build: error: ct-ng-riscv64-unknown-elf: unknown package

This confuses me a bit because it says that it is an unbound variable but it is defined in embedded-dev/build-system/crosstool-ng.scm. I believe I should be importing this module with the "#:use-module (embedded-dev build-system crosstool-ng)" line in the package file. The symbol should be exported with:

(define-module (embedded-dev build-system crosstool-ng)
  #:use-module (guix build-system)
  #:use-module (guix build-system gnu)
  #:export (%crosstool-ng-build-system-modules
            crosstool-ng-build
            crosstool-ng-build-system))

which is in the embedded-dev/build-system/crosstool-ng.scm file of my channel. I was mainly trying to follow some build-system setups like ruby where there are build/ruby-build-system.scm, which is used by build-system/ruby.scm, which defines and exports the ruby-build-system symbol, and that is used by the packages in packages/ruby.scm.

If I was to manually trace how the build system guile files are used from a package definition, it would look like this:

1. In packages/crosstool-ng.scm I have a package definition that uses
       (build-system crosstool-ng-build-system)

2. In that same file I have a line that should include the entry point to the crosstool-ng build system:
        #:use-module (embedded-dev build-system crosstool-ng)

3. That line should use the guile module located at embedded-dev/build-system/crosstool-ng.scm, since my build invocation looks like: "guix build -v3 -L embedded-dev ct-ng-riscv64-unknown-elf" and my channel is in a directory called "embedded-dev". So the fulll path would be embedded-dev/embedded-dev/build-system/crosstool-ng.scm

4. In build-system/crosstool-ng.scm the beginning is defined as:

(define-module (embedded-dev build-system crosstool-ng)
  #:use-module (guix build-system)
  #:use-module (guix build-system gnu)
  #:export (%crosstool-ng-build-system-modules
            crosstool-ng-build
            crosstool-ng-build-system))

(define %crosstool-ng-build-system-modules
  ;; Build-side modules imported by default.
  `((embedded-dev build crosstool-ng-build-system)
    ,@%gnu-build-system-modules))

(define (default-crosstool-ng )
  "Return the default crosstool-ng package"
  (let ((crosstool-ng (resolve-interface '(embedded-dev packages crosstool-ng))))
    (module-ref crosstool-ng 'crosstool-ng)))


Here I should be exporting the "crosstool-ng-build-system" symbol to be used by a guile script that uses it. The crosstool-ng-build-system-modules should be looking at embedded-dev/build/crosstool-ng-build-system.scm, again taking inspiration from other build system files like the ones associated with ruby. The default-crosstool-ng symbol should be grabbing from the embedded-dev/packages/crosstool-ng.scm file.

5. Later in that file I pass the crosstool-ng-build-system-modules symbol to the crosstool-ng-build function as well as the module located at embedded-dev/build/crosstool-ng-build-system.scm

(define* (crosstool-ng-build name inputs
                             #:key (sample "unknown")
                             (test-target "test")
                             (tests? #t)
                             (phases '%standard-phases)
                             (outputs '("out"))
                             (search-paths '())
                             (system (%current-system))
                             (guile #f)
                             (imported-modules %crosstool-ng-build-system-modules)                              (modules '((embedded-dev build crosstool-ng-build-system)
                                        (guix build utils)))
                             )

6. Then the actual build system symbol that is exported from the top is defined at the bottom of this file:

(define crosstool-ng-build-system
  (build-system
    (name 'crosstool-ng)
    (description "Crosstool-ng build system")
    (lower lower)))

It all seems just as threaded together as the ones in the guix source. I must be missing something small here.

I'm also confused about the "guix build: warning: invalid argument list". It looks like I'm invoking the build command properly.

Is there something else you have to do when setting up a channel to pull in the build and build-system directories? I thought that by adding my channel to the load path with "-L", the elements passed to use-module were essentially directory paths.


That might be what's causing the error:

...
In guix/build-system.scm:
      94:2  3 (make-bag _ _ #:source _ #:inputs _ #:native-inputs _ # …)
In ice-9/boot-9.scm:
   1685:16  2 (raise-exception _ #:continuable? _)
   1685:16  1 (raise-exception _ #:continuable? _)
   1685:16  0 (raise-exception _ #:continuable? _)

ice-9/boot-9.scm:1685:16: In procedure raise-exception:
Throw to key `match-error' with args `("match" "no matching pattern"
#<package crosstool-ng@1.26.0
embedded-dev/embedded-dev/packages/crosstool-ng.scm:26
7fd09cb334d0>)'.
Looking in make-bag (in guix/build-system.scm), the first think it does
it pattern match on the build system expecting a record of the
<build-system> type. Your package doesn't match that pattern, so this
error is raised.
Thanks for pointing this out, I didn't dig in enough.

Carlo

I've attached the version with the changes mentioned.

Thanks,

Jesse

Attachment: embedded-dev.tar.gz
Description: application/gzip


reply via email to

[Prev in Thread] Current Thread [Next in Thread]