[PATCH 2/2] gnu: Add hare.

DoneSubmitted by Antero Mejr.
Details
6 participants
  • Antero Mejr
  • Liliana Marie Prikler
  • Liliana Marie Prikler
  • Maxime Devos
  • Tobias Geerinckx-Rice
  • (
Owner
unassigned
Severity
normal
Merged with
Blocked by
A
A
Antero Mejr wrote on 24 May 03:21 +0200
(address . guix-patches@gnu.org)(name . Antero Mejr)(address . antero@mailbox.org)
20220524012155.48729-2-antero@mailbox.org
* gnu/packages/hare.scm (hare): New variable.
---
Guix style was indenting badly when applied to the hare package, putting the
text far past 80 characters. Corrected it by hand.

gnu/packages/hare.scm | 136 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 136 insertions(+)
create mode 100644 gnu/packages/hare.scm

Toggle diff (144 lines)
diff --git a/gnu/packages/hare.scm b/gnu/packages/hare.scm
new file mode 100644
index 0000000000..5936056fda
--- /dev/null
+++ b/gnu/packages/hare.scm
@@ -0,0 +1,136 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2022 Antero Mejr <antero@mailbox.org>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages hare)
+  #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix build-system gnu)
+  #:use-module (guix download)
+  #:use-module (guix gexp)
+  #:use-module (guix git-download)
+  #:use-module (guix packages)
+  #:use-module (guix utils)
+  #:use-module (gnu packages base)
+  #:use-module (gnu packages c)
+  #:use-module (gnu packages man)
+  #:use-module (gnu platform))
+
+(define-public harec
+  (let ((commit "43b34048dd83bde5d4d2a7d93d37a593a9c12fda") (revision "0"))
+    (package
+      (name "harec")
+      (version (git-version "0.0" revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://git.sr.ht/~sircmpwn/harec")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "0502xw96za7bvnqvh6jhfjwrw4ddqwppr4ihcn9f5jvjpgw95284"))))
+      (native-inputs (list qbe))
+      (build-system gnu-build-system)
+      (arguments
+       `(#:tests? #f ;no test suite
+         #:make-flags
+         (list (string-append "CC="
+                              ,(cc-for-target))
+               (string-append "DESTDIR="
+                              (assoc-ref %outputs "out")) "PREFIX=")
+         #:phases
+         (modify-phases %standard-phases
+           (replace 'configure
+             (lambda* (#:key configure-flags #:allow-other-keys)
+               (setenv "QBE"
+                       (string-append (assoc-ref %build-inputs "qbe")
+                                      "/bin/qbe"))
+               ;; configure rejects unrecognized options
+               (apply invoke "./configure" configure-flags))))))
+      (home-page "https://harelang.org")
+      (synopsis "Hare bootstrap compiler")
+      (description "Hare compiler written in C11 for POSIX-compatible
+systems.")
+      (license license:gpl3+))))
+
+(define-public hare
+  (let ((commit "5af4fbd5f2f552da47af0f8f765050e49b0ae73f") (revision "0"))
+    (package
+      (name "hare")
+      (version (git-version "0.0" revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://git.sr.ht/~sircmpwn/hare")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "1gj2v5p73f8y5gpglm6mmfdadc6ih2bnd80nyax1xipsfy0f82di"))))
+      (build-system gnu-build-system)
+      (arguments
+       `(#:make-flags
+         (list (string-append "DESTDIR=" (assoc-ref %outputs "out"))
+               "BINDIR=/bin"
+               "MANDIR=/share/man"
+               "SRCDIR=/src"
+               "LOCALSRCDIR=/src/hare"
+               (string-append "HAREPATH="
+                              (assoc-ref %outputs "out")
+                              "/src/hare/stdlib:"
+                              (assoc-ref %outputs "out")
+                              "/src/hare/third-party")
+               (string-append "PLATFORM=" "linux")
+               (string-append "ARCH="
+                              ,(platform-linux-architecture
+                                (lookup-platform-by-target-or-system
+                                 (or (%current-target-system)
+                                     (%current-system)))))
+               (string-append "HAREC="
+                              (string-append (assoc-ref %build-inputs "harec")
+                                             "/bin/harec"))
+               "HAREFLAGS="
+               (string-append "QBE="
+                              (string-append (assoc-ref %build-inputs "qbe")
+                                             "/bin/qbe"))
+               (string-append "AS="
+                              (string-append (assoc-ref %build-inputs "binutils")
+                                             "/bin/as"))
+               (string-append "LD="
+                              (string-append (assoc-ref %build-inputs "binutils")
+                                             "/bin/ld"))
+               (string-append "AR="
+                              (string-append (assoc-ref %build-inputs "binutils")
+                                             "/bin/ar"))
+               (string-append "SCDOC="
+                              (string-append (assoc-ref %build-inputs "scdoc")
+                                             "/bin/scdoc"))
+               "HARECACHE=.cache")
+         #:phases
+         (modify-phases %standard-phases
+                        (delete 'configure) ;No configuration script.
+           ;; Use own make-flags instead of `config.mk`.
+           (add-before 'build 'dont-include-config-mk
+             (lambda _
+               (substitute* "Makefile"
+                 (("include config.mk") "")) #t)))))
+      (native-inputs (list scdoc))
+      (propagated-inputs (list harec qbe binutils))
+      (home-page "https://harelang.org")
+      (synopsis "Compiler for the Hare programming language")
+      (description "Hare is a systems programming language.")
+      (license (list license:gpl3+ license:mpl2.0)))))
-- 
2.36.1
L
L
Liliana Marie Prikler wrote on 24 May 08:43 +0200
(address . control@debbugs.gnu.org)
8fdea3aaa79939d25f1fbe1a7b92b7f73ae20cc1.camel@ist.tugraz.at
merge 53833 55151 55605
merge 55187 55606
block 55187 by 53833
block 53834 by 53833
thanks
M
M
Maxime Devos wrote on 24 May 19:01 +0200
af752a70d2f5e8441665bd6e5cde73741e2341bd.camel@telenet.be
Antero Mejr via Guix-patches via schreef op ma 23-05-2022 om 21:21 [-
0400]:
Toggle quote (17 lines)
> +      (arguments
> +       `(#:tests? #f ;no test suite
> +         #:make-flags
> +         (list (string-append "CC="
> +                              ,(cc-for-target))
> +               (string-append "DESTDIR="
> +                              (assoc-ref %outputs "out")) "PREFIX=")
> +         #:phases
> +         (modify-phases %standard-phases
> +           (replace 'configure
> +             (lambda* (#:key configure-flags #:allow-other-keys)
> +               (setenv "QBE"
> +                       (string-append (assoc-ref %build-inputs "qbe")
> +                                      "/bin/qbe"))
> +               ;; configure rejects unrecognized options
> +               (apply invoke "./configure" configure-flags))))))

input labels can be eliminated (see

(arguments
(list ...
#:phases
#~(modify-phases ...
(setenv "QBE" (which "qbe"))
(apply invoke ...))))

Also, 'qbe' looks like a non-native input input, IIUC that 'harec'
invokes 'qbe' under the hood. (in that case, use (search-input-file
inputs "/bin/qbe") instead). As a test, you can do "guix build harec"
and "guix gc --refences /gnu/store/HAS-harec-VERSION" to see if it ends
up in the references.

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYo0PcxccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7kQdAP9JmAdzbWViKpAuvLeYSzUi53CB
Vhi7R/rYJPuwWzyo2gEAjUzyrtV+EX/3Q82PUBTo1pDuSi55qplAFbEf7Wcuvws=
=H7kk
-----END PGP SIGNATURE-----


M
M
Maxime Devos wrote on 24 May 19:07 +0200
6fb4da7ebb8e56fd2e107e37293f3d76002d557d.camel@telenet.be
Antero Mejr via Guix-patches via schreef op ma 23-05-2022 om 21:21 [-
0400]:
Toggle quote (7 lines)
> +       `(#:make-flags
> +         (list (string-append "DESTDIR=" (assoc-ref %outputs "out"))
> +               "BINDIR=/bin"
> +               "MANDIR=/share/man"
> +               "SRCDIR=/src"
> +               "LOCALSRCDIR=/src/hare"

See previous message about G-exp and DESTDIR.

+ (string-append "HAREPATH="
+ (assoc-ref %outputs "out")
+ "/src/hare/stdlib:"
+ (assoc-ref %outputs "out")

Likewise, (assoc-ref ... "out") -> #$output


+ (string-append "HAREC="
+ (string-append (assoc-ref %build-inputs
"harec")
+ "/bin/harec"))

Likewise about input labels, though in this case search-input-file.
Or (file-append #$(this-package-input "harec") "/bin/harec").

+ (string-append "AS="
+ (string-append (assoc-ref %build-inputs
"binutils")

IIRC %build-inputs does not exist when cross-compiling, try "guix build
--target=aarch64-linux-gnu hare". Also, it is ambigious if you meant
inputs or native-inptus here. You might need %build-target-input or
one of those instead. They are undocumented though, so maybe better
use this-package-{native,}-input. Those don't support implicit inputs
though, so you may need to add the gcc manually (maybe look at (guix
build-system gnu) for how).

Toggle quote (2 lines)
> + "HARECACHE=.cache")

Is this used for building the hare compiler itself or for building hare
libraries and applications?

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYo0QyRccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7rckAQDd9wpIgNEu4pqcaDLLfItcfAZE
GZvkwpHDcRGXa9BnvgEAi38kJIo3fZfnhvqkSO+1QRGBrfGpjgIobngwILkTGgo=
=CU+j
-----END PGP SIGNATURE-----


M
M
Maxime Devos wrote on 24 May 19:09 +0200
957c71af73953ce8dcd1553c9b4141502eaaa45b.camel@telenet.be
Antero Mejr via Guix-patches via schreef op ma 23-05-2022 om 21:21 [-
0400]:
Toggle quote (3 lines)
> +               (string-append "LD="
> +                              (string-append (assoc-ref %build-inputs "binutils")

Looking at the makefile, I think all you need is "LD=ld". Or maybe
"LD=TARGET-ld".
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYo0RTRccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7oLjAQDECMgGD5AnxsI0KfQEixwsnd2u
Q2cYgfBMiDyCy+mwNQD+JTqagzRUtPnYQnMsNkRNZ65qkogH/WgLkanmfMx3DgA=
=I9Pc
-----END PGP SIGNATURE-----


T
T
Tobias Geerinckx-Rice wrote on 24 May 19:10 +0200
(name . Antero Mejr)(address . antero@mailbox.org)
87leuqaloi@nckx
Antero Mejr via Guix-patches via 写道:
Toggle quote (4 lines)
> Guix style was indenting badly when applied to the hare package,
> putting the
> text far past 80 characters. Corrected it by hand.

This caught my attention; I didn't review anything.

Guix style just follows the same rules we should follow. Don't
‘fix’ the result unless there's a real bug in ‘guix style’.

Instead, work with it, in this case by adding newlines. This:

(proc "foo"
"bar")

reads *wrong* to humans.

Worse, it's forever a pain to maintain, because nobody can ever
auto-indent any changes they make to your hand-tweaked code. They
have to work around it.

Instead, when necessary, write:

(proc
"foo"
"bar")

Toggle quote (3 lines)
> + (list (string-append "DESTDIR=" (assoc-ref %outputs
> "out"))

In this case you'd a newline after the above ‘string-append’.

Toggle quote (5 lines)
> + (string-append "HAREC="
> + (string-append (assoc-ref
> %build-inputs "harec")
> + "/bin/harec"))

This is easy to fix: theres no need for the inner string-appends
in this section.

(string-append "HAREC="
(assoc-ref %build-inputs "harec")
"/bin/harec")

is 100% equivalent. If the line is still too long, add newlines
where it keeps the code the clearest.

With such changes, you can run ‘guix style’ (or let your editor
indent the code) without worries or manual fix-ups.

Kind regards,

T G-R
-----BEGIN PGP SIGNATURE-----

iIMEARYKACsWIQT12iAyS4c9C3o4dnINsP+IT1VteQUCYo0UvQ0cbWVAdG9iaWFz
LmdyAAoJEA2w/4hPVW15gWcBAO0d9f1GuB1lvmoiFVLoEH9Oe5c1G3ttKJjQtZLn
mWeOAQCKHNkcYAwPV5FqDd5lkQpWZjy3JC3400tTyc5Dc/NeBg==
=6ISR
-----END PGP SIGNATURE-----

A
A
Antero Mejr wrote on 29 May 02:54 +0200
[PATCH] gnu: Add hare.
(address . 55606@debbugs.gnu.org)(name . Antero Mejr)(address . antero@mailbox.org)
20220529005455.331312-1-antero@mailbox.org
* gnu/packages/hare.scm (hare): New variable.
---
gnu/packages/hare.scm | 145 ++++++++++++++++++++++++++++++++++++++++++
guix/utils.scm | 6 ++
2 files changed, 151 insertions(+)
create mode 100644 gnu/packages/hare.scm

Toggle diff (177 lines)
diff --git a/gnu/packages/hare.scm b/gnu/packages/hare.scm
new file mode 100644
index 0000000000..b36bb3d475
--- /dev/null
+++ b/gnu/packages/hare.scm
@@ -0,0 +1,145 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2022 Antero Mejr <antero@mailbox.org>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages hare)
+  #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix build-system gnu)
+  #:use-module (guix download)
+  #:use-module (guix gexp)
+  #:use-module (guix git-download)
+  #:use-module (guix packages)
+  #:use-module (guix utils)
+  #:use-module (gnu packages base)
+  #:use-module (gnu packages c)
+  #:use-module (gnu packages man)
+  #:use-module (gnu platform))
+
+(define-public harec
+  (let ((commit "78989a15dfcc301ac2eca07afb1f906e172bd48b") (revision "0"))
+    (package
+      (name "harec")
+      (version (git-version "0.0.0" revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://git.sr.ht/~sircmpwn/harec")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "1cv71vmrcf31rk7cjrmhb6ivwdfwzick7fyiglwh4ky6bf0r6cgx"))))
+      (build-system gnu-build-system)
+      (arguments
+       (list #:configure-flags
+             #~(list (string-append "--prefix="
+                                    #$output))
+             #:phases
+             #~(modify-phases %standard-phases
+                 (add-before 'configure 'setenv
+                   (lambda _
+                     (setenv "QBE"
+                             (string-append #$qbe "/bin/qbe"))
+                     (setenv "CC"
+                             #$(cc-for-target))))
+                 (replace 'configure
+                   (lambda* (#:key outputs
+                             (configure-flags '()) #:allow-other-keys)
+                     (apply invoke "./configure" configure-flags))))))
+      (inputs (list qbe))
+      (home-page "https://harelang.org")
+      (synopsis "Hare bootstrap compiler")
+      (description "Hare compiler written in C11 for POSIX-compatible
+systems.")
+      (license license:gpl3+))))
+
+(define-public hare
+  (let ((commit "19e380ccb7dfe2bcab5f94e6bd03004e3e2c6005") (revision "0"))
+    (package
+      (name "hare")
+      (version (git-version "0.0.0" revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://git.sr.ht/~sircmpwn/hare")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "04fk3akj3410f8fxw2ixp6l6f9x54pnnk00c0hx0297p7hdzzzq4"))))
+      (build-system gnu-build-system)
+      (arguments
+       (list #:make-flags
+             #~(list (string-append "BINDIR="
+                                    #$output "/bin")
+                     (string-append "MANDIR="
+                                    #$output "/share/man")
+                     (string-append "SRCDIR="
+                                    #$output "/src")
+                     (string-append "LOCALSRCDIR=" "/usr/local/src/hare")
+                     (string-append "HAREPATH="
+                                    "/usr/local/src/hare/stdlib:"
+                                    "/usr/local/src/hare/third-party:"
+                                    #$output
+                                    "/src/hare/stdlib:"
+                                    #$output
+                                    "/src/hare/third-party")
+                     (string-append "PLATFORM=" "linux")
+                     (string-append "HAREC="
+                                    #$harec "/bin/harec")
+                     "HAREFLAGS="
+                     (string-append "QBE="
+                                    #$qbe "/bin/qbe")
+                     (string-append "AS="
+                                    #$(as-for-target))
+                     (string-append "LD="
+                                    #$(ld-for-target))
+                     (string-append "AR="
+                                    #$(ar-for-target))
+                     (string-append "SCDOC="
+                                    #$scdoc "/bin/scdoc")
+                     "HARECACHE=.cache")
+             #:phases
+             #~(modify-phases %standard-phases
+                 (delete 'configure)
+                 (add-before 'build 'set-arch-env
+                   (lambda _
+                     (let ((arch #$(platform-linux-architecture
+                                    (lookup-platform-by-target-or-system
+                                     (or (%current-target-system)
+                                         (%current-system))))))
+                       (setenv "ARCH" arch)) #t))
+                 (add-before 'build 'edit-files
+                   (lambda _
+                     (substitute* "Makefile"
+                       (("include config.mk") "")
+                       (("\\$\\(LOCALSRCDIR\\)") ""))
+                     (substitute* "math/complex/+test.ha"
+                       (("return realalike && imagalike;")
+                        "return true;")) #t)))))
+      (native-inputs (list scdoc))
+      (inputs (list tzdata))
+      (propagated-inputs (list harec qbe))
+      (native-search-paths
+       (list (search-path-specification
+              (variable "HAREPATH")
+              (files '("src/hare/stdlib"
+                       "src/hare/third-party")))))
+      (home-page "https://harelang.org")
+      (synopsis "Compiler for the Hare programming language")
+      (description "Hare is a systems programming language.")
+      (license (list license:gpl3+ license:mpl2.0)))))
diff --git a/guix/utils.scm b/guix/utils.scm
index 44c46cb4a9..2cf5fb1db7 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -100,6 +100,7 @@ (define-module (guix utils)
             target-riscv64?
             target-64bit?
             ar-for-target
+            as-for-target
             cc-for-target
             cxx-for-target
             ld-for-target
@@ -722,6 +723,11 @@ (define* (ar-for-target #:optional (target (%current-target-system)))
       (string-append target "-ar")
       "ar"))
 
+(define* (as-for-target #:optional (target (%current-target-system)))
+  (if target
+      (string-append target "-as")
+      "as"))
+
 (define* (cc-for-target #:optional (target (%current-target-system)))
   (if target
       (string-append target "-gcc")
-- 
2.36.1
A
A
Antero Mejr wrote on 3 Jun 19:54 +0200
(name . 55606@debbugs.gnu.org)(address . 55606@debbugs.gnu.org)
1494793954.947626.1654278890520@office.mailbox.org
Thanks for the suggestions Maxime and Tobias, the patch above uses the new gexps and has better styling. The new patch was tested by building the hare programs 'hautils', which compiled and ran successfully.

Maxime, the HARECACHE directory is a temporary build directory for the compiler itself, yes.

Please let me know if there are any futher issues.
L
L
Liliana Marie Prikler wrote on 25 Jun 18:54 +0200
0f62a23e7014fa02404683d144bbeffa52732ebc.camel@gmail.com
Am Freitag, dem 03.06.2022 um 13:54 -0400 schrieb Antero Mejr:
Toggle quote (1 lines)
> Please let me know if there are any futher issues.
For what it's worth, the patch should probably be split in three (one
for as-for-target, one for harec, one for hare).

Maxime, Tobias, what else is missing?
(
Re: [bug#55606] [PATCH 2/2] gnu: Add hare.
CKZENZNME1O0.U98IWRHP1BRD@guix-aspire
(
CKZESLZJRMLX.MJV2YNDL09F9@guix-aspire
Some notes:

+ `hare` is not a compiler for Hare, it's a build tool. (It's going to
include a self-hosted compiler eventually though :))
+ I think the way this patch handles config.mk from `hare` is better.
+ The Guix 'R Us version works with cross-compilation; I don't think this
one does?
+ harec and qbe probably shouldn't be propagated; their paths should be
patched into the source code.

-- (
A
A
Antero Mejr wrote on 25 Jun 23:32 +0200
Re: [PATCH 2/2] gnu: Add hare.
(name . Liliana Marie Prikler)(address . liliana.prikler@gmail.com)
8735fss8kl.fsf@mailbox.org
Liliana Marie Prikler <liliana.prikler@gmail.com> writes:

Toggle quote (3 lines)
> For what it's worth, the patch should probably be split in three (one
> for as-for-target, one for harec, one for hare).

I split out as-for-target into a new patch/issue #56224, since it does
not directly involve hare:
A
A
Antero Mejr wrote on 26 Jun 06:39 +0200
[PATCH 1/2] gnu: Add harec.
(address . 55606@debbugs.gnu.org)
20220626043902.3076-1-antero@mailbox.org
* gnu/packages/hare.scm (harec): New variable.
---
gnu/packages/hare.scm | 66 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 66 insertions(+)
create mode 100644 gnu/packages/hare.scm

Toggle diff (74 lines)
diff --git a/gnu/packages/hare.scm b/gnu/packages/hare.scm
new file mode 100644
index 0000000000..a1149499d5
--- /dev/null
+++ b/gnu/packages/hare.scm
@@ -0,0 +1,66 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2022 (unmatched parenthesis <paren@disroot.org>
+;;; Copyright © 2022 Antero Mejr <antero@mailbox.org>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages hare)
+  #:use-module (gnu packages base)
+  #:use-module (gnu packages c)
+  #:use-module (gnu packages man)
+  #:use-module (guix build-system gnu)
+  #:use-module (guix download)
+  #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix gexp)
+  #:use-module (guix git-download)
+  #:use-module (guix packages)
+  #:use-module (guix platform)
+  #:use-module (guix utils))
+
+(define-public harec
+  (let ((commit "bbabe09bddf74bd699f8ad2224fdd6e2eefbd35e") (revision "0"))
+    (package
+      (name "harec")
+      (version (git-version "0.0.0" revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://git.sr.ht/~sircmpwn/harec")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "0sa8rjj5w01n55svql8drv761ks6i1bl9q4gj1yzr31dixaf6xvr"))))
+      (build-system gnu-build-system)
+      (arguments
+       (list #:configure-flags #~(list (string-append "--prefix=" #$output))
+             #:phases #~(modify-phases %standard-phases
+                          (replace 'configure
+                            (lambda* (#:key outputs
+                                      (configure-flags '()) #:allow-other-keys)
+                              (setenv "AR" #$(ar-for-target))
+                              (setenv "AS" #$(as-for-target))
+                              (setenv "CC" #$(cc-for-target))
+                              (setenv "LD" #$(ld-for-target))
+                              (setenv "QBE" (string-append #$qbe "/bin/qbe"))
+                              (apply invoke "./configure" configure-flags))))))
+      (inputs (list qbe))
+      (home-page "https://harelang.org")
+      (synopsis "Hare bootstrap compiler in C")
+      (description "This package provides @code{harec}, the Hare language's
+bootstrap written in C.  Currently, the self-hosting @code{harec} rewrite is
+incomplete, so this is used as the default compiler in the build driver.")
+      (license license:gpl3))))
-- 
2.36.1
A
A
Antero Mejr wrote on 26 Jun 06:39 +0200
[PATCH 2/2] gnu: Add hare.
(address . 55606@debbugs.gnu.org)
20220626043902.3076-2-antero@mailbox.org
* gnu/packages/hare.scm (hare): New variable.
---
gnu/packages/hare.scm | 73 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 73 insertions(+)

Toggle diff (83 lines)
diff --git a/gnu/packages/hare.scm b/gnu/packages/hare.scm
index a1149499d5..16c7d8e2dd 100644
--- a/gnu/packages/hare.scm
+++ b/gnu/packages/hare.scm
@@ -64,3 +64,76 @@ (define-public harec
 bootstrap written in C.  Currently, the self-hosting @code{harec} rewrite is
 incomplete, so this is used as the default compiler in the build driver.")
       (license license:gpl3))))
+
+(define-public hare
+  (let ((commit "19e380ccb7dfe2bcab5f94e6bd03004e3e2c6005") (revision "0"))
+    (package
+      (name "hare")
+      (version (git-version "0.0.0" revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://git.sr.ht/~sircmpwn/hare")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "04fk3akj3410f8fxw2ixp6l6f9x54pnnk00c0hx0297p7hdzzzq4"))))
+      (build-system gnu-build-system)
+      (arguments
+       (list #:make-flags
+             #~(list (string-append "BINDIR=" #$output "/bin")
+                     (string-append "MANDIR=" #$output "/share/man")
+                     (string-append "SRCDIR=" #$output "/src")
+                     (string-append "LOCALSRCDIR=" #$output "/src/hare")
+                     (string-append "HAREC=" #$harec "/bin/harec")
+                     (string-append "PLATFORM=" "linux")
+                     (string-append "HAREPATH="
+                                    #$output "/src/hare/stdlib:"
+                                    #$output "/src/hare/third-party")
+                     (string-append "ARCH="
+                                    #$(platform-linux-architecture
+                                       (lookup-platform-by-target-or-system
+                                        (or (%current-target-system)
+                                            (%current-system)))))
+                     (string-append "AR=" #$(ar-for-target))
+                     (string-append "AS=" #$(as-for-target))
+                     (string-append "LD=" #$(ld-for-target))
+                     (string-append "QBE=" #$qbe "/bin/qbe")
+                     (string-append "SCDOC=" #$scdoc "/bin/scdoc")
+                     "HARECACHE=.cache"
+                     "BINOUT=.bin")
+             #:phases
+             #~(modify-phases %standard-phases
+                 (add-after 'unpack 'patch-failing-tests
+                   (lambda _
+                     ;; These tests fail due to a NaN-related bug in QBE when
+                     ;; used on glibc.
+                     (substitute* "math/complex/+test.ha"
+                       (("@test (fn (cos|cosh|exp)\\(\\) void =)" _ func)
+                        func))))
+                 (add-after 'unpack 'patch-makefile
+                   (lambda _
+                     (substitute* "Makefile"
+                       (("include config.mk") ""))))
+                 (delete 'configure))))
+      (native-inputs (list scdoc))
+      (inputs (list tzdata))
+      (propagated-inputs (list binutils harec qbe))
+      (supported-systems (list "x86_64-linux" "aarch64-linux" "riscv64-linux"))
+      (native-search-paths
+       (list (search-path-specification
+              (variable "HAREPATH")
+              (files '("src/hare/stdlib" "src/hare/third-party")))))
+      (home-page "https://harelang.org")
+      (synopsis "Systems programming language")
+      (description "Hare is a systems programming language that aims to improve
+on C while retaining its core philosophy. Its principles are:
+@itemize
+@item Trust the programmer.
+@item Provide tools the programmer may use when they don't trust themselves.
+@item Prefer explicit behavior over implicit behavior.
+@item A good program must be both correct and simple.
+@end itemize")
+      (license (list license:gpl3 ;compiler and build driver
+                     license:mpl2.0))))) ;standard library
-- 
2.36.1
A
A
Antero Mejr wrote on 26 Jun 06:40 +0200
(name . ()(address . paren@disroot.org)
87v8so81lg.fsf@mailbox.org
Hi (,

"(" <paren@disroot.org> writes:
Toggle quote (5 lines)
> Some notes:
>
> + `hare` is not a compiler for Hare, it's a build tool. (It's going to
> include a self-hosted compiler eventually though :))

The above 2 patches are a combination of your guixrus patches and mine.
The descriptions are replaced with your better ones, and you are
credited at the top.

Toggle quote (2 lines)
> + I think the way this patch handles config.mk from `hare` is better.

I kept that part in the new patches.

Toggle quote (2 lines)
> + The Guix 'R Us version works with cross-compilation; I don't think this
> one does?
You mean cross-compilation of hare code? When I try to use hare build -t
(the target flag) it gives me a not implemented error, so I don't think
hare cross-compilation is possible right now.

As for cross-compilation of the guix hare build, I think the
platform-linux-architecture bit should take care of it, right?

Toggle quote (5 lines)
> + harec and qbe probably shouldn't be propagated; their paths should be
> patched into the source code.
>
> -- (

I'm unsure about this one - maybe the user would want to use harec or
qbe by themselves to debug a build step?
I wanted to give the user a full hare build environment when
they run `guix install hare`, but I understand your logic for wanting to
patch the paths in.

Thanks,
Antero
A
A
Antero Mejr wrote on 26 Jun 06:56 +0200
(name . ()(address . paren@disroot.org)
87r13c81ek.fsf@mailbox.org
"(" <paren@disroot.org> writes:

Toggle quote (4 lines)
> FYI, I added Hare packages and libraries to Guix 'R Us a while ago, but
> was waiting for 1.0 to send it here:
>

Hare is already in Nixpkgs and AUR, so I think it would be good to make
the language available in Guix. I haven't seen a release plan, so
1.0.0 could still be far off.
L
L
Liliana Marie Prikler wrote on 26 Jun 08:50 +0200
Re: [PATCH 1/2] gnu: Add harec.
83e1d5b4523b9ecb6ca2540fe3fa7866425118ff.camel@gmail.com
Hi,

added the others back to CC; don't forget to set those when using guix
send-email.

Am Sonntag, dem 26.06.2022 um 00:39 -0400 schrieb Antero Mejr:
Toggle quote (53 lines)
> * gnu/packages/hare.scm (harec): New variable.
> ---
>  gnu/packages/hare.scm | 66
> +++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 66 insertions(+)
>  create mode 100644 gnu/packages/hare.scm
>
> diff --git a/gnu/packages/hare.scm b/gnu/packages/hare.scm
> new file mode 100644
> index 0000000000..a1149499d5
> --- /dev/null
> +++ b/gnu/packages/hare.scm
> @@ -0,0 +1,66 @@
> +;;; GNU Guix --- Functional package management for GNU
> +;;; Copyright © 2022 (unmatched parenthesis <paren@disroot.org>
> +;;; Copyright © 2022 Antero Mejr <antero@mailbox.org>
> +;;;
> +;;; This file is part of GNU Guix.
> +;;;
> +;;; GNU Guix is free software; you can redistribute it and/or modify
> it
> +;;; under the terms of the GNU General Public License as published
> by
> +;;; the Free Software Foundation; either version 3 of the License,
> or (at
> +;;; your option) any later version.
> +;;;
> +;;; GNU Guix is distributed in the hope that it will be useful, but
> +;;; WITHOUT ANY WARRANTY; without even the implied warranty of
> +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +;;; GNU General Public License for more details.
> +;;;
> +;;; You should have received a copy of the GNU General Public
> License
> +;;; along with GNU Guix.  If not, see
> <http://www.gnu.org/licenses/>.
> +
> +(define-module (gnu packages hare)
> +  #:use-module (gnu packages base)
> +  #:use-module (gnu packages c)
> +  #:use-module (gnu packages man)
> +  #:use-module (guix build-system gnu)
> +  #:use-module (guix download)
> +  #:use-module ((guix licenses) #:prefix license:)
> +  #:use-module (guix gexp)
> +  #:use-module (guix git-download)
> +  #:use-module (guix packages)
> +  #:use-module (guix platform)
> +  #:use-module (guix utils))
> +
> +(define-public harec
> +  (let ((commit "bbabe09bddf74bd699f8ad2224fdd6e2eefbd35e")
> (revision "0"))
Despite what (guix style) may tell you, revision goes to an extra line.
Toggle quote (28 lines)
> +    (package
> +      (name "harec")
> +      (version (git-version "0.0.0" revision commit))
> +      (source (origin
> +                (method git-fetch)
> +                (uri (git-reference
> +                      (url "https://git.sr.ht/~sircmpwn/harec")
> +                      (commit commit)))
> +                (file-name (git-file-name name version))
> +                (sha256
> +                 (base32
> +                 
> "0sa8rjj5w01n55svql8drv761ks6i1bl9q4gj1yzr31dixaf6xvr"))))
> +      (build-system gnu-build-system)
> +      (arguments
> +       (list #:configure-flags #~(list (string-append "--prefix="
> #$output))
> +             #:phases #~(modify-phases %standard-phases
> +                          (replace 'configure
> +                            (lambda* (#:key outputs
> +                                      (configure-flags '()) #:allow-
> other-keys)
> +                              (setenv "AR" #$(ar-for-target))
> +                              (setenv "AS" #$(as-for-target))
> +                              (setenv "CC" #$(cc-for-target))
> +                              (setenv "LD" #$(ld-for-target))
> +                              (setenv "QBE" (string-append #$qbe
> "/bin/qbe"))
Should be (which "qbe"), or some elaborate search-input-file. Also qbe
should be a native input.

I do wonder if some of those get embedded into the compiler or how
they're supposed to be used (outside of build time); if you find a
place where harec invokes qbe, you'd need to patch that in the source.
Toggle quote (11 lines)
> +                              (apply invoke "./configure" configure-
> flags))))))
> +      (inputs (list qbe))
> +      (home-page "https://harelang.org")
> +      (synopsis "Hare bootstrap compiler in C")
> +      (description "This package provides @code{harec}, the Hare
> language's
> +bootstrap written in C.  Currently, the self-hosting @code{harec}
> rewrite is
> +incomplete, so this is used as the default compiler in the build
> driver.")
I don't see why it's necessary to state that harec can't self-host yet.
We would need to bootstrap it from C anyways, so having this
architecture in place actually makes things simpler.
Toggle quote (2 lines)
> +      (license license:gpl3))))

Cheers
L
L
Liliana Marie Prikler wrote on 26 Jun 09:18 +0200
Re: [PATCH 2/2] gnu: Add hare.
415a5fd68a5540c6ba45bdd69edbbf8fb39335d9.camel@gmail.com
Hi,

Am Sonntag, dem 26.06.2022 um 00:39 -0400 schrieb Antero Mejr:
Toggle quote (20 lines)
> * gnu/packages/hare.scm (hare): New variable.
> ---
>  gnu/packages/hare.scm | 73
> +++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 73 insertions(+)
>
> diff --git a/gnu/packages/hare.scm b/gnu/packages/hare.scm
> index a1149499d5..16c7d8e2dd 100644
> --- a/gnu/packages/hare.scm
> +++ b/gnu/packages/hare.scm
> @@ -64,3 +64,76 @@ (define-public harec
>  bootstrap written in C.  Currently, the self-hosting @code{harec}
> rewrite is
>  incomplete, so this is used as the default compiler in the build
> driver.")
>        (license license:gpl3))))
> +
> +(define-public hare
> +  (let ((commit "19e380ccb7dfe2bcab5f94e6bd03004e3e2c6005")
> (revision "0"))
As with harec.
Toggle quote (22 lines)
> +    (package
> +      (name "hare")
> +      (version (git-version "0.0.0" revision commit))
> +      (source (origin
> +                (method git-fetch)
> +                (uri (git-reference
> +                      (url "https://git.sr.ht/~sircmpwn/hare")
> +                      (commit commit)))
> +                (file-name (git-file-name name version))
> +                (sha256
> +                 (base32
> +                 
> "04fk3akj3410f8fxw2ixp6l6f9x54pnnk00c0hx0297p7hdzzzq4"))))
> +      (build-system gnu-build-system)
> +      (arguments
> +       (list #:make-flags
> +             #~(list (string-append "BINDIR=" #$output "/bin")
> +                     (string-append "MANDIR=" #$output "/share/man")
> +                     (string-append "SRCDIR=" #$output "/src")
> +                     (string-append "LOCALSRCDIR=" #$output
> "/src/hare")
> +                     (string-append "HAREC=" #$harec "/bin/harec")
Should have a (this-package-input) or (this-package-native-input) for
harec. If it's the latter, (which "harec") might also be acceptable.
Toggle quote (15 lines)
> +                     (string-append "PLATFORM=" "linux")
> +                     (string-append "HAREPATH="
> +                                    #$output "/src/hare/stdlib:"
> +                                    #$output "/src/hare/third-
> party")
> +                     (string-append "ARCH="
> +                                    #$(platform-linux-architecture
> +                                       (lookup-platform-by-target-
> or-system
> +                                        (or (%current-target-system)
> +                                            (%current-system)))))
> +                     (string-append "AR=" #$(ar-for-target))
> +                     (string-append "AS=" #$(as-for-target))
> +                     (string-append "LD=" #$(ld-for-target))
> +                     (string-append "QBE=" #$qbe "/bin/qbe")
As with harec.
Toggle quote (1 lines)
> +                     (string-append "SCDOC=" #$scdoc "/bin/scdoc")
As with harec.
Toggle quote (2 lines)
> +                     "HARECACHE=.cache"
> +                     "BINOUT=.bin")
I suppose neither of those ought to be installed?
Toggle quote (16 lines)
> +             #:phases
> +             #~(modify-phases %standard-phases
> +                 (add-after 'unpack 'patch-failing-tests
> +                   (lambda _
> +                     ;; These tests fail due to a NaN-related bug in
> QBE when
> +                     ;; used on glibc.
> +                     (substitute* "math/complex/+test.ha"
> +                       (("@test (fn (cos|cosh|exp)\\(\\) void =)" _
> func)
> +                        func))))
> +                 (add-after 'unpack 'patch-makefile
> +                   (lambda _
> +                     (substitute* "Makefile"
> +                       (("include config.mk") ""))))
> +                 (delete 'configure))))
Why delete configure here, but not in harec? I'm pretty sure we can
use the same hack for both packages.

Toggle quote (9 lines)
> +      (native-inputs (list scdoc))
> +      (inputs (list tzdata))
> +      (propagated-inputs (list binutils harec qbe))
> +      (supported-systems (list "x86_64-linux" "aarch64-linux"
> "riscv64-linux"))
> +      (native-search-paths
> +       (list (search-path-specification
> +              (variable "HAREPATH")
> +              (files '("src/hare/stdlib" "src/hare/third-party")))))
Is there a need to split HAREPATH like that? From a functionality
perspective, a singular "include/hare" or similar ought to be enough.
I'd specifically avoid "src" since it exists "only for reference
purposes" in the FHS. Other distros mandate that the linux kernel
source code be put there.
Toggle quote (15 lines)
> +      (home-page "https://harelang.org")
> +      (synopsis "Systems programming language")
> +      (description "Hare is a systems programming language that aims
> to improve
> +on C while retaining its core philosophy. Its principles are:
> +@itemize
> +@item Trust the programmer.
> +@item Provide tools the programmer may use when they don't trust
> themselves.
> +@item Prefer explicit behavior over implicit behavior.
> +@item A good program must be both correct and simple.
> +@end itemize")
> +      (license (list license:gpl3 ;compiler and build driver
> +                     license:mpl2.0))))) ;standard library

Cheers
M
M
Maxime Devos wrote on 26 Jun 09:30 +0200
Re: [bug#55606] [PATCH 2/2] gnu: Add hare.
e53a18a96cc94ebc5ec0797c399f283d7900324e.camel@telenet.be
Antero Mejr schreef op zo 26-06-2022 om 00:40 [-0400]:
Toggle quote (7 lines)
> > + The Guix 'R Us version works with cross-compilation; I don't
> > think this
> >    one does?
> You mean cross-compilation of hare code? When I try to use hare build
> -t (the target flag) it gives me a not implemented error, so I don't
> think hare cross-compilation is possible right now.

IIRC, it was for cross-compiling the compiler itself, not using harec
as a cross-compiler.

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYrgLEBccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7gGJAP96sffch53aCaNIhAY+SiMgGZBp
CReB6BboaaGGHEvM2AD/ShFKNCXuH3VaIYTtgIh2BZtzvb2G7ku6UQWr072+uAQ=
=UqI0
-----END PGP SIGNATURE-----


M
M
Maxime Devos wrote on 26 Jun 09:34 +0200
74953c055d467420fdd4b0d13a6d42800da2eafb.camel@telenet.be
Antero Mejr schreef op zo 26-06-2022 om 00:40 [-0400]:
Toggle quote (9 lines)
> > + harec and qbe probably shouldn't be propagated; their paths
> > should be
> >    patched into the source code.
> >
> >      -- (
>
> I'm unsure about this one - maybe the user would want to use harec or
> qbe by themselves to debug a build step?

FWIW, they can use "guix install harec qbe" for that.

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYrgL+xccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7sMNAQCKMJEagJT72SY/xgCz5ghR204C
oFDJDAygbOHiFKqFcAEAs+ILkirAhL6Mh1Lhnl1d9HGWy1+StfWfdv6j/hx8Lgc=
=83Ve
-----END PGP SIGNATURE-----


(
(name . Antero Mejr)(address . antero@mailbox.org)
CL00H831S29H.1W4RJZE71SNXQ@guix-aspire
On Sun Jun 26, 2022 at 5:40 AM BST, Antero Mejr wrote:
Toggle quote (3 lines)
> As for cross-compilation of the guix hare build, I think the
> platform-linux-architecture bit should take care of it, right?

My mistake, I realized that it would work shortly after sending that.

Toggle quote (6 lines)
> I'm unsure about this one - maybe the user would want to use harec or
> qbe by themselves to debug a build step?
> I wanted to give the user a full hare build environment when
> they run `guix install hare`, but I understand your logic for wanting to
> patch the paths in.

There are a few compilers where intermediate build programs aren't
included in propagated-inputs:

+ neither ldc nor zig include ld or as (nor the llvm equivalents)
+ neither nim nor ghc include gcc

I think it should be fine.

-- (
(
Re: [PATCH 2/2] gnu: Add hare.
CL00MQOJDX2I.4XFK940NJYVS@guix-aspire
On Sun Jun 26, 2022 at 8:18 AM BST, Liliana Marie Prikler wrote:
Toggle quote (2 lines)
> Is there a need to split HAREPATH like that?

Yes. The standard library modules and third-party modules are stored in
different directories. (Don't ask... :P)

Toggle quote (6 lines)
> From a functionality
> perspective, a singular "include/hare" or similar ought to be enough.
> I'd specifically avoid "src" since it exists "only for reference
> purposes" in the FHS. Other distros mandate that the linux kernel
> source code be put there.

Well, it contains source code, and Hare makefiles install into /usr/src
by default, so using src makes sense.

-- (
A
A
Antero Mejr wrote on 26 Jun 15:59 +0200
[PATCH 1/2] gnu: Add harec.
(address . 55606@debbugs.gnu.org)
20220626135940.10504-1-antero@mailbox.org
Resolving the issues mentioned above.

* gnu/packages/hare.scm (harec): New variable.
---
gnu/packages/hare.scm | 67 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 67 insertions(+)
create mode 100644 gnu/packages/hare.scm

Toggle diff (75 lines)
diff --git a/gnu/packages/hare.scm b/gnu/packages/hare.scm
new file mode 100644
index 0000000000..abded91007
--- /dev/null
+++ b/gnu/packages/hare.scm
@@ -0,0 +1,67 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2022 (unmatched parenthesis <paren@disroot.org>
+;;; Copyright © 2022 Antero Mejr <antero@mailbox.org>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages hare)
+  #:use-module (gnu packages base)
+  #:use-module (gnu packages c)
+  #:use-module (gnu packages man)
+  #:use-module (guix build-system gnu)
+  #:use-module (guix download)
+  #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix gexp)
+  #:use-module (guix git-download)
+  #:use-module (guix packages)
+  #:use-module (guix platform)
+  #:use-module (guix utils))
+
+(define-public harec
+  (let ((commit "bbabe09bddf74bd699f8ad2224fdd6e2eefbd35e")
+        (revision "0"))
+    (package
+      (name "harec")
+      (version (git-version "0.0.0" revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://git.sr.ht/~sircmpwn/harec")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "0sa8rjj5w01n55svql8drv761ks6i1bl9q4gj1yzr31dixaf6xvr"))))
+      (build-system gnu-build-system)
+      (arguments
+       (list #:configure-flags #~(list (string-append "--prefix=" #$output))
+             #:phases #~(modify-phases %standard-phases
+                          (replace 'configure
+                            (lambda* (#:key outputs
+                                      (configure-flags '()) #:allow-other-keys)
+                              (setenv "AR" #$(ar-for-target))
+                              (setenv "AS" #$(as-for-target))
+                              (setenv "CC" #$(cc-for-target))
+                              (setenv "LD" #$(ld-for-target))
+                              (setenv "QBE" (which "qbe"))
+                              (apply invoke "./configure" configure-flags))))))
+      (native-inputs (list qbe))
+      (home-page "https://harelang.org")
+      (synopsis "Hare bootstrap compiler in C")
+      (description "This package provides @code{harec}, the Hare language's
+bootstrap written in C.  Currently, @code{harec} is used as the default
+compiler in the @code{hare} build driver.")
+      (license license:gpl3))))
-- 
2.36.1
A
A
Antero Mejr wrote on 26 Jun 15:59 +0200
[PATCH 2/2] gnu: Add hare.
(address . 55606@debbugs.gnu.org)
20220626135940.10504-2-antero@mailbox.org
* gnu/packages/hare.scm (hare): New variable.
---
gnu/packages/hare.scm | 74 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 74 insertions(+)

Toggle diff (84 lines)
diff --git a/gnu/packages/hare.scm b/gnu/packages/hare.scm
index abded91007..5e51ace67f 100644
--- a/gnu/packages/hare.scm
+++ b/gnu/packages/hare.scm
@@ -65,3 +65,77 @@ (define-public harec
 bootstrap written in C.  Currently, @code{harec} is used as the default
 compiler in the @code{hare} build driver.")
       (license license:gpl3))))
+
+(define-public hare
+  (let ((commit "19e380ccb7dfe2bcab5f94e6bd03004e3e2c6005")
+        (revision "0"))
+    (package
+      (name "hare")
+      (version (git-version "0.0.0" revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://git.sr.ht/~sircmpwn/hare")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "04fk3akj3410f8fxw2ixp6l6f9x54pnnk00c0hx0297p7hdzzzq4"))))
+      (build-system gnu-build-system)
+      (arguments
+       (list #:phases
+             #~(modify-phases %standard-phases
+                 (add-after 'unpack 'patch-failing-tests
+                   (lambda _
+                     ;; These tests fail due to a NaN-related bug in QBE when
+                     ;; used on glibc.
+                     (substitute* "math/complex/+test.ha"
+                       (("@test (fn (cos|cosh|exp)\\(\\) void =)" _ func)
+                        func))))
+                 (add-after 'unpack 'patch-makefile
+                   (lambda _
+                     (substitute* "Makefile"
+                       (("include config.mk") ""))))
+                 (add-before 'build 'set-env
+                   (lambda _
+                     (setenv "BINDIR" (string-append #$output "/bin"))
+                     (setenv "MANDIR" (string-append #$output "/share/man"))
+                     (setenv "SRCDIR" (string-append #$output "/src"))
+                     (setenv "LOCALSRCDIR" (string-append #$output "/src/hare"))
+                     (setenv "HAREC" (which "harec"))
+                     (setenv "PLATFORM" "linux")
+                     (setenv "HAREPATH" (string-append
+                                         #$output "/src/hare/stdlib:"
+                                         #$output "/src/hare/third-party"))
+                     (setenv "ARCH"
+                             #$(platform-linux-architecture
+                                (lookup-platform-by-target-or-system
+                                 (or (%current-target-system)
+                                     (%current-system)))))
+                     (setenv "AR" #$(ar-for-target))
+                     (setenv "AS" #$(as-for-target))
+                     (setenv "LD" #$(ld-for-target))
+                     (setenv "QBE" (which "qbe"))
+                     (setenv "SCDOC" (which "scdoc"))
+                     (setenv "HARECACHE" ".cache")
+                     (setenv "BINOUT" ".bin")))
+                 (delete 'configure))))
+      (native-inputs (list harec qbe scdoc))
+      (inputs (list tzdata))
+      (supported-systems (list "x86_64-linux" "aarch64-linux" "riscv64-linux"))
+      (native-search-paths
+       (list (search-path-specification
+              (variable "HAREPATH")
+              (files '("src/hare/stdlib" "src/hare/third-party")))))
+      (home-page "https://harelang.org")
+      (synopsis "Systems programming language")
+      (description "Hare is a systems programming language that aims to improve
+on C while retaining its core philosophy. Its principles are:
+@itemize
+@item Trust the programmer.
+@item Provide tools the programmer may use when they don't trust themselves.
+@item Prefer explicit behavior over implicit behavior.
+@item A good program must be both correct and simple.
+@end itemize")
+      (license (list license:gpl3 ;compiler and build driver
+                     license:mpl2.0))))) ;standard library
-- 
2.36.1
A
A
Antero Mejr wrote on 26 Jun 16:00 +0200
(name . Liliana Marie Prikler)(address . liliana.prikler@gmail.com)
87tu87frkd.fsf@mailbox.org
Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
Toggle quote (3 lines)
>> +                     (string-append "HAREC=" #$harec "/bin/harec")
> Should have a (this-package-input) or (this-package-native-input) for
> harec. If it's the latter, (which "harec") might also be acceptable.
Done.
Toggle quote (2 lines)
>> +                     (string-append "QBE=" #$qbe "/bin/qbe")
> As with harec.
Done.
Toggle quote (2 lines)
>> +                     (string-append "SCDOC=" #$scdoc "/bin/scdoc")
> As with harec.
Done.
Toggle quote (3 lines)
>> +                     "HARECACHE=.cache"
>> +                     "BINOUT=.bin")
> I suppose neither of those ought to be installed?
Right, they're temp dirs. I checked the build output and made sure they
are not included.
Toggle quote (3 lines)
>> +                 (delete 'configure))))
> Why delete configure here, but not in harec? I'm pretty sure we can
> use the same hack for both packages.
hare doesn't have a configure, so we have to set the flags for the
build manually. harec does have a configure that correctly sets many
of the build flags, so I used it.
Thanks,
Antero
M
M
Maxime Devos wrote on 26 Jun 16:20 +0200
fbc53bfbf6c5aa3f4c815f20b889e19ec7b0765d.camel@telenet.be
Antero Mejr schreef op zo 26-06-2022 om 09:59 [-0400]:
Toggle quote (2 lines)
> +      (inputs (list tzdata))

What's this input for? Packages shouldn't have tzdata in their inputs,
because it's a bunch of facts about the external world. When doing
this, running hare's equivalent of `date` from an old profile would
give a bogus result because of out-of-date time zone info.

Also, the rebuilding problem, from (gnu packages base):

;;; A "fixed" version of tzdata, which is used in the test suites of glib and R
;;; and a few other places. We can update this whenever we are able to rebuild
;;; thousands of packages (for example, in a core-updates rebuild). This package
;;; will typically be obsolete and should never be referred to by a built
;;; package.
;;;
;;; Please make this a hidden-package if it is different from the primary tzdata
;;; package.
(define-public tzdata-for-tests tzdata)

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYrhrLhccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7qgdAP9ICrumLPIBfbQG6CE5WOBMqraO
Xz24/IgWL4ZhKmCs7gEAysC6CZTodiOi/e6v1S55BboLSkw4q9yAF3TZrp590A4=
=Vkmu
-----END PGP SIGNATURE-----


A
A
Antero Mejr wrote on 26 Jun 16:07 +0200
Re: [bug#55606] [PATCH 2/2] gnu: Add hare.
(name . ()(address . paren@disroot.org)
87bkuffquv.fsf@mailbox.org
"(" <paren@disroot.org> writes:

Toggle quote (8 lines)
> There are a few compilers where intermediate build programs aren't
> included in propagated-inputs:
>
> + neither ldc nor zig include ld or as (nor the llvm equivalents)
> + neither nim nor ghc include gcc
>
> I think it should be fine.

If harec/qbe are not installed, hare raises an error saying that it
cannot find the program, so users will know to install it. So yes it
should be fine, I moved those programs into native-inputs.

If we moved qbe/harec to inputs, we could patch os::tryenv in
schedule.ha to resolve to the guix path. That way the user gets a
working toolchain by default, but they could still swap in different
versions of qbe/harec using the QBE/HAREC environment variables.
Let me know if that would be preferred over leaving qbe/harec in
native-inputs.

Thanks,
Antero
M
M
Maxime Devos wrote on 26 Jun 16:22 +0200
Re: [PATCH 2/2] gnu: Add hare.
972c0ec00f8ae99cfa8ae569146b767c2c450d67.camel@telenet.be
Antero Mejr schreef op zo 26-06-2022 om 09:59 [-0400]:
Toggle quote (2 lines)
> +      (synopsis "Systems programming language")

You can't package the language itself. DYM: ‘The Hare compiler’, or
maybe: ‘The Hare standard library’, or both?

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYrhrshccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7iYhAP0Vs3ALSm2wteuR8Vbj8Oro34Mj
zEZHllEIhF00Ujba7wD/ddP3vaypw3KCmV/MrcVDzHNP+i7f10W0Xu6/gn1lrQA=
=ArMH
-----END PGP SIGNATURE-----


M
M
Maxime Devos wrote on 26 Jun 16:27 +0200
Re: [bug#55606] [PATCH 2/2] gnu: Add hare.
a10397649ec2f912665dc41cb388877152d6f1a9.camel@telenet.be
Antero Mejr schreef op zo 26-06-2022 om 10:07 [-0400]:
Toggle quote (5 lines)
> If harec/qbe are not installed, hare raises an error saying that it
> cannot find the program, so users will know to install it. So yes it
> should be fine,
>

TBC: what is this package packaging?

* the compiler
* some wrapper around the compiler
* the standard library and the compiler
* both

If it packages the compiler, this is not fine. Guix is a package
manager and distribution, the point of which is to automatically sort
out dependencies. Leaving it up to the user to sort out the
dependencies then partially defeats the point.

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYrhs6xccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7mfeAQDQRSd0nVUpJ2mBJn5y6DDCR9Zl
ANTaxk7aKRZfeHB5wgEA20go8Xiq09Rt57KLFe13WJsmDu+ICuhtHbkQvOJx0wg=
=dCgL
-----END PGP SIGNATURE-----


A
A
Antero Mejr wrote on 26 Jun 16:30 +0200
Re: [PATCH 2/2] gnu: Add hare.
(name . Maxime Devos)(address . maximedevos@telenet.be)
874k07fqb1.fsf@mailbox.org
Maxime Devos <maximedevos@telenet.be> writes:

Toggle quote (7 lines)
>> +      (inputs (list tzdata))
>
> What's this input for? Packages shouldn't have tzdata in their inputs,
> because it's a bunch of facts about the external world. When doing
> this, running hare's equivalent of `date` from an old profile would
> give a bogus result because of out-of-date time zone info.

I forgot to patch the path in leapsec.ha to use for Guix's leapseconds
file. Should I do that, or leave out tzdata?

From the hare mailing list:

"Notably, Hare requires the installation of the leap-seconds.list file in
the tzdata package in order to handle leap seconds properly.

Hare will work in the absence of this file, or of tzdata as a whole, but
users will encounter bugs in timekeeping logic."

A
A
Antero Mejr wrote on 26 Jun 16:33 +0200
(name . Maxime Devos)(address . maximedevos@telenet.be)
87zghzebnh.fsf@mailbox.org
Maxime Devos <maximedevos@telenet.be> writes:

Toggle quote (5 lines)
>> +      (synopsis "Systems programming language")
>
> You can't package the language itself. DYM: ‘The Hare compiler’, or
> maybe: ‘The Hare standard library’, or both?

I was going to use
"Hare programming language build driver and standard library"
in the next patch.
M
M
Maxime Devos wrote on 26 Jun 16:39 +0200
(name . Antero Mejr)(address . antero@mailbox.org)
2133c0d9e8ac58612b34d40c323236b481b39e80.camel@telenet.be
Antero Mejr schreef op zo 26-06-2022 om 10:30 [-0400]:
Toggle quote (3 lines)
> I forgot to patch the path in leapsec.ha to use for Guix's leapseconds
> file. Should I do that, or leave out tzdata?

Looking at https://harelang.org/distributions/, harec expects it to
be located in /usr/share/zoneinfo/leap-seconds.list by default (not
/gnu/store/.../share/tzdata), so adding tzdata as input doesn't
accomplish anything here.

So to have time zone things working on Guix System, it seems like hare
needs to be patched to support the $TZDIR environment variable (if it
doesn't support that already).

Also, I think there was some mail or message on #guix some time ago
about Guix not installing that particular file yet in the tzdata
package? That would need to be fixed as well ...

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYrhvhxccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7gj+AQDY31LkBSttpUTnnYBNCgidm54Q
KAhyM7MZaxbPL2V5FQEAmPviVsDDl486IoA+efPGuWpZsDjBYdIBsp8YxRa3rw0=
=Chhv
-----END PGP SIGNATURE-----


M
M
Maxime Devos wrote on 26 Jun 16:44 +0200
(name . Antero Mejr)(address . antero@mailbox.org)
ee28dfb2033b76ccb38b017f39e2f06254e2e1b3.camel@telenet.be
Antero Mejr schreef op zo 26-06-2022 om 10:33 [-0400]:
Toggle quote (4 lines)
> I was going to use
> "Hare programming language build driver and standard library"
> in the next patch.

I don't have a clue what a ‘build driver’ is (a kernel-style driver +
something about building -> a compiler inside the (Linux) kernel?
Doesn't seem to apply here). I'd use ‘compiler’ instead, which I
believe to be more widely understood (e.g., it has an entry on
Wikipedia).

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYrhwyBccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7rCuAP42mhxbZ4Z64eCH16T43+AosS+2
d7OLF2X9dpsKOInSVAD8CRgzppITggj2rSHBXWoJGcMq32/SHD5CFgWMmuJQlgw=
=v28Z
-----END PGP SIGNATURE-----


A
A
Antero Mejr wrote on 26 Jun 16:39 +0200
Re: [bug#55606] [PATCH 2/2] gnu: Add hare.
(name . Maxime Devos)(address . maximedevos@telenet.be)
87sfnreaxv.fsf@mailbox.org
Maxime Devos <maximedevos@telenet.be> writes:

Toggle quote (12 lines)
> TBC: what is this package packaging?
>
> * the compiler
> * some wrapper around the compiler
> * the standard library and the compiler
> * both
>
> If it packages the compiler, this is not fine. Guix is a package
> manager and distribution, the point of which is to automatically sort
> out dependencies. Leaving it up to the user to sort out the
> dependencies then partially defeats the point.

My current understanding is:
The "hare" package is the standard library and a "build driver", which
orchestrates the program "harec" to compile hare programs into QBE IR,
and then hare calls qbe and binutils to compile the program to a
binary.

I think they refer to a "build driver" as "a program that calls other
programs to do a build". Kind of like Rust's cargo build system,
but without full package management.

However, in the future the plan is for hare to be a self-hosted
compiler and build system, dropping the harec dependency (will still
need it, but just for bootstrapping). Not sure if they will replace qbe
as well.

Our options are:
1. Provide the build driver "hare" standalone, then a "hare-toolchain"
package that propagates hare, harec, qbe, and binutils. This is how it
was done by ) on Guix'R'Us.
2. Add qbe and harec to propagated-inputs of hare. This is what the
earlier patch did.
3. Add qbe and harec to inputs, and patch the source code to direct
the build driver to the Guix paths.
M
M
Maxime Devos wrote on 26 Jun 16:53 +0200
(name . Antero Mejr)(address . antero@mailbox.org)
ec9edc66f1f2386cfc60404411a39663a031daa4.camel@telenet.be
Maxime Devos schreef op zo 26-06-2022 om 16:44 [+0200]:
Toggle quote (12 lines)
> Antero Mejr schreef op zo 26-06-2022 om 10:33 [-0400]:
> > I was going to use
> > "Hare programming language build driver and standard library"
> > in the next patch.
>
> I don't have a clue what a ‘build driver’ is (a kernel-style driver +
> something about building -> a compiler inside the (Linux) kernel?
> Doesn't seem to apply here).  I'd use ‘compiler’ instead, which I
> believe to be more widely understood (e.g., it has an entry on
> Wikipedia).
>

Maybe nevermind. From #guix:

14:47 < nckx> 'The build driver is responsible for collecting input files,
resolving their dependencies, and producing a plan for
compiling your program.' —
14:48 < nckx> Seemingly not synonymous.

although:

14:51 < maximed> (OTOH, technically 'gcc' isn't the compiler but 'cc1' is ...)

and yet we call 'gcc' a compiler and seems a bit of an implementation detail
to me, so I dunno.

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYrhzBxccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7jhpAP9EszBaPWFXsRGErGOaxxKQhg9Q
hMZZBnYH6koX63NitQD/XD6qJ4lPDM1aeHugPwuAhkK9hsMQHMR/bIBznA6gQAg=
=kTfk
-----END PGP SIGNATURE-----


(
(address . control@debbugs.gnu.org)
CL3MKBDPR3LV.3R1MTRSR9A725@guix-aspire
close 55187
thanks

Superseded by #55606.

-- (
(
(name . Antero Mejr)(address . antero@mailbox.org)
CLO0MXRILE1Z.4XAE4TMFRA4L@guix-aspire
On Sun Jun 26, 2022 at 3:07 PM BST, Antero Mejr wrote:
Toggle quote (4 lines)
> If we moved qbe/harec to inputs, we could patch os::tryenv in
> schedule.ha to resolve to the guix path. That way the user gets a
> working toolchain by default, but they could still swap in different
> versions of qbe/harec using the QBE/HAREC environment variables.
Yes, that's what I meant. (Sorry for the late reply :))

-- (
?
Your comment

This issue is archived.

To comment on this conversation send email to 55606@debbugs.gnu.org