diff mbox series

[bug#69552,vREVISION,1/2] gnu: Add cyclone-bootstrap.

Message ID 9e15650dea41ee388dbbb01bf09c59758a0e34f4.1709769419.git.takev@disroot.org
State New
Headers show
Series [bug#69552,vREVISION,1/2] gnu: Add cyclone-bootstrap. | expand

Commit Message

TakeV March 6, 2024, 11:56 p.m. UTC
* gnu/packages/scheme.scm (cyclone-bootstrap): New variable.

Change-Id: I85d37ebc48882d4b830ef34851ae6d37ecf2e6e5
---
 gnu/packages/scheme.scm | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)


base-commit: 201f90f34f90242bb74baa5ca44bda6131b3a035

Comments

Christopher Baines March 13, 2024, 12:12 p.m. UTC | #1
tags 69552 + moreinfo
user guix
usertag 69552 - reviewed-looks-good
quit

TakeV via Guix-patches via <guix-patches@gnu.org> writes:

> * gnu/packages/scheme.scm (cyclone-bootstrap): New variable.
>
> Change-Id: I85d37ebc48882d4b830ef34851ae6d37ecf2e6e5
> ---
>  gnu/packages/scheme.scm | 41 +++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 41 insertions(+)
>
> diff --git a/gnu/packages/scheme.scm b/gnu/packages/scheme.scm
> index ad06d7db06..e0151e954c 100644
> --- a/gnu/packages/scheme.scm
> +++ b/gnu/packages/scheme.scm
> @@ -23,6 +23,7 @@
>  ;;; Copyright © 2023 Andrew Whatson <whatson@tailcall.au>
>  ;;; Copyright © 2023 Juliana Sims <juli@incana.org>
>  ;;; Copyright © 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
> +;;; Copyright © 2024 TakeV <takev@disroot.org>
>  ;;;
>  ;;; This file is part of GNU Guix.
>  ;;;
> @@ -59,6 +60,7 @@ (define-module (gnu packages scheme)
>    #:use-module (gnu packages base)
>    #:use-module (gnu packages bash)
>    #:use-module (gnu packages bdw-gc)
> +  #:use-module (gnu packages c)
>    #:use-module (gnu packages compression)
>    #:use-module (gnu packages databases)
>    #:use-module (gnu packages emacs)
> @@ -1276,3 +1278,42 @@ (define-public stklos
>  Machine.  STklos can also be compiled as a library and embedded in an
>  application.")
>      (license gpl2+)))
> +
> +;; Cyclone is self-hosted. To build it, we require the bootstrap compiler.
> +(define cyclone-bootstrap
> +  (package
> +    (name "cyclone-bootstrap")
> +    (version "0.36.0")
> +    ;; TODO Use system's libtommath after
> +    ;; https://github.com/justinethier/cyclone/issues/458 is resolved
> +    (source
> +     (origin
> +       (method git-fetch)
> +       (uri (git-reference
> +             (url "https://github.com/justinethier/cyclone-bootstrap.git")
> +             (commit (string-append "v" version))))
> +       (file-name (git-file-name name version))
> +       (sha256
> +        (base32 "0fv0mnrn5shbx77383f4mbkvc4i9yyj1bjm3dfyhipnaqapbhqpi"))))

I've had a look at this and I'm concerned about the bootstrapping
approach. If you look at cyclone.c, I'm pretty sure that's not the
preferred form for editing and it doesn't look like that from the
commits.

Maybe there are things already in Guix that are similarly bad, but I
don't think that alone is sufficient to include more.
TakeV March 13, 2024, 12:32 p.m. UTC | #2
On 3/13/24 08:12, Christopher Baines wrote:

> tags 69552 + moreinfo
> user guix
> usertag 69552 - reviewed-looks-good
> quit
>
> TakeV via Guix-patches via <guix-patches@gnu.org> writes:
> I've had a look at this and I'm concerned about the bootstrapping
> approach. If you look at cyclone.c, I'm pretty sure that's not the
> preferred form for editing and it doesn't look like that from the
> commits.
>
> Maybe there are things already in Guix that are similarly bad, but I
> don't think that alone is sufficient to include more.

Do you mean the package is wrong, or cyclone itself is not going about 
it the correct way? The instructions for building from source specify 
that this is the intended way of handling it.
Christopher Baines March 13, 2024, 12:45 p.m. UTC | #3
TakeV <takev@disroot.org> writes:

> On 3/13/24 08:12, Christopher Baines wrote:
>
>> tags 69552 + moreinfo
>> user guix
>> usertag 69552 - reviewed-looks-good
>> quit
>>
>> TakeV via Guix-patches via <guix-patches@gnu.org> writes:
>> I've had a look at this and I'm concerned about the bootstrapping
>> approach. If you look at cyclone.c, I'm pretty sure that's not the
>> preferred form for editing and it doesn't look like that from the
>> commits.
>>
>> Maybe there are things already in Guix that are similarly bad, but I
>> don't think that alone is sufficient to include more.
>
> Do you mean the package is wrong, or cyclone itself is not going about
> it the correct way? The instructions for building from source specify
> that this is the intended way of handling it.

It's not that cyclone is going about it in an incorrect way, just that
the approach used doesn't match up with Guix's requirement to build from
source (which is the prefered form for modification) in all but
exceptional cases.

Contrast this with Guile for example [1], rather than using some
generated C file for bootstrapping, it uses a Scheme interpreter
implemented in C.

1: https://bootstrappable.org/best-practices.html
TakeV March 13, 2024, 2:17 p.m. UTC | #4
I think I am a bit confused. Are you saying that we need to be able to generate the file ourselves from scratch, rather than using the upstream source code?

Or do you mean that we package the first version of the bootstrap compiler which is not automatically generated, then use the result to generate the cyclone binary, then use that to generate the bootstrap compiler, and so forth until we are at the latest version?

Mostly uncertain because the self-hosted compiler does generate the bootstrap compiler's source, but it is not needed to build the bootstrap compiler itself, and thus seems to be the same approach as guile aside from how the source code being written by a person vs a computer. 



-------- Original Message --------
From: Christopher Baines <mail@cbaines.net>
Sent: March 13, 2024 8:45:03 AM EDT
To: TakeV <takev@disroot.org>
Cc: 69552@debbugs.gnu.org, guix-patches@gnu.org
Subject: Re: [bug#69552] [PATCH vREVISION 1/2] gnu: Add cyclone-bootstrap.


TakeV <takev@disroot.org> writes:

> On 3/13/24 08:12, Christopher Baines wrote:
>
>> tags 69552 + moreinfo
>> user guix
>> usertag 69552 - reviewed-looks-good
>> quit
>>
>> TakeV via Guix-patches via <guix-patches@gnu.org> writes:
>> I've had a look at this and I'm concerned about the bootstrapping
>> approach. If you look at cyclone.c, I'm pretty sure that's not the
>> preferred form for editing and it doesn't look like that from the
>> commits.
>>
>> Maybe there are things already in Guix that are similarly bad, but I
>> don't think that alone is sufficient to include more.
>
> Do you mean the package is wrong, or cyclone itself is not going about
> it the correct way? The instructions for building from source specify
> that this is the intended way of handling it.

It's not that cyclone is going about it in an incorrect way, just that
the approach used doesn't match up with Guix's requirement to build from
source (which is the prefered form for modification) in all but
exceptional cases.

Contrast this with Guile for example [1], rather than using some
generated C file for bootstrapping, it uses a Scheme interpreter
implemented in C.

1: https://bootstrappable.org/best-practices.html
Christopher Baines March 13, 2024, 2:42 p.m. UTC | #5
TakeV <takev@disroot.org> writes:

> I think I am a bit confused. Are you saying that we need to be able to
> generate the file ourselves from scratch, rather than using the
> upstream source code?
>
> Or do you mean that we package the first version of the bootstrap
> compiler which is not automatically generated, then use the result to
> generate the cyclone binary, then use that to generate the bootstrap
> compiler, and so forth until we are at the latest version?

I don't have a solution to suggest unfortunately, I'm just raising this
as a problem.

Either of the approaches you suggest above would work.

> Mostly uncertain because the self-hosted compiler does generate the
> bootstrap compiler's source, but it is not needed to build the
> bootstrap compiler itself, and thus seems to be the same approach as
> guile aside from how the source code being written by a person vs a
> computer.

It's the "how the source code being written by a person vs a computer"
bit that's key, source code generated by a computer isn't the preferred
form for editing, so building from it is not building from source, even
though it's source code.
diff mbox series

Patch

diff --git a/gnu/packages/scheme.scm b/gnu/packages/scheme.scm
index ad06d7db06..e0151e954c 100644
--- a/gnu/packages/scheme.scm
+++ b/gnu/packages/scheme.scm
@@ -23,6 +23,7 @@ 
 ;;; Copyright © 2023 Andrew Whatson <whatson@tailcall.au>
 ;;; Copyright © 2023 Juliana Sims <juli@incana.org>
 ;;; Copyright © 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2024 TakeV <takev@disroot.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -59,6 +60,7 @@  (define-module (gnu packages scheme)
   #:use-module (gnu packages base)
   #:use-module (gnu packages bash)
   #:use-module (gnu packages bdw-gc)
+  #:use-module (gnu packages c)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages databases)
   #:use-module (gnu packages emacs)
@@ -1276,3 +1278,42 @@  (define-public stklos
 Machine.  STklos can also be compiled as a library and embedded in an
 application.")
     (license gpl2+)))
+
+;; Cyclone is self-hosted. To build it, we require the bootstrap compiler.
+(define cyclone-bootstrap
+  (package
+    (name "cyclone-bootstrap")
+    (version "0.36.0")
+    ;; TODO Use system's libtommath after
+    ;; https://github.com/justinethier/cyclone/issues/458 is resolved
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/justinethier/cyclone-bootstrap.git")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "0fv0mnrn5shbx77383f4mbkvc4i9yyj1bjm3dfyhipnaqapbhqpi"))))
+    (inputs (list ck))
+    (build-system gnu-build-system)
+    (arguments
+     (list
+      #:phases #~(modify-phases %standard-phases
+                   (delete 'configure))
+      #:test-target "test"
+      #:make-flags #~(list "CC=gcc"
+                           (string-append "PREFIX="
+                                          #$output))))
+    (home-page "https://github.com/justinethier/cyclone-bootstrap")
+    (synopsis "Cyclone Scheme bootstrap compiler")
+    (description
+     "Cyclone Scheme is a brand-new, R7RS Scheme-to-C compiler that uses a
+variant of Cheney on the MTA to implement full tail recursion,
+continuations, and generational garbage collection.  This package uses
+intermediate code generated by compiling the Scheme source files to
+build and install Cyclone Scheme.  The compiler is self-hosting and
+cannot be built directly on a system without Cyclone binaries
+installed.")
+    (license expat)))
+