diff mbox series

[bug#53878,v5,06/22] gnu: racket-minimal: Change inheritance to follow bootstrapping.

Message ID 20220226130254.1301333-7-philip@philipmcgrath.com
State Accepted
Headers show
Series Update Racket to 8.4. Adjust Chez Scheme packages. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Philip McGrath Feb. 26, 2022, 1:02 p.m. UTC
Having the package inheritance chain go in the same direction as the
bootstrapping chain, rather than the opposite, is less confusing. In
some cases, it can also help to avoid unnecessary rebuilds.

* gnu/packages/racket.scm (racket-minimal-bc-cgc): Change to be the root
of the package inheritance chain.
[version, source, inputs, native-inputs, build-system, arguments,
home-page, license]: Inline formerly inherited values.
(racket-minimal-bc-3m): Inherit from 'racket-minimal-bc-cgc' rather than
'racket-minimal'.
[inputs, native-inputs, arguments, license]: Adjust accordingly.
(racket-minimal): Inherit from 'racket-minimal-bc-3m'.
[inputs, native-inputs, arguments, license]: Adjust accordingly.
[properties]: Override effect of 'hidden-package'.
---
 gnu/packages/racket.scm | 294 ++++++++++++++++++++--------------------
 1 file changed, 147 insertions(+), 147 deletions(-)

Comments

Liliana Marie Prikler Feb. 26, 2022, 2:19 p.m. UTC | #1
Am Samstag, dem 26.02.2022 um 08:02 -0500 schrieb Philip McGrath:
> Having the package inheritance chain go in the same direction as the
> bootstrapping chain, rather than the opposite, is less confusing. In
> some cases, it can also help to avoid unnecessary rebuilds.
> 
> * gnu/packages/racket.scm (racket-minimal-bc-cgc): Change to be the
> root
> of the package inheritance chain.
> [version, source, inputs, native-inputs, build-system, arguments,
> home-page, license]: Inline formerly inherited values.
> (racket-minimal-bc-3m): Inherit from 'racket-minimal-bc-cgc' rather
> than
> 'racket-minimal'.
> [inputs, native-inputs, arguments, license]: Adjust accordingly.
> (racket-minimal): Inherit from 'racket-minimal-bc-3m'.
> [inputs, native-inputs, arguments, license]: Adjust accordingly.
> [properties]: Override effect of 'hidden-package'.
> ---
I think this patch might introduce some noise by moving a package to a
different location in the file.  If possible, we might want to avoid
this and relocate afterwards – IIUC positioning within a file should
not matter when it comes to the inherit clause.

Other than that not much to argue against.

Cheers
Philip McGrath Feb. 26, 2022, 3:16 p.m. UTC | #2
Hi,

On Saturday, February 26, 2022 9:19:20 AM EST Liliana Marie Prikler wrote:
> Am Samstag, dem 26.02.2022 um 08:02 -0500 schrieb Philip McGrath:
> > Having the package inheritance chain go in the same direction as the
> > bootstrapping chain, rather than the opposite, is less confusing. In
> > some cases, it can also help to avoid unnecessary rebuilds.
> > 
> > * gnu/packages/racket.scm (racket-minimal-bc-cgc): Change to be the
> > root
> > of the package inheritance chain.
> > [version, source, inputs, native-inputs, build-system, arguments,
> > home-page, license]: Inline formerly inherited values.
> > (racket-minimal-bc-3m): Inherit from 'racket-minimal-bc-cgc' rather
> > than
> > 'racket-minimal'.
> > [inputs, native-inputs, arguments, license]: Adjust accordingly.
> > (racket-minimal): Inherit from 'racket-minimal-bc-3m'.
> > [inputs, native-inputs, arguments, license]: Adjust accordingly.
> > [properties]: Override effect of 'hidden-package'.
> > ---
> 
> I think this patch might introduce some noise by moving a package to a
> different location in the file.  If possible, we might want to avoid
> this and relocate afterwards – IIUC positioning within a file should
> not matter when it comes to the inherit clause.
> 

I've tested a few things, and the best result I'm getting is to keep the order 
as in this patch—the unchanged portion of `arguments` turns out to be longer 
than the descriptions—but adjust the use of `hidden-package` vs. `properties` 
to avoid indentation changes. In particular, that helps Git to realize that 
`racket-minimal-bc-3m` does not move.

I'll plan on a v6 with this and other things you've found.

-Philip
Liliana Marie Prikler Feb. 26, 2022, 3:19 p.m. UTC | #3
Am Samstag, dem 26.02.2022 um 10:16 -0500 schrieb Philip McGrath:
> I've tested a few things, and the best result I'm getting is to keep
> the order  as in this patch—the unchanged portion of `arguments`
> turns out to be longer than the descriptions—but adjust the use of
> `hidden-package` vs. `properties` to avoid indentation changes. In
> particular, that helps Git to realize that `racket-minimal-bc-3m`
> does not move.
> 
> I'll plan on a v6 with this and other things you've found.
Git lacking sexp diffs, our old nemesis!  Thanks for investigating.
diff mbox series

Patch

diff --git a/gnu/packages/racket.scm b/gnu/packages/racket.scm
index abcd9658b2..f5a8091be0 100644
--- a/gnu/packages/racket.scm
+++ b/gnu/packages/racket.scm
@@ -2,7 +2,7 @@ 
 ;;; Copyright © 2013, 2014, 2015, 2016, 2018, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2017, 2018, 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2020 Pierre Neidhardt <mail@ambrevar.xyz>
-;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
+;;; Copyright © 2021, 2022 Philip McGrath <philip@philipmcgrath.com>
 ;;; Copyright © 2021 jgart <jgart@dismail.de>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -172,99 +172,157 @@  (define (make-unpack-nanopass+stex)
           (display "# to placate ../configure")))))
 
 
+(define-public racket-minimal-bc-cgc
+  ;; Eventually, it may make sense for some vm packages to not be hidden,
+  ;; but this one is especially likely to remain hidden.
+  (hidden-package
+   (package
+     (name "racket-minimal-bc-cgc")
+     (version %racket-version)
+     (source %racket-origin)
+     (inputs
+      (list
+       ;; common to all racket-minimal variants:
+       openssl
+       sqlite
+       bash-minimal ;; <- for `system`
+       ncurses ;; <- for #%terminal
+       ;; only for BC variants:
+       libffi))
+     (native-inputs (list libtool)) ;; <- only for BC variants
+     (build-system gnu-build-system)
+     (arguments
+      (list
+       #:configure-flags
+       #~(cons* "--enable-cgcdefault"
+                #$(racket-vm-common-configure-flags))
+       ;; Tests are in packages like racket-test-core and
+       ;; main-distribution-test that aren't part of the main
+       ;; distribution.
+       #:tests? #f
+       ;; Upstream recommends #:out-of-source?, and it does
+       ;; help with debugging, but it confuses `install-license-files`.
+       #:modules '((ice-9 match)
+                   (ice-9 regex)
+                   (guix build gnu-build-system)
+                   (guix build utils))
+       #:phases
+       #~(modify-phases %standard-phases
+           (add-before 'configure 'initialize-config.rktd
+             (lambda* (#:key inputs #:allow-other-keys)
+               (define (write-racket-hash alist)
+                 ;; inside must use dotted pair notation
+                 (display "#hash(")
+                 (for-each (match-lambda
+                             ((k . v)
+                              (format #t "(~s . ~s)" k v)))
+                           alist)
+                 (display ")\n"))
+               (define maybe-release-catalog
+                 (let ((v #$(package-version this-package)))
+                   (if (string-match "^[0-9]+\\.[0-9]+($|\\.[0-8][0-9]*$)"
+                                     v)
+                       `(,(string-append
+                           "https://download.racket-lang.org/releases/"
+                           v
+                           "/catalog/"))
+                       '())))
+               (mkdir-p "racket/etc")
+               (with-output-to-file "racket/etc/config.rktd"
+                 (lambda ()
+                   (write-racket-hash
+                    `((lib-search-dirs
+                       . (#f #$(file-append (this-package-input "openssl") "/lib")
+                             #$(file-append (this-package-input "sqlite") "/lib")))
+                      (build-stamp . "")
+                      (catalogs ,@maybe-release-catalog
+                                #f)))))))
+           (add-before 'configure 'chdir
+             (lambda _
+               (chdir "racket/src")))
+           (add-after 'install 'remove-pkgs-directory
+             ;; If the configured pkgs-dir exists, "pkgs.rktd" does not
+             ;; exist, and a lock file does not exist, commands like
+             ;; `raco pkg show` will try to create a lock file and fail
+             ;; due to the read-only store.
+             ;; Arguably this may be a bug in `pkg/private/lock`:
+             ;; see <https://github.com/racket/racket/issues/3851>.
+             ;; As a workaround, remove the directory.
+             (lambda args
+               ;; rmdir because we want an error if it isn't empty
+               (rmdir (string-append #$output "/share/racket/pkgs")))))))
+     (home-page "https://racket-lang.org")
+     (synopsis "Old Racket implementation used for bootstrapping")
+     (description "This variant of the Racket BC (``before Chez'' or
+``bytecode'') implementation is not recommended for general use.  It uses
+CGC (a ``Conservative Garbage Collector''), which was succeeded as default in
+PLT Scheme version 370 (which translates to 3.7 in the current versioning
+scheme) by the 3M variant, which in turn was succeeded in version 8.0 by the
+Racket CS implementation.
+
+Racket BC [CGC] is primarily used for bootstrapping Racket BC [3M].  It may
+also be used for embedding applications without the annotations needed in C
+code to use the 3M garbage collector.")
+     ;; https://download.racket-lang.org/license.html
+     ;; The LGPL components are only used by Racket BC.
+     (license (list license:lgpl3+ license:asl2.0 license:expat)))))
+
+(define-public racket-minimal-bc-3m
+  (package
+    (inherit racket-minimal-bc-cgc)
+    (name "racket-minimal-bc-3m")
+    (native-inputs
+     (modify-inputs (package-native-inputs racket-minimal-bc-cgc)
+       (prepend racket-minimal-bc-cgc)))
+    (arguments
+     (substitute-keyword-arguments (package-arguments racket-minimal-bc-cgc)
+       ((#:configure-flags _ '())
+        #~(cons "--enable-bconly"
+                #$(racket-vm-common-configure-flags)))))
+    (synopsis "Minimal Racket with the BC [3M] runtime system")
+    (description "The Racket BC (``before Chez'' or ``bytecode'')
+implementation was the default before Racket 8.0.  It uses a compiler written
+in C targeting architecture-independent bytecode, plus a JIT compiler on most
+platforms.  Racket BC has a different C API and supports a slightly different
+set of architectures than the current default runtime system, Racket CS (based
+on ``Chez Scheme'').
+
+This package is the normal implementation of Racket BC with a precise garbage
+collector, 3M (``Moving Memory Manager'').")))
+
 (define-public racket-minimal
   (package
+    (inherit racket-minimal-bc-3m)
     (name "racket-minimal")
-    (version %racket-version)
-    (source %racket-origin)
     (inputs
-     (list
-      ;; common to all racket-minimal variants:
-      openssl
-      sqlite
-      bash-minimal ;; <- for `system`
-      ncurses ;; <- for #%terminal
-      ;; only for CS
-      zlib
-      lz4))
+     (modify-inputs (package-inputs racket-minimal-bc-cgc)
+       (prepend zlib lz4)
+       (delete "libffi")))
     (native-inputs
-     (list chez-scheme-for-racket-bootstrap-bootfiles
-           racket-minimal-bc-3m))
-    (build-system gnu-build-system)
+     (modify-inputs (package-native-inputs racket-minimal-bc-cgc)
+       (delete "libtool")
+       (prepend chez-scheme-for-racket-bootstrap-bootfiles
+                racket-minimal-bc-3m)))
     (arguments
-     (list
-      #:configure-flags
-      #~(cons* "--enable-csonly"
-               "--enable-libz"
-               "--enable-lz4"
-               #$(racket-vm-common-configure-flags))
-      ;; Tests are in packages like racket-test-core and
-      ;; main-distribution-test that aren't part of the main
-      ;; distribution.
-      #:tests? #f
-      ;; Upstream recommends #:out-of-source?, and it does
-      ;; help with debugging, but it confuses `install-license-files`.
-      #:modules '((ice-9 match)
-                  (ice-9 regex)
-                  (guix build gnu-build-system)
-                  (guix build utils))
-      #:phases
-      #~(modify-phases %standard-phases
-          (add-after 'unpack 'unpack-nanopass+stex
-            (lambda args
-              (with-directory-excursion "racket/src/ChezScheme"
-                #$(make-unpack-nanopass+stex))))
-          (add-after 'unpack-nanopass+stex 'unpack-bootfiles
-            (lambda* (#:key native-inputs inputs #:allow-other-keys)
-              (with-directory-excursion "racket/src/ChezScheme"
-                (copy-recursively
-                 (search-input-directory (or native-inputs inputs)
-                                         "lib/chez-scheme-bootfiles")
-                 "boot"))))
-          (add-before 'configure 'initialize-config.rktd
-            (lambda* (#:key inputs #:allow-other-keys)
-              (define (write-racket-hash alist)
-                ;; inside must use dotted pair notation
-                (display "#hash(")
-                (for-each (match-lambda
-                            ((k . v)
-                             (format #t "(~s . ~s)" k v)))
-                          alist)
-                (display ")\n"))
-              (define maybe-release-catalog
-                (let ((v #$(package-version this-package)))
-                  (if (string-match "^[0-9]+\\.[0-9]+($|\\.[0-8][0-9]*$)"
-                                    v)
-                      `(,(string-append
-                          "https://download.racket-lang.org/releases/"
-                          v
-                          "/catalog/"))
-                      '())))
-              (mkdir-p "racket/etc")
-              (with-output-to-file "racket/etc/config.rktd"
-                (lambda ()
-                  (write-racket-hash
-                   `((lib-search-dirs
-                      . (#f #$(file-append (this-package-input "openssl") "/lib")
-                            #$(file-append (this-package-input "sqlite") "/lib")))
-                     (build-stamp . "")
-                     (catalogs ,@maybe-release-catalog
-                               #f)))))))
-          (add-before 'configure 'chdir
-            (lambda _
-              (chdir "racket/src")))
-          (add-after 'install 'remove-pkgs-directory
-            ;; If the configured pkgs-dir exists, "pkgs.rktd" does not
-            ;; exist, and a lock file does not exist, commands like
-            ;; `raco pkg show` will try to create a lock file and fail
-            ;; due to the read-only store.
-            ;; Arguably this may be a bug in `pkg/private/lock`:
-            ;; see <https://github.com/racket/racket/issues/3851>.
-            ;; As a workaround, remove the directory.
-            (lambda args
-              ;; rmdir because we want an error if it isn't empty
-              (rmdir (string-append #$output "/share/racket/pkgs")))))))
-    (home-page "https://racket-lang.org")
+     (substitute-keyword-arguments (package-arguments racket-minimal-bc-3m)
+       ((#:phases bc-phases)
+        #~(modify-phases #$bc-phases
+            (add-after 'unpack 'unpack-nanopass+stex
+              (lambda args
+                (with-directory-excursion "racket/src/ChezScheme"
+                  #$(make-unpack-nanopass+stex))))
+            (add-after 'unpack-nanopass+stex 'unpack-bootfiles
+              (lambda* (#:key native-inputs inputs #:allow-other-keys)
+                (with-directory-excursion "racket/src/ChezScheme"
+                  (copy-recursively
+                   (search-input-directory (or native-inputs inputs)
+                                           "lib/chez-scheme-bootfiles")
+                   "boot"))))))
+       ((#:configure-flags _ '())
+        #~(cons* "--enable-csonly"
+                 "--enable-libz"
+                 "--enable-lz4"
+                 #$(racket-vm-common-configure-flags)))))
     (synopsis "Racket without bundled packages such as DrRacket")
     (description
      "Racket is a general-purpose programming language in the Scheme family,
@@ -275,69 +333,11 @@  (define maybe-release-catalog
 The ``minimal Racket'' distribution includes just enough of Racket for you to
 use @command{raco pkg} to install more.  Bundled packages, such as the
 DrRacket IDE, are not included.")
+    (properties `())
     ;; https://download.racket-lang.org/license.html
     ;; The LGPL components are only used by Racket BC.
     (license (list license:asl2.0 license:expat))))
 
-(define-public racket-minimal-bc-3m
-  (hidden-package
-   (package
-     (inherit racket-minimal)
-     (name "racket-minimal-bc-3m")
-     (inputs
-      (modify-inputs (package-inputs racket-minimal)
-        (prepend libffi) ;; <- only for BC variants
-        (delete "zlib" "lz4")))
-     (native-inputs
-      (list libtool
-            (if (%current-target-system)
-                racket-minimal
-                racket-minimal-bc-cgc)))
-     (arguments
-      (substitute-keyword-arguments (package-arguments racket-minimal)
-        ((#:configure-flags _ '())
-         #~(cons "--enable-bconly"
-                 #$(racket-vm-common-configure-flags)))
-        ((#:phases cs-phases)
-         #~(modify-phases #$cs-phases
-             (delete 'unpack-nanopass+stex)
-             (delete 'unpack-bootfiles)))))
-     (synopsis "Minimal Racket with the BC [3M] runtime system")
-     (description "The Racket BC (``before Chez'' or ``bytecode'')
-implementation was the default before Racket 8.0.  It uses a compiler written
-in C targeting architecture-independent bytecode, plus a JIT compiler on most
-platforms.  Racket BC has a different C API and supports a slightly different
-set of architectures than the current default runtime system, Racket CS (based
-on ``Chez Scheme'').
-
-This package is the normal implementation of Racket BC with a precise garbage
-collector, 3M (``Moving Memory Manager'').")
-     ;; https://download.racket-lang.org/license.html
-     ;; The LGPL components are only used by Racket BC.
-     (license (list license:lgpl3+ license:asl2.0 license:expat)))))
-
-(define-public racket-minimal-bc-cgc
-  (package
-    (inherit racket-minimal-bc-3m)
-    (name "racket-minimal-bc-cgc")
-    (native-inputs (list libtool))
-    (arguments
-     (substitute-keyword-arguments (package-arguments racket-minimal-bc-3m)
-       ((#:configure-flags _ '())
-        #~(cons "--enable-cgcdefault"
-                #$(racket-vm-common-configure-flags)))))
-    (synopsis "Old Racket implementation used for bootstrapping")
-    (description "This variant of the Racket BC (``before Chez'' or
-``bytecode'') implementation is not recommended for general use.  It uses
-CGC (a ``Conservative Garbage Collector''), which was succeeded as default in
-PLT Scheme version 370 (which translates to 3.7 in the current versioning
-scheme) by the 3M variant, which in turn was succeeded in version 8.0 by the
-Racket CS implementation.
-
-Racket BC [CGC] is primarily used for bootstrapping Racket BC [3M].  It may
-also be used for embedding applications without the annotations needed in C
-code to use the 3M garbage collector.")))
-
 (define-public chez-scheme-for-racket-bootstrap-bootfiles
   (package
     (name "chez-scheme-for-racket-bootstrap-bootfiles")