Subject: [bug#58100] [PATCH] gnu: cbqn: factor out singeli into derivative package.

From: Liliana Marie Prikler <[email-masked]>
Date: Tue, 27 Sep 2022 09:26:26 +0200

Am Montag, dem 26.09.2022 um 15:12 -0400 schrieb Christopher Rodriguez:
> Persuant to a recent conversation[1] with upstream, I've factored the
> AVX2-dependent builds into their own package (defaulting to a generic
> build
> instead).
> 
> + gnu/packages/bqn.scm: cbqn-singeli
> ~ gnu/packages/bqn.scm: cbqn: changed make flags, inputs, and commit.
This is not how to write a ChangeLog.  See [1] or infer from other
commits.

> ---
>  gnu/packages/bqn.scm | 45 ++++++++++++++++++++++++++++++++++++++----
> --
>  1 file changed, 39 insertions(+), 6 deletions(-)
> 
> diff --git a/gnu/packages/bqn.scm b/gnu/packages/bqn.scm
> index c4e0f39efb..56705beede 100644
> --- a/gnu/packages/bqn.scm
> +++ b/gnu/packages/bqn.scm
> @@ -126,7 +126,7 @@ (define bqn-sources
>  
>  (define cbqn-bootstrap
>    (let* ((revision "1")
> -         (commit "9c1cbdc99863b1da0116df61cd832137b196dc5c"))
> +         (commit "bd823839feaf42af4013e5a245981f58f563e659"))
Why are you changing the bootstrap commit?  This looks suspicious.
>      (package
>        (name "cbqn-bootstrap")
>        (version (git-version "0" "1" commit))
> @@ -138,7 +138,7 @@ (define cbqn-bootstrap
>                  (file-name (git-file-name name version))
>                  (sha256
>                   (base32
> -                 
> "0w38fhwf20drkyijy6nfnhmc5g5gw0zmzgmy1q605x57znlj85a2"))))
> +                 
> "0735mixvpgp2g1jsmbg7aaw35r4xs348y7djkwdvb0193ais6xz2"))))
>        (build-system gnu-build-system)
>        (arguments
>         (list #:tests? #f                         ;skipping tests for
> bootstrap
> @@ -182,12 +182,9 @@ (define-public cbqn
>      (name "cbqn")
>      (outputs '("out" "lib"))
>      (arguments
> -     (list #:make-flags '(list "shared-o3" "o3n-singeli")
> +     (list #:make-flags '(list "shared-o3" "o3")
Okay
>             #:phases #~(modify-phases %standard-phases
>                          (delete 'configure)
> -                        (add-before 'build 'link-singeli
> -                          (lambda* (#:key inputs #:allow-other-keys)
> -                            (symlink #+singeli-sources "Singeli")))
>                          (add-before 'build 'generate-bytecode
>                            (lambda* (#:key inputs #:allow-other-keys)
>                              (system (string-append #+dbqn
> @@ -222,3 +219,39 @@ (define-public cbqn
>                           libffi
>                           clang-toolchain
>                           linux-libre-headers))))
> +(define-public cbqn-singeli
> +  (package
> +    (inherit cbqn)
> +    (name "cbqn-singeli")
> +    (outputs '("out"))
> +    (arguments
> +     (list #:make-flags '(list "singeli=1 f='-mavx2 -mbmi2 -O3' c")
> +           #:phases #~(modify-phases %standard-phases
> +                        (delete 'configure)
> +                        (add-before 'build 'link-singeli
> +                          (lambda* (#:key inputs #:allow-other-keys)
> +                            (symlink #+singeli-sources "Singeli")))
> +                        (add-before 'build 'generate-bytecode
> +                          (lambda* (#:key inputs #:allow-other-keys)
> +                            (system (string-append #+dbqn
> +                                                   "/bin/dbqn
> ./genRuntime "
> +                                                   #+bqn-sources))))
> +                        (replace 'check
> +                          (lambda* (#:key inputs tests? #:allow-
> other-keys)
> +                            (when tests?
> +                              (system (string-append "./BQN -M 1000
> \""
> +                                                     #+bqn-sources
> +                                                    
> "/test/this.bqn\""))
> +                              (map (lambda (x)
> +                                     (system (string-append "./BQN
> ./test/" x
> +                                                           
> ".bqn")))
> +                                   '("cmp" "equal" "copy"
> "random")))))
> +                        (replace 'install
> +                          (lambda* (#:key outputs #:allow-other-
> keys)
> +                            (let* ((bin (string-append (assoc-ref
> outputs
> +                                                                 
> "out")
> +                                                       "/bin")))
> +                              (mkdir-p bin)
> +                              (copy-recursively "BQN"
> +                                                (string-append bin
> "/bqn"))))))))))
> +
Instead of providing a singeli variant, would just tuning the package
suffice?  If not, I think we should try to properly unbundle singeli
(as in build an actual singeli package) before adding another package
variant.  Then, you could use existing patterns to decide whether to
use singeli by making it an input or not.

Cheers

[1] https://www.gnu.org/prep/standards/html_node/Change-Logs.html