diff mbox series

[bug#70065,4/6] gnu: chez-scheme: Update to 10.0.0.

Message ID dfda42863f9d5d7128025f87ac423971d6158a2c.1711688274.git.philip@philipmcgrath.com
State New
Headers show
Series gnu: Update to Racket 8.12, Chez Scheme 10, and Zuo 1.9. | expand

Commit Message

Philip McGrath March 29, 2024, 5:18 a.m. UTC
* gnu/packages/patches/chez-scheme-bin-sh.patch: Refresh patch.
* gnu/packages/patches/chez-scheme-backport-configure.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/chez.scm (chez-scheme): Update to 10.0.0.  Inherit from
'chez-scheme-for-racket'.
[source]<patches>: Use "chez-scheme-backport-configure.patch".
<snippet>: Also unbundle Zuo.
[native-inputs, native-search-paths, outputs, arguments]
[supported-systems]: Inherit from 'chez-scheme-for-racket'.
[inputs]: Likewise, replacing the bootfile package and adding libx11.
[description]: Update based on the User's Guide, release notes, man
page, and README file.
(chez-scheme-bootstrap-bootfiles)[supported-systems]: All systems are
now supported.
(chez-scheme-for-system): Deprecate it, since 'chez-scheme' now supports
all systems.
(chez-srfi, chez-web, chez-sockets, chez-matchable, chez-irregex)
(chez-fmt, chez-mit, chez-scmutils)[native-inputs]: Use 'chez-scheme'
instead of 'chez-scheme-for-system'.
* gnu/packages/emacs-xyz.scm (emacs-geiser-chez)[inputs]: Likewise.

Change-Id: I287ff66f385f20e69c1411abcc94f19dd45870c5
---
 gnu/local.mk                                  |   1 +
 gnu/packages/chez.scm                         | 222 ++-------
 gnu/packages/emacs-xyz.scm                    |   2 +-
 .../chez-scheme-backport-configure.patch      | 463 ++++++++++++++++++
 gnu/packages/patches/chez-scheme-bin-sh.patch |  37 +-
 5 files changed, 522 insertions(+), 203 deletions(-)
 create mode 100644 gnu/packages/patches/chez-scheme-backport-configure.patch

Comments

Liliana Marie Prikler March 30, 2024, 7:56 a.m. UTC | #1
Am Freitag, dem 29.03.2024 um 01:18 -0400 schrieb Philip McGrath:
> * gnu/packages/patches/chez-scheme-bin-sh.patch: Refresh patch.
> * gnu/packages/patches/chez-scheme-backport-configure.patch: New
> file.
> * gnu/local.mk (dist_patch_DATA): Add it.
> * gnu/packages/chez.scm (chez-scheme): Update to 10.0.0.  Inherit
> from
> 'chez-scheme-for-racket'.
Is there a good reason to do it this way?  Or could we build racket
with regular chez-scheme afterwards?

> [source]<patches>: Use "chez-scheme-backport-configure.patch".
> <snippet>: Also unbundle Zuo.
> [native-inputs, native-search-paths, outputs, arguments]
> [supported-systems]: Inherit from 'chez-scheme-for-racket'.
> [inputs]: Likewise, replacing the bootfile package and adding libx11.
> [description]: Update based on the User's Guide, release notes, man
> page, and README file.
> (chez-scheme-bootstrap-bootfiles)[supported-systems]: All systems are
> now supported.
> (chez-scheme-for-system): Deprecate it, since 'chez-scheme' now
> supports
> all systems.
> (chez-srfi, chez-web, chez-sockets, chez-matchable, chez-irregex)
> (chez-fmt, chez-mit, chez-scmutils)[native-inputs]: Use 'chez-scheme'
> instead of 'chez-scheme-for-system'.
> * gnu/packages/emacs-xyz.scm (emacs-geiser-chez)[inputs]: Likewise.
> 
> Change-Id: I287ff66f385f20e69c1411abcc94f19dd45870c5
I think I got pinged for this due to the emacs side, which as far as I
can see LGTM.  I haven't looked at all of the patch however, let alone
the series.

As usual for these large rackets (pun intended), I do wonder whether
it'd be possible to split the commits into more reviewable hunks.  For
instance, I don't think chez-scheme-for-system would need to be
adjusted yet – it could simply return chez-scheme and then in the next
commit be deprecated or dropped.

Cheers
Skyler Ferris March 30, 2024, 2:39 p.m. UTC | #2
On 3/28/24 22:18, Philip McGrath wrote:
> -(define* (chez-scheme-for-system #:optional
> -                                 (system (or (%current-target-system)
> -                                             (%current-system))))
> -  "Return 'chez-scheme' if it fully supports SYSTEM, including support for
> -bootstrapping and native threads.  Otherwise, return
> -'chez-scheme-for-racket'."
> -  (if (and=> (chez-upstream-features-for-system system)
> -             (lambda (features)
> -               (every (cut memq <> features)
> -                      '(threads
> -                        ;; We can cross-compile for platforms without
> -                        ;; bootstrap bootfiles, but we can't self-host
> -                        ;; on them short of adding more binary seeds.
> -                        bootstrap-bootfiles))))
> -      chez-scheme
> -      chez-scheme-for-racket))
> +(define-deprecated (chez-scheme-for-system #:optional system) chez-scheme
> +  "Returns 'chez-scheme'."
> +  chez-scheme)
As mentioned in the reply to the cover letter, it looks like this broke 
loko-scheme from gnu/pcakages/loko.scm.

In particular, I get a "wrong type to apply" error in its use of 
"chez-scheme-for-system". I ran into this problem when running the 
following command:

```
./pre-inst-env guix refresh --list-depedent zuo -e '(@ (gnu packages 
racket) racket-vm-cs)' racket chez-scheme chez-scheme-for-racket
```

For this reason, I was also unable to verify that all dependents 
build... presumably, the CI will run into the same error when this 
patch's turn comes up. I did check the following packages based on the 
output of the refresh without this patch applied, and they all build 
with all patches in this series applied:

```
./pre-inst-env guix build chez-socket chez-nanopass chez-fmt 
chez-scmutils chez-irregex emacs-geiser-chez emacs-geiser-racket
```

So I think loko-scheme is the only impacted dependent. Pending 
cross-builds from the CI.

As before, my experience with autotools is limited so my review of the 
build changes should be taken with a grain of salt. It looks like some 
of the patched code is fixing bugs rather than adapting for guix so they 
should be upstreamed, but I assume Philip is already on top of that.
Philip McGrath March 30, 2024, 10:49 p.m. UTC | #3
Hi Liliana and Skyler,

On 3/30/24 10:28, Skyler Ferris wrote:
 >
 >> Is there a good reason to do it this way?  Or could we build racket
 >> with regular chez-scheme afterwards?
 >
 > I believe this is addressed by this comment from patch 6/6; we can't
 > rely on chez-scheme being the correct version to use for racket. But
 > please correct me if I misunderstood Philip!
 >
 >> Since the pre-releases for Chez Scheme 10.0.0, all of Racket's 
changes have
 >> been merged upstream, and development will be kept in sync going
 >> forward. However, there is no plan to align the Chez Scheme and Racket
 >> release cycles. For the near fulture, a given released version of Racket
 >> will continue to depend on a specific pre-release version of Chez 
Scheme as
 >> part of Racket CS's "ABI". See upstream discussion at
 >> <https://racket.discourse.group/t/2739/3>.
 >

That's right. In the linked thread, Matthew Flatt specifically confirmed 
that we should not try to build Racket with our chez-scheme package.

On 3/30/24 10:39, Skyler Ferris wrote:
> On 3/28/24 22:18, Philip McGrath wrote:
>> -(define* (chez-scheme-for-system #:optional
>> -                                 (system (or (%current-target-system)
>> -                                             (%current-system))))
>> -  "Return 'chez-scheme' if it fully supports SYSTEM, including support for
>> -bootstrapping and native threads.  Otherwise, return
>> -'chez-scheme-for-racket'."
>> -  (if (and=> (chez-upstream-features-for-system system)
>> -             (lambda (features)
>> -               (every (cut memq <> features)
>> -                      '(threads
>> -                        ;; We can cross-compile for platforms without
>> -                        ;; bootstrap bootfiles, but we can't self-host
>> -                        ;; on them short of adding more binary seeds.
>> -                        bootstrap-bootfiles))))
>> -      chez-scheme
>> -      chez-scheme-for-racket))
>> +(define-deprecated (chez-scheme-for-system #:optional system) chez-scheme
>> +  "Returns 'chez-scheme'."
>> +  chez-scheme)
> As mentioned in the reply to the cover letter, it looks like this broke
> loko-scheme from gnu/pcakages/loko.scm.
> 
> In particular, I get a "wrong type to apply" error in its use of
> "chez-scheme-for-system". I ran into this problem when running the
> following command:
> 
> ```
> ./pre-inst-env guix refresh --list-depedent zuo -e '(@ (gnu packages
> racket) racket-vm-cs)' racket chez-scheme chez-scheme-for-racket
> ```
> 

Thanks, I had forgotten about loko-scheme!

On 3/30/24 10:28, Skyler Ferris wrote:
 > (I think the deprecation definition might need an
 > update, because IIUC the syntax is supposed to be backwards-compatible
 > until it is removed).
 >

I still don't understand why the deprecation definition isn't working. I 
expected the expansion at the repl, and (chez-scheme-for-system) 
expanded to (%chez-scheme-for-system/deprecated), which was defined by 
the expansion of define-deprecated as:

   (define %chez-scheme-for-system/deprecated
     (begin
       (lambda () chez-scheme)
       (lambda* (#:optional (system #f)) chez-scheme)))

I guess, unless I figure something out or someone has a better 
suggestion, I could just remove chez-scheme-for-system without 
deprecation, but that seemed less friendly.

> 
> As before, my experience with autotools is limited so my review of the
> build changes should be taken with a grain of salt. It looks like some
> of the patched code is fixing bugs rather than adapting for guix so they
> should be upstreamed, but I assume Philip is already on top of that.
> 

Chez Scheme actually doesn't use autotools. (Racket does use autoconf, 
only.) All of the patches for configure have already been accepted 
upstream: in fact, the second patch in the file is a follow-up from 
Matthew Flatt, one of the maintainers of Racket and, more recently, Chez 
Scheme.

On 3/30/24 03:56, Liliana Marie Prikler wrote:
 > As usual for these large rackets (pun intended), I do wonder whether
 > it'd be possible to split the commits into more reviewable hunks.  For
 > instance, I don't think chez-scheme-for-system would need to be
 > adjusted yet – it could simply return chez-scheme and then in the next
 > commit be deprecated or dropped.

Since there's a problem with the deprecation anyway, I will split this 
out. Overall, dividing up this series as much as I did has been 
especially arduous. If you noticed that the authored dates on the 
patches are a month ago, that's mostly the time it took me to reorganize 
these commits.

Thanks,
Philip
Skyler Ferris March 31, 2024, 2:35 p.m. UTC | #4
On 3/30/24 15:49, Philip McGrath wrote:
> I still don't understand why the deprecation definition isn't working. I
> expected the expansion at the repl, and (chez-scheme-for-system)
> expanded to (%chez-scheme-for-system/deprecated), which was defined by
> the expansion of define-deprecated as:
>
>     (define %chez-scheme-for-system/deprecated
>       (begin
>         (lambda () chez-scheme)
>         (lambda* (#:optional (system #f)) chez-scheme)))
>
> I guess, unless I figure something out or someone has a better
> suggestion, I could just remove chez-scheme-for-system without
> deprecation, but that seemed less friendly.

So, I started poking at this and ran into something strange. I removed 
the surrounding parentheses from chez-scheme-for-system in loko.scm, and 
it gave me the expected error about an invalid package, where the value 
was a procedure rather than a package. Which sounds like what I would 
expect if it was working, except that it didn't work with the 
parentheses. Then, after adding the parentheses back it stopped giving 
me the error, even after running make again.

I haven't worked with define-deprecated before. It's a macro, and I know 
that the guile compiler misses recompiling macro dependencies sometimes, 
so maybe it was a problem on my end with having mismatching build 
artifacts. I'll try a clean build with these patches and a simulated 
guix pull within the next couple of days (hopefully today), and if those 
both work then the definition is probably correct.... but I'd be more 
comfortable if we could explain exactly why that error occurred. I'll 
also look more at the definitions, but I think it will be a little 
difficult to be confident in any explanation if I can't reproduce the 
error. Here's the full error output, in case it's helpful to anyone:

Backtrace:
In ice-9/boot-9.scm:
   1752:10 19 (with-exception-handler _ _ #:unwind? _ # _)
In guix/ui.scm:
     485:6 18 (_)
In guix/scripts/build.scm:
     711:5 17 (_)
In srfi/srfi-1.scm:
    673:15 16 (append-map #<procedure 7fef052ecdc0 at guix/scripts/b…> …)
    586:17 15 (map1 ("x86_64-linux"))
In guix/scripts/build.scm:
    713:21 14 (_ _)
In guix/store.scm:
   1382:11 13 (map/accumulate-builds #<store-connection 256.100 7fef…> …)
    1300:8 12 (call-with-build-handler #<procedure 7fef06f90990 at g…> …)
In guix/scripts/build.scm:
    667:16 11 (_ #<package loko-scheme@0.12.0 gnu/packages/loko.scm:3…>)
    656:24 10 (_ #<package loko-scheme@0.12.0 gnu/packages/loko.scm:…> …)
In guix/packages.scm:
   1378:17  9 (supported-package? #<package loko-scheme@0.12.0 gnu/p…> …)
In guix/memoization.scm:
     101:0  8 (_ #<hash-table 7fef036b2120 0/31> #<package loko-sche…> …)
In guix/packages.scm:
   1356:39  7 (_)
   1618:16  6 (package->bag _ _ _ #:graft? _)
   1722:47  5 (thunk)
In gnu/packages/loko.scm:
     77:11  4 (native-inputs #<package loko-scheme@0.12.0 gnu/package…>)
     77:11  3 (native-inputs _)
In ice-9/boot-9.scm:
   1685:16  2 (raise-exception _ #:continuable? _)
   1685:16  1 (raise-exception _ #:continuable? _)
   1685:16  0 (raise-exception _ #:continuable? _)

ice-9/boot-9.scm:1685:16: In procedure raise-exception:
Wrong type to apply: #<syntax-transformer chez-scheme-for-system>
Skyler Ferris March 31, 2024, 3:28 p.m. UTC | #5
Hi again! I stepped away from my desk to do something else and as often 
happens the answer came to me. I'll include full steps to reproduce the 
issue below, in order to build confidence in my explanation, but the 
TLDR is that your definition is correct and it was a problem on my end. 
Additionally, I confirmed that loko-scheme still builds and runs. I'll 
keep this situation in mind for future reviews. Thank you for all your 
hard work!

Explanation:

The loko.scm file was not recompiled so it searched chez.scm for a 
variable named chez-scheme-for-system, which is now a syntax 
transformer. But compiled files have already completed the expansion 
phase, so this means that a syntax transformer is invalid. This will not 
cause a problem for `guix pull` because guix rebuilds itself from 
scratch when it gets updated.

Reproduction:

1. Build the tree without patch 4/6 applied
    `guix shell -D guix -CPW -- make`
2. Apply the patch
    `git apply /path/to/patch`
3. Build the tree again
    `guix shell -D guix -CPW -- make`
4. Try to build loko-scheme
    `./pre-inst-env guix build loko-scheme`
5. Delete the compiled loko file
    `rm gnu/packages/loko.go`
6. Build the tree again
    `guix shell -D guix -CPW -- make`
7. Build loko-scheme
    `./pre-inst-env guix build loko-scheme`

On 3/31/24 07:35, Skyler Ferris wrote:
> On 3/30/24 15:49, Philip McGrath wrote:
>> I still don't understand why the deprecation definition isn't working. I
>> expected the expansion at the repl, and (chez-scheme-for-system)
>> expanded to (%chez-scheme-for-system/deprecated), which was defined by
>> the expansion of define-deprecated as:
>>
>>     (define %chez-scheme-for-system/deprecated
>>       (begin
>>         (lambda () chez-scheme)
>>         (lambda* (#:optional (system #f)) chez-scheme)))
>>
>> I guess, unless I figure something out or someone has a better
>> suggestion, I could just remove chez-scheme-for-system without
>> deprecation, but that seemed less friendly.
>
> So, I started poking at this and ran into something strange. I removed 
> the surrounding parentheses from chez-scheme-for-system in loko.scm, 
> and it gave me the expected error about an invalid package, where the 
> value was a procedure rather than a package. Which sounds like what I 
> would expect if it was working, except that it didn't work with the 
> parentheses. Then, after adding the parentheses back it stopped giving 
> me the error, even after running make again.
>
> I haven't worked with define-deprecated before. It's a macro, and I 
> know that the guile compiler misses recompiling macro dependencies 
> sometimes, so maybe it was a problem on my end with having mismatching 
> build artifacts. I'll try a clean build with these patches and a 
> simulated guix pull within the next couple of days (hopefully today), 
> and if those both work then the definition is probably correct.... but 
> I'd be more comfortable if we could explain exactly why that error 
> occurred. I'll also look more at the definitions, but I think it will 
> be a little difficult to be confident in any explanation if I can't 
> reproduce the error. Here's the full error output, in case it's 
> helpful to anyone:
>
> Backtrace:
> In ice-9/boot-9.scm:
>   1752:10 19 (with-exception-handler _ _ #:unwind? _ # _)
> In guix/ui.scm:
>     485:6 18 (_)
> In guix/scripts/build.scm:
>     711:5 17 (_)
> In srfi/srfi-1.scm:
>    673:15 16 (append-map #<procedure 7fef052ecdc0 at guix/scripts/b…> …)
>    586:17 15 (map1 ("x86_64-linux"))
> In guix/scripts/build.scm:
>    713:21 14 (_ _)
> In guix/store.scm:
>   1382:11 13 (map/accumulate-builds #<store-connection 256.100 7fef…> …)
>    1300:8 12 (call-with-build-handler #<procedure 7fef06f90990 at g…> …)
> In guix/scripts/build.scm:
>    667:16 11 (_ #<package loko-scheme@0.12.0 gnu/packages/loko.scm:3…>)
>    656:24 10 (_ #<package loko-scheme@0.12.0 gnu/packages/loko.scm:…> …)
> In guix/packages.scm:
>   1378:17  9 (supported-package? #<package loko-scheme@0.12.0 gnu/p…> …)
> In guix/memoization.scm:
>     101:0  8 (_ #<hash-table 7fef036b2120 0/31> #<package loko-sche…> …)
> In guix/packages.scm:
>   1356:39  7 (_)
>   1618:16  6 (package->bag _ _ _ #:graft? _)
>   1722:47  5 (thunk)
> In gnu/packages/loko.scm:
>     77:11  4 (native-inputs #<package loko-scheme@0.12.0 gnu/package…>)
>     77:11  3 (native-inputs _)
> In ice-9/boot-9.scm:
>   1685:16  2 (raise-exception _ #:continuable? _)
>   1685:16  1 (raise-exception _ #:continuable? _)
>   1685:16  0 (raise-exception _ #:continuable? _)
>
> ice-9/boot-9.scm:1685:16: In procedure raise-exception:
> Wrong type to apply: #<syntax-transformer chez-scheme-for-system>
>
Philip McGrath March 31, 2024, 8:17 p.m. UTC | #6
Hi Skyler,

On 3/31/24 11:28, Skyler Ferris wrote:
> Hi again! I stepped away from my desk to do something else and as often
> happens the answer came to me.

Thanks for this analysis!

> 
> The loko.scm file was not recompiled so it searched chez.scm for a
> variable named chez-scheme-for-system, which is now a syntax
> transformer. But compiled files have already completed the expansion
> phase, so this means that a syntax transformer is invalid. This will not
> cause a problem for `guix pull` because guix rebuilds itself from
> scratch when it gets updated.
> 


On 3/31/24 10:35, Skyler Ferris wrote:
 > I haven't worked with define-deprecated before. It's a macro, and I know
 > that the guile compiler misses recompiling macro dependencies sometimes,
 > so maybe it was a problem on my end with having mismatching build
 > artifacts.

Very interesting! I hadn't realized that problem with dependency 
tracking existed: it might explain some issues I've struggled to 
reproduce in the past. It's also given me several surprises about 
Guile's implementation of phases: for one thing, apparently 
(define-syntax x 42) expands to (define x (make-syntax-transformer 'x 
'macro 42)). I wouldn't have expected a macro to create a value that 
would exist at runtime.

Philip
Skyler Ferris April 2, 2024, 2:55 p.m. UTC | #7
On 3/31/24 13:17, Philip McGrath wrote:
>> The loko.scm file was not recompiled so it searched chez.scm for a
>> variable named chez-scheme-for-system, which is now a syntax
>> transformer. But compiled files have already completed the expansion
>> phase, so this means that a syntax transformer is invalid. This will not
>> cause a problem for `guix pull` because guix rebuilds itself from
>> scratch when it gets updated.
>>
>
> On 3/31/24 10:35, Skyler Ferris wrote:
>   > I haven't worked with define-deprecated before. It's a macro, and I know
>   > that the guile compiler misses recompiling macro dependencies sometimes,
>   > so maybe it was a problem on my end with having mismatching build
>   > artifacts.
>
> Very interesting! I hadn't realized that problem with dependency
> tracking existed: it might explain some issues I've struggled to
> reproduce in the past. It's also given me several surprises about
> Guile's implementation of phases: for one thing, apparently
> (define-syntax x 42) expands to (define x (make-syntax-transformer 'x
> 'macro 42)). I wouldn't have expected a macro to create a value that
> would exist at runtime.
Exists yes, but it (should not be) used/referenced at runtime. I'm going 
to type some more details in case you are interested, but an important 
disclaimer is that my understanding comes from reading documentation on 
an as-needed basis and doing some work writing macros, but not a lot. I 
haven't worked with the code that actually implements these things.

I'm not sure how other schemes implement this, but Guile has a clearly 
defined separation between "compile time" and "load time". Compilation 
is when syntax transformers are used to modify source expressions into 
the expanded form (in addition to other things, like lowering to 
intermediate representations). This is discussed in the documentation 
for eval-when (1). If I define that macro and then use it within the 
same file, the place where it is used will not contain a reference to 
the syntax transformer: it will already be expanded. If I write a new 
file tomorrow which wants to use that macro, Guile will reference the 
compiled version of the module. If the syntax transformer was not 
present in the compiled module then the new file would break. Instead, 
the syntax transformer still exists in the compiled version of the file 
so that the new module can load it at expansion time. But again, once 
the new file is compiled the reference to the macro will disappear. So 
it exists at runtime, but it is only used when compiling code. For 
compiled files, it is not used at runtime. The exception is that when 
code is evaluated at the REPL, or if auto-compilation is disabled, there 
is no practical difference between compile time and load time.

I'm not entirely sure why the compiler doesn't see the dependency here. 
The section on compilation (2) says "Guile does not yet do proper 
dependency tracking" so I assume that it just hasn't been high priority 
enough for anyone to fix it. There would be trade-offs in some cases. In 
this case it is pretty easy to see that the file needs to be recompiled 
because loko.go (the compiled version of the file) contains an explicit 
reference to the macro, because it used to be a procedure. But if it was 
a macro both before and after the change the reference would not be 
there. We could add the list of macros used during compilation as 
metadata to the file but I don't know how much bloat that would cause. 
We could also reference the use-module forms in the original source, but 
I'm not sure if those are typically available in the go files or if that 
would also need to be tracked as additional metadata.

(1) https://www.gnu.org/software/guile/manual/html_node/Eval-When.html
(2) https://www.gnu.org/software/guile/manual/html_node/Compilation.html
Ludovic Courtès April 11, 2024, 10:55 a.m. UTC | #8
Hello,

Philip McGrath <philip@philipmcgrath.com> skribis:

> Here is v2!
>
> In the second patch, I tweaked the comments based on discussion with Skyler.
>
> To be extra careful about the deprecation of chez-scheme-for-system, I split
> the former [4/6] into:
>
>   * [v2 4/8], which just changes the return value;
>   * [v2 5/8], which changes to define-deprecated; and
>   * [v2 6/8], which updates the uses.
>
> I checked after that all the dependents built and that deprecation warnings
> were shown after [v2 5/8] (and not anywhere else!).

I went ahead and applied v2.  Thank you and thanks to Liliana and Skyler
for reviewing!

Ludo’.
diff mbox series

Patch

diff --git a/gnu/local.mk b/gnu/local.mk
index a10aa2cefd..b5f922b538 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1017,6 +1017,7 @@  dist_patch_DATA =						\
   %D%/packages/patches/ccextractor-add-missing-header.patch	\
   %D%/packages/patches/ccextractor-autoconf-tesseract.patch	\
   %D%/packages/patches/ccextractor-fix-ocr.patch		\
+  %D%/packages/patches/chez-scheme-backport-configure.patch	\
   %D%/packages/patches/chez-scheme-bin-sh.patch			\
   %D%/packages/patches/circos-remove-findbin.patch		\
   %D%/packages/patches/cdparanoia-fpic.patch			\
diff --git a/gnu/packages/chez.scm b/gnu/packages/chez.scm
index 3b7e6a67b3..406180ce0f 100644
--- a/gnu/packages/chez.scm
+++ b/gnu/packages/chez.scm
@@ -27,6 +27,7 @@  (define-module (gnu packages chez)
                 #:select (gpl2+ gpl3+ lgpl2.0+ lgpl2.1+ asl2.0 bsd-3 expat
                           public-domain))
   #:use-module (guix packages)
+  #:use-module (guix deprecation)
   #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module (guix utils)
@@ -68,22 +69,9 @@  (define-module (gnu packages chez)
 ;;
 ;; Code:
 
-(define* (chez-scheme-for-system #:optional
-                                 (system (or (%current-target-system)
-                                             (%current-system))))
-  "Return 'chez-scheme' if it fully supports SYSTEM, including support for
-bootstrapping and native threads.  Otherwise, return
-'chez-scheme-for-racket'."
-  (if (and=> (chez-upstream-features-for-system system)
-             (lambda (features)
-               (every (cut memq <> features)
-                      '(threads
-                        ;; We can cross-compile for platforms without
-                        ;; bootstrap bootfiles, but we can't self-host
-                        ;; on them short of adding more binary seeds.
-                        bootstrap-bootfiles))))
-      chez-scheme
-      chez-scheme-for-racket))
+(define-deprecated (chez-scheme-for-system #:optional system) chez-scheme
+  "Returns 'chez-scheme'."
+  chez-scheme)
 
 (define* (target-chez-arch #:optional (system
                                        (or (%current-target-system)
@@ -503,10 +491,11 @@  (define-public chez-scheme-for-racket
 
 (define-public chez-scheme
   (package
+    (inherit chez-scheme-for-racket)
     (name "chez-scheme")
-    ;; The version should match `(scheme-version-number)`.
+    ;; The version should match `(scheme-version-number #t)`.
     ;; See s/cmacros.ss c. line 360.
-    (version "9.5.8")
+    (version "10.0.0")
     (source (origin
               (method git-fetch)
               (uri (git-reference
@@ -514,9 +503,10 @@  (define-public chez-scheme
                     (commit (string-append "v" version))))
               (sha256
                (base32
-                "0xchqq8cm0ka5wgpn18sjs0hh15rc3nb7xrjqbbc9al3asq0d7gc"))
+                "1q66vafhiwk617z51qkm1v64r3bxqhhf5lzrmsa4l9d5yhvlyk09"))
               (file-name (git-file-name name version))
-              (patches (search-patches "chez-scheme-bin-sh.patch"))
+              (patches (search-patches "chez-scheme-backport-configure.patch"
+                                       "chez-scheme-bin-sh.patch"))
               (snippet #~(begin
                            (use-modules (guix build utils))
                            ;; TODO: consider putting this in a (guix ...) or
@@ -525,165 +515,30 @@  (define-public chez-scheme
                            (for-each (lambda (dir)
                                        (when (directory-exists? dir)
                                          (delete-file-recursively dir)))
-                                     '("stex"
+                                     '("lz4"
                                        "nanopass"
-                                       "lz4"
-                                       "zlib"))))))
+                                       "stex"
+                                       "zlib"
+                                       "zuo"))))))
     (build-system gnu-build-system)
     (inputs
-     (list
-      chez-scheme-bootstrap-bootfiles
-      `(,util-linux "lib") ;<-- libuuid
-      zlib
-      lz4
-      ncurses ;<-- for expeditor
-      ;; for X11 clipboard support in expeditor:
-      ;; https://github.com/cisco/ChezScheme/issues/9#issuecomment-222057232
-      libx11))
-    (native-inputs (list chez-nanopass-bootstrap
-                         stex-bootstrap))
-    (native-search-paths
-     (list (search-path-specification
-            (variable "CHEZSCHEMELIBDIRS")
-            (files '("lib/chez-scheme")))))
-    (outputs '("out" "doc"))
-    (arguments
-     (list
-      #:modules
-      '((guix build gnu-build-system)
-        (guix build utils)
-        (ice-9 ftw)
-        (ice-9 match))
-      #:test-target "test"
-      #:configure-flags
-      #~`(,(string-append "--installprefix=" #$output)
-          #$@(if (and=> (chez-upstream-features-for-system)
-                        (cut memq 'threads <>))
-                 #~("--threads")
-                 #~())
-          "ZLIB=-lz"
-          "LZ4=-llz4"
-          "--libkernel"
-          ;; Guix will do 'compress-man-pages',
-          ;; and letting Chez try causes an error
-          "--nogzip-man-pages")
-      #:phases
-      #~(modify-phases %standard-phases
-          (add-after 'unpack 'unpack-nanopass+stex
-            (lambda args
-              (begin
-                (copy-recursively
-                 (dirname (search-input-file %build-inputs
-                                             "lib/chez-scheme/nanopass.ss"))
-                 "nanopass"
-                 #:keep-mtime? #t)
-                (mkdir-p "stex")
-                (with-output-to-file "stex/Mf-stex"
-                  (lambda ()
-                    ;; otherwise, it will try to download submodules
-                    (display "# to placate ../configure"))))))
-          (add-after 'unpack-nanopass+stex 'unpack-bootfiles
-            (lambda* (#:key native-inputs inputs #:allow-other-keys)
-              (when (directory-exists? "boot")
-                (delete-file-recursively "boot"))
-              (copy-recursively
-               (search-input-directory inputs
-                                       "lib/chez-scheme-bootfiles")
-               "boot")))
-          ;; NOTE: The custom Chez 'configure' script doesn't allow
-          ;; unrecognized flags, such as those automatically added
-          ;; by `gnu-build-system`. This replacement phase uses only
-          ;; the explicitly provided `#:configure-flags`.
-          (replace 'configure
-            (lambda* (#:key inputs (configure-flags '()) out-of-source?
-                            #:allow-other-keys)
-              (let* ((abs-srcdir (getcwd))
-                     (srcdir (if out-of-source?
-                                 (string-append "../" (basename abs-srcdir))
-                                 ".")))
-                (format #t "source directory: ~s (relative from build: ~s)~%"
-                        abs-srcdir srcdir)
-                (if out-of-source?
-                    (begin
-                      (mkdir "../build")
-                      (chdir "../build")))
-                (format #t "build directory: ~s~%" (getcwd))
-                (format #t "configure flags: ~s~%" configure-flags)
-                (apply invoke
-                       (string-append srcdir "/configure")
-                       configure-flags))))
-          (add-after 'configure 'configure-environment-variables
-            (lambda args
-              ;; Some makefiles (for tests) don't seem to propagate CC
-              ;; properly, so we take it out of their hands:
-              (setenv "CC" #$(cc-for-target))
-              ;; Likewise, some tests have needed HOME to be set:
-              (setenv "HOME" "/tmp")))
-          ;; The binary file name is called "scheme" as is the one from
-          ;; MIT/GNU Scheme.  We add a symlink to use in case both are
-          ;; installed.
-          (add-after 'install 'install-symlink
-            (lambda* (#:key outputs #:allow-other-keys)
-              (let* ((scheme (search-input-file outputs "/bin/scheme"))
-                     (bin-dir (dirname scheme)))
-                (symlink scheme
-                         (string-append bin-dir "/chez-scheme"))
-                (match (find-files (string-append bin-dir "/../lib")
-                                   "scheme.boot")
-                  ((scheme.boot)
-                   (symlink scheme.boot
-                            (string-append (dirname scheme.boot)
-                                           "/chez-scheme.boot")))))))
-          ;; Building the documentation requires stex and a running scheme.
-          (add-after 'install-symlink 'install-docs
-            (lambda* (#:key native-inputs inputs outputs #:allow-other-keys)
-              (let* ((doc-prefix (or (assoc-ref outputs "doc")
-                                     (assoc-ref outputs "out")))
-                     (chez+version (strip-store-file-name #$output))
-                     (scheme (search-input-file outputs "/bin/scheme"))
-                     (stexlib (search-input-directory (or native-inputs
-                                                          inputs)
-                                                      "/lib/stex"))
-                     (doc-dir (string-append doc-prefix
-                                             "/share/doc/"
-                                             chez+version)))
-                (define* (stex-make #:optional (suffix ""))
-                  (invoke "make" "install"
-                          (string-append "Scheme=" scheme)
-                          (string-append "STEXLIB=" stexlib)
-                          (string-append "installdir=" doc-dir suffix)))
-                (with-directory-excursion "csug"
-                  (stex-make "/csug"))
-                (with-directory-excursion "release_notes"
-                  (stex-make "/release_notes")))))
-          (add-after 'install-docs 'link-doc-pdfs
-            ;; otherwise, it's hard to notice them in a forest of HTML files
-            (lambda* (#:key outputs #:allow-other-keys)
-              (with-directory-excursion
-                  (string-append (or (assoc-ref outputs "doc")
-                                     (assoc-ref outputs "out"))
-                                 "/share/doc/"
-                                 (strip-store-file-name #$output))
-                (symlink "release_notes/release_notes.pdf"
-                         "release_notes.pdf")
-                (match (find-files "csug"
-                                   "csug.*\\.pdf$" ;; embeded version number
-                                   #:fail-on-error? #t)
-                  ((pth)
-                   (symlink pth
-                            "csug.pdf")))))))))
-    (supported-systems
-     (delete
-      "armhf-linux" ;; XXX reportedly broken, needs checking
-      (filter chez-upstream-features-for-system
-              %supported-systems)))
+     (modify-inputs (package-inputs chez-scheme-for-racket)
+       (replace "chez-scheme-for-racket-bootstrap-bootfiles"
+         chez-scheme-bootstrap-bootfiles)
+       ;; for X11 clipboard support in expeditor:
+       ;; https://github.com/cisco/ChezScheme/issues/9#issuecomment-222057232
+       (prepend libx11)))
+    ;; replace unpack phase?
     (home-page "https://cisco.github.io/ChezScheme/")
     (synopsis "R6RS Scheme compiler and run-time")
     (description
-     "Chez Scheme is a compiler and run-time system for the language of the
-Revised^6 Report on Scheme (R6RS), with numerous extensions.  The compiler
-generates native code for each target processor, with support for x86, x86_64,
-and 32-bit PowerPC architectures.")
+     "Chez Scheme is both a programming language and a high-performance
+implementation of that language. The language is a superset of R6RS Scheme
+with numerous extensions, including native threads, non-blocking I/O, local
+modules, and much more.  Chez Scheme compiles source expressions incrementally
+to machine code, providing the speed of compiled code in an interactive
+system.  The system is intended to be as reliable and efficient as possible,
+with reliability taking precedence over efficiency if necessary.")
     (license asl2.0)))
 
 ;;
@@ -782,11 +637,6 @@  (define-public chez-scheme-bootstrap-bootfiles
     (arguments
      (list #:install-plan
            #~`(("boot/" "lib/chez-scheme-bootfiles"))))
-    (supported-systems
-     (filter (lambda (system)
-               (and=> (chez-upstream-features-for-system system)
-                      (cut memq 'bootstrap-bootfiles <>)))
-             %supported-systems))
     (synopsis "Chez Scheme bootfiles (binary seed)")
     (description
      "Chez Scheme is a self-hosting compiler: building it requires
@@ -1054,7 +904,7 @@  (define-public chez-srfi
        (file-name (git-file-name name version))))
     (build-system gnu-build-system)
     (native-inputs
-     (list (chez-scheme-for-system)))
+     (list chez-scheme))
     (arguments
      (list #:make-flags (chez-make-flags name version)
            #:test-target "test"
@@ -1085,7 +935,7 @@  (define-public chez-web
           (base32 "1dq25qygyncbfq4kwwqqgyyakfqjwhp5q23vrf3bff1p66nyfl3b"))))
       (build-system gnu-build-system)
       (native-inputs
-       (list (chez-scheme-for-system)
+       (list chez-scheme
              ghostscript
              (texlive-updmap.cfg
               (list texlive-charter
@@ -1152,7 +1002,7 @@  (define-public chez-sockets
           (base32 "1n5fbwwz51fdzvjackgmnsgh363g9inyxv7kmzi0469cwavwcx5m"))))
       (build-system gnu-build-system)
       (native-inputs
-       (list (chez-scheme-for-system)
+       (list chez-scheme
              chez-web
              (texlive-updmap.cfg)))
       (arguments
@@ -1238,7 +1088,7 @@  (define-public chez-matchable
     (inputs
      (list chez-srfi)) ; for tests
     (native-inputs
-     (list (chez-scheme-for-system)))
+     (list chez-scheme))
     (arguments
      (list #:make-flags (chez-make-flags name version)
            #:test-target "test"
@@ -1270,7 +1120,7 @@  (define-public chez-irregex
     (propagated-inputs
      (list chez-srfi)) ; for irregex-utils
     (native-inputs
-     (list (chez-scheme-for-system)))
+     (list chez-scheme))
     (arguments
      (list #:make-flags (chez-make-flags name version)
            #:test-target "test"
@@ -1301,7 +1151,7 @@  (define-public chez-fmt
     (propagated-inputs
      (list chez-srfi)) ; for irregex-utils
     (native-inputs
-     (list (chez-scheme-for-system)))
+     (list chez-scheme))
     (arguments
      (list #:make-flags (chez-make-flags name version)
            #:test-target "chez-check"
@@ -1364,7 +1214,7 @@  (define-public chez-mit
     (inputs
      (list chez-srfi))       ; for tests
     (native-inputs
-     (list (chez-scheme-for-system)))
+     (list chez-scheme))
     (arguments
      (list #:make-flags (chez-make-flags name version)
            #:test-target "test"
@@ -1395,7 +1245,7 @@  (define-public chez-scmutils
     (inputs
      (list chez-srfi))       ; for tests
     (native-inputs
-     (list (chez-scheme-for-system)))
+     (list chez-scheme))
     (propagated-inputs
      (list chez-mit chez-srfi))
     (arguments
diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index d4819c62ce..731f479560 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -767,7 +767,7 @@  (define-public emacs-geiser-chez
                 (string-append
                  "(eval-after-load 'geiser-impl '" all ")"))))))))
     (inputs
-     (list (chez-scheme-for-system)))
+     (list chez-scheme))
     (propagated-inputs
      (list emacs-geiser))
     (home-page "https://nongnu.org/geiser/")
diff --git a/gnu/packages/patches/chez-scheme-backport-configure.patch b/gnu/packages/patches/chez-scheme-backport-configure.patch
new file mode 100644
index 0000000000..584dcb3f0b
--- /dev/null
+++ b/gnu/packages/patches/chez-scheme-backport-configure.patch
@@ -0,0 +1,463 @@ 
+From 24ab36374f2e366b6c939fffe8c129c8b0ae3b9c Mon Sep 17 00:00:00 2001
+From: Philip McGrath <philip@philipmcgrath.com>
+Date: Wed, 28 Feb 2024 19:41:22 -0500
+Subject: [PATCH 1/2] Repairs and improvements for building with external
+ dependencies (#807)
+
+* configure: fix zlib and lz4 submodule checks
+
+Conditionals to skip the submodule checks were using the wrong
+variable names, so the checks were always skipped. The correct
+behavior is to perform the check unless given `ZLIB=<zlib>` or
+`LZ4=<lz4>`, as applicable.
+
+* configure: support `ZUO=<zuo>`
+
+Supplying `ZUO=<zuo>` skips the submodule check in `configure`
+and configures the generated makefile not to build or remove Zuo.
+
+* configure: support `STEXLIB=<stex>`
+
+For compatibility with older scripts, when not explicitly configured,
+continue to honor the `STEXLIB` environment variable at build time.
+
+(cherry picked from commit b8838c3280ef10e115236d2f7ac9ae857f83e268)
+---
+ BUILDING              |  5 +++--
+ build.zuo             | 13 +++++++++----
+ configure             | 40 +++++++++++++++++++++++++++++++++-------
+ makefiles/Makefile.in |  6 ++----
+ 4 files changed, 47 insertions(+), 17 deletions(-)
+
+diff --git a/BUILDING b/BUILDING
+index 7b3dc9c8..9e9a268b 100644
+--- a/BUILDING
++++ b/BUILDING
+@@ -149,7 +149,8 @@ information on the supported options.
+ The generated makefile mostly just ensures that a `zuo` executable is
+ built in a `bin` directory, and then it defers the actual build work
+ to `zuo`, which uses the "main.zuo" file. If you have `zuo` installed,
+-you can use `zuo` directly instead of `make`. In general, instead of
++you can use `zuo` directly instead of `make`: in that case, you may
++wish to use `./configure ZUO=<zuo>`. In general, instead of
+ the command `make X` to build target `X` as described below, you can
+ use `zuo . X` (or `bin/zuo . X` after `bin/zuo` is built).
+ 
+@@ -333,7 +334,7 @@ The makefile supports several targets:
+  * `make clean`
+ 
+    Removes all built elements from the workarea, and then removes
+-   `bin/zuo`.
++   `bin/zuo` (unless configured with `ZUO=<zuo>`).
+ 
+ 
+ WINDOWS VIA COMMAND PROMPT
+diff --git a/build.zuo b/build.zuo
+index c21d2caa..c5896396 100644
+--- a/build.zuo
++++ b/build.zuo
+@@ -224,10 +224,15 @@
+            token))
+ 
+   (define stexlib
+-    (let ((found (assoc "STEXLIB" (hash-ref (runtime-env) 'env))))
+-      (if found
+-          (cdr found)
+-          (at-source "stex"))))
++    (let ([configured (hash-ref config 'STEXLIB "")]
++          [env (assoc "STEXLIB" (hash-ref (runtime-env) 'env))])
++      (cond
++        [(not (equal? "" configured))
++         configured]
++        [env
++         (cdr env)]
++        [else
++         (at-source "stex")])))
+   (define stex-sources
+     (source-tree stexlib))
+ 
+diff --git a/configure b/configure
+index 2b4b594e..782dd09b 100755
+--- a/configure
++++ b/configure
+@@ -93,6 +93,7 @@ default_warning_flags="-Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough"
+ CFLAGS_ADD=
+ zlibLib=
+ LZ4Lib=
++STEXLIB=
+ Kernel=KernelLib
+ buildKernelOnly=no
+ enableFrompb=yes
+@@ -103,6 +104,7 @@ moreBootFiles=
+ preloadBootFiles=
+ alwaysUseBootFile=
+ skipSubmoduleUpdate=
++zuoExternal=
+ 
+ CONFIG_UNAME=`uname`
+ 
+@@ -446,6 +448,12 @@ while [ $# != 0 ] ; do
+     LZ4=*)
+       LZ4Lib=`echo $1 | sed -e 's/^LZ4=//'`
+       ;;
++    STEXLIB=*)
++      STEXLIB=`echo $1 | sed -e 's/^STEXLIB=//'`
++      ;;
++    ZUO=*)
++      zuoExternal=`echo $1 | sed -e 's/^ZUO=//'`
++      ;;
+     *)
+       echo "option '$1' unrecognized or missing an argument; try $0 --help"
+       exit 1
+@@ -672,6 +680,8 @@ if [ "$help" = "yes" ]; then
+   echo "  STRIP=<strip>                     executable stripper"
+   echo "  ZLIB=<lib>                        link to <lib> instead of own zlib"
+   echo "  LZ4=<lib>                         link to <lib> instead of own LZ4"
++  echo "  STEXLIB=<stex>                    build docs with <stex> instead of own stex"
++  echo "  ZUO=<zuo>                         build with <zuo> instead of own Zuo"
+   echo ""
+   echo "Available machine types: $machs"
+   echo ""
+@@ -889,28 +899,39 @@ submod_instructions () {
+     exit 1
+ }
+ 
+-if [ ! -f "$srcdir"/zuo/configure ] ; then
+-    submod_instructions 'Source in "zuo" is missing'
++if [ "${zuoExternal}" = "" ] ; then
++    if [ ! -f "$srcdir"/zuo/configure ] ; then
++        submod_instructions 'Source in "zuo" is missing'
++    fi
++    ZUO="bin/zuo"
++    RM_ZUO="rm -f bin/zuo"
++    ZUO_TARGET="bin/zuo"
++else
++    ZUO="${zuoExternal}"
++    RM_ZUO="@echo 'Not cleaning external ${zuoExternal}'"
++    ZUO_TARGET="DoNotBuildZuo"
+ fi
+ 
+ if [ ! -f "$srcdir"/nanopass/nanopass.ss ] ; then
+     submod_instructions 'Source in "nanopass" is missing'
+ fi
+ 
+-if [ "${zlibDep}" != "" ] ; then
++if [ "${zlibLib}" = "" ] ; then
+     if [ ! -f "$srcdir"/zlib/configure ] ; then
+         submod_instructions 'Source in "zlib" is missing'
+     fi
+ fi
+ 
+-if [ "${LZ4Dep}" != "" ] ; then
++if [ "${LZ4Lib}" = "" ] ; then
+     if [ ! -f "$srcdir"/lz4/lib/Makefile ] ; then
+         submod_instructions 'Source in "lz4" is missing'
+     fi
+ fi
+ 
+-if [ ! -f "$srcdir"/stex/Mf-stex ] ; then
+-    submod_instructions 'Source in "stex" is missing'
++if [ "${STEXLIB}" = "" ] ; then
++    if [ ! -f "$srcdir"/stex/Mf-stex ] ; then
++        submod_instructions 'Source in "stex" is missing'
++    fi
+ fi
+ 
+ # more compile and link flags for c/Mf-unix and mats/Mf-unix
+@@ -1083,7 +1104,7 @@ cp "$srcdir"/makefiles/buildmain.zuo main.zuo
+ # Some idea, but in the workarea, so it refers to "workarea.zuo" here:
+ cp "$srcdir"/makefiles/workmain.zuo $w/main.zuo
+ 
+-# The content of "$w/Makefile" records configuration decisions,
++# The content of "$w/Mf-config" records configuration decisions,
+ # and the Zuo build script takes it from there
+ cat > $w/Mf-config << END
+ srcdir=$srcdir
+@@ -1119,6 +1140,7 @@ cursesLib=$cursesLib
+ ncursesLib=$ncursesLib
+ zlibLib=$zlibLib
+ LZ4Lib=$LZ4Lib
++STEXLIB=$STEXLIB
+ warningFlags=$warningFlags
+ Kernel=$Kernel
+ installscriptname=$installscriptname
+@@ -1130,6 +1152,10 @@ preloadBootFiles=$preloadBootFiles
+ alwaysUseBootFile=$alwaysUseBootFile
+ relativeBootFiles=$relativeBootFiles
+ 
++ZUO=$ZUO
++RM_ZUO=$RM_ZUO
++ZUO_TARGET=$ZUO_TARGET
++
+ InstallBin=$installbin
+ InstallLib=$installlib
+ InstallMan=$installman/man1
+diff --git a/makefiles/Makefile.in b/makefiles/Makefile.in
+index 3b95f065..0e3d307d 100644
+--- a/makefiles/Makefile.in
++++ b/makefiles/Makefile.in
+@@ -3,8 +3,6 @@ workarea=$(w)
+ 
+ include $(workarea)/Mf-config
+ 
+-ZUO=bin/zuo
+-
+ .PHONY: build
+ build: $(ZUO)
+ 	+ $(ZUO) $(workarea) MAKE="$(MAKE)"
+@@ -144,9 +142,9 @@ pkg: $(ZUO)
+ .PHONY: clean
+ clean: $(ZUO)
+ 	+ $(ZUO) $(workarea) clean MAKE="$(MAKE)"
+-	rm -f bin/zuo
++	$(RM_ZUO)
+ 
+ # Using `+` here means that $(ZUO) gets built even if `-n`/`--dry-run` is provided to `make`
+-$(ZUO): $(srcdir)/zuo/zuo.c
++$(ZUO_TARGET): $(srcdir)/zuo/zuo.c
+ 	+ mkdir -p bin
+ 	+ $(CC_FOR_BUILD) -DZUO_LIB_PATH='"'"../zuo/lib"'"' -o $(ZUO) $(srcdir)/zuo/zuo.c
+
+base-commit: 253230f7dfbb4fe777277d6bbf93f39f9567f086
+-- 
+2.41.0
+
+
+From 665bccc1c074131e790879adc1436f8059801171 Mon Sep 17 00:00:00 2001
+From: Matthew Flatt <mflatt@racket-lang.org>
+Date: Sun, 17 Mar 2024 09:06:30 -0600
+Subject: [PATCH 2/2] adjust `configure ZUO=<command>` support (#816)
+
+Continuing from b8838c3280, adjust the generated makefile so the
+supplied `<command>` is not a makefile dependency. That way, `ZUO=zuo`
+works if `zuo` is installed and the current build directory is not the
+source directory. (The `zuo` executable is a dependency in a real and
+relevant sense, but not in the sense of dependencies that we normally
+track in makefiles.)
+
+Also adapt the makefile for the case that `ZUO=...` is not supplied
+and the build directory is not the source directory, in which case
+`ZUO_LIB_PATH` needs to be relative to the source directory.
+
+Using `make ZUO=zuo` can also work, but in that case, `bin/zuo` is
+still built as a dependency. It's possible that some portable makefile
+magic could overcome that limitation, but it doesn't seem important.
+
+(cherry picked from commit d327968f37cdf669d15a9ad6d356bbf92c502bb9)
+---
+ configure             |  3 ++
+ makefiles/Makefile.in | 66 +++++++++++++++++++++----------------------
+ 2 files changed, 36 insertions(+), 33 deletions(-)
+
+diff --git a/configure b/configure
+index 782dd09b..9adae37a 100755
+--- a/configure
++++ b/configure
+@@ -904,10 +904,12 @@ if [ "${zuoExternal}" = "" ] ; then
+         submod_instructions 'Source in "zuo" is missing'
+     fi
+     ZUO="bin/zuo"
++    ZUO_DEP="${ZUO}"
+     RM_ZUO="rm -f bin/zuo"
+     ZUO_TARGET="bin/zuo"
+ else
+     ZUO="${zuoExternal}"
++    ZUO_DEP=""
+     RM_ZUO="@echo 'Not cleaning external ${zuoExternal}'"
+     ZUO_TARGET="DoNotBuildZuo"
+ fi
+@@ -1153,6 +1155,7 @@ alwaysUseBootFile=$alwaysUseBootFile
+ relativeBootFiles=$relativeBootFiles
+ 
+ ZUO=$ZUO
++ZUO_DEP=$ZUO_DEP
+ RM_ZUO=$RM_ZUO
+ ZUO_TARGET=$ZUO_TARGET
+ 
+diff --git a/makefiles/Makefile.in b/makefiles/Makefile.in
+index 0e3d307d..fc8605a0 100644
+--- a/makefiles/Makefile.in
++++ b/makefiles/Makefile.in
+@@ -4,55 +4,55 @@ workarea=$(w)
+ include $(workarea)/Mf-config
+ 
+ .PHONY: build
+-build: $(ZUO)
++build: $(ZUO_DEP)
+ 	+ $(ZUO) $(workarea) MAKE="$(MAKE)"
+ 
+ .PHONY: run
+-run: $(ZUO)
++run: $(ZUO_DEP)
+ 	+ $(ZUO) $(workarea) run
+ 
+ .PHONY: kernel
+-kernel: $(ZUO)
++kernel: $(ZUO_DEP)
+ 	+ $(ZUO) $(workarea) kernel MAKE="$(MAKE)"
+ 
+ .PHONY: install
+-install: $(ZUO)
++install: $(ZUO_DEP)
+ 	$(ZUO) $(workarea) install MAKE="$(MAKE)"
+ 
+ .PHONY: uninstall
+-uninstall: $(ZUO)
++uninstall: $(ZUO_DEP)
+ 	+ $(ZUO) $(workarea) uninstall MAKE="$(MAKE)"
+ 
+ .PHONY: test-one
+-test-one: $(ZUO)
++test-one: $(ZUO_DEP)
+ 	+ $(ZUO) $(workarea) test-one MAKE="$(MAKE)"
+ 
+ .PHONY: test-some-fast
+-test-some-fast: $(ZUO)
++test-some-fast: $(ZUO_DEP)
+ 	+ $(ZUO) $(workarea) test-some-fast MAKE="$(MAKE)"
+ 
+ .PHONY: test-some
+-test-some: $(ZUO)
++test-some: $(ZUO_DEP)
+ 	+ $(ZUO) $(workarea) test-some MAKE="$(MAKE)"
+ 
+ .PHONY: test
+-test: $(ZUO)
++test: $(ZUO_DEP)
+ 	+ $(ZUO) $(workarea) test MAKE="$(MAKE)"
+ 
+ .PHONY: test-more
+-test-more: $(ZUO)
++test-more: $(ZUO_DEP)
+ 	+ $(ZUO) $(workarea) test-more MAKE="$(MAKE)"
+ 
+ .PHONY: coverage
+-coverage: $(ZUO)
++coverage: $(ZUO_DEP)
+ 	+ $(ZUO) $(workarea) coverage MAKE="$(MAKE)"
+ 
+ .PHONY: bootfiles
+-bootfiles: $(ZUO)
++bootfiles: $(ZUO_DEP)
+ 	+ $(ZUO) $(workarea) bootfiles MAKE="$(MAKE)"
+ 
+ .PHONY: reset
+-reset: $(ZUO)
++reset: $(ZUO_DEP)
+ 	+ $(ZUO) $(workarea) reset MAKE="$(MAKE)"
+ 
+ # Supply XM=<machine> to build boot files for <machine>
+@@ -61,90 +61,90 @@ boot:
+ 	+ $(ZUO) $(workarea) boot "$(XM)" MAKE="$(MAKE)"
+ 
+ # `<machine>.boot` as alias for `boot XM=<machine>`
+-%.boot: $(ZUO)
++%.boot: $(ZUO_DEP)
+ 	+ $(ZUO) $(workarea) boot $* MAKE="$(MAKE)"
+ 
+ .PHONY: auto.boot
+-auto.boot: $(ZUO)
++auto.boot: $(ZUO_DEP)
+ 	+ $(ZUO) $(workarea) boot MAKE="$(MAKE)"
+ 
+ SCHEME=scheme
+ 
+ .PHONY: cross.boot
+-cross.boot: $(ZUO)
++cross.boot: $(ZUO_DEP)
+ 	+ $(ZUO) $(workarea) boot SCHEME="$(SCHEME)" MAKE="$(MAKE)"
+ 
+ .PHONY: re.boot
+-re.boot: $(ZUO)
++re.boot: $(ZUO_DEP)
+ 	+ $(ZUO) $(workarea) reboot SCHEME="$(SCHEME)"
+ 
+ # Supply XM=<machine> to build boot files for <machine>
+ # with o=3 d=0 for the cross compiler, and only after
+ # building the kernel for the configured machine
+ .PHONY: bootquick
+-bootquick: $(ZUO)
++bootquick: $(ZUO_DEP)
+ 	+ $(ZUO) $(workarea) bootquick "$(XM)" MAKE="$(MAKE)"
+ 
+ # `<machine>.bootquick` as alias for `boot XM=<machine>`
+-%.bootquick: $(ZUO)
++%.bootquick: $(ZUO_DEP)
+ 	+ $(ZUO) $(workarea) bootquick $* MAKE="$(MAKE)"
+ 
+-auto.bootquick: $(ZUO)
++auto.bootquick: $(ZUO_DEP)
+ 	+ $(ZUO) $(workarea) bootquick MAKE="$(MAKE)"
+ 
+ # Supply XM=<machine>-<tag>.bootpbchunk to repackage boot files for
+ # <machine> with pbchunk sources, including additional
+ # boot files
+ .PHONY: bootpbchunk
+-bootpbchunk: $(ZUO)
++bootpbchunk: $(ZUO_DEP)
+ 	+ $(ZUO) $(workarea) bootpbchunk "$(XM)" $(ARGS) MAKE="$(MAKE)"
+ 
+ # `<machine>.bootpbchunk` as alias for `pbchunk XM=<machine>`
+-%.bootpbchunk: $(ZUO)
++%.bootpbchunk: $(ZUO_DEP)
+ 	+ $(ZUO) $(workarea) bootpbchunk $* $(ARGS) MAKE="$(MAKE)"
+ 
+ .PHONY: docs
+-docs: build $(ZUO)
++docs: build $(ZUO_DEP)
+ 	+ $(ZUO) $(workarea) docs MAKE="$(MAKE)"
+ 
+ .PHONY: csug
+-csug: build $(ZUO)
++csug: build $(ZUO_DEP)
+ 	+ $(ZUO) $(workarea) csug MAKE="$(MAKE)"
+ 
+ .PHONY: release_notes
+-release_notes: build $(ZUO)
++release_notes: build $(ZUO_DEP)
+ 	+ $(ZUO) $(workarea) release_notes MAKE="$(MAKE)"
+ 
+ .PHONY: install-docs
+-install-docs: build $(ZUO)
++install-docs: build $(ZUO_DEP)
+ 	+ $(ZUO) $(workarea) install-docs MAKE="$(MAKE)"
+ 
+ .PHONY: install-csug
+-install-csug: build $(ZUO)
++install-csug: build $(ZUO_DEP)
+ 	+ $(ZUO) $(workarea) install-csug MAKE="$(MAKE)"
+ 
+ .PHONY: install-release_notes
+-install-release_notes: build $(ZUO)
++install-release_notes: build $(ZUO_DEP)
+ 	+ $(ZUO) $(workarea) install-release_notes MAKE="$(MAKE)"
+ 
+ .PHONY: bintar
+-bintar: $(ZUO)
++bintar: $(ZUO_DEP)
+ 	+ $(ZUO) $(workarea) bintar MAKE="$(MAKE)"
+ 
+ .PHONY: rpm
+-rpm: $(ZUO)
++rpm: $(ZUO_DEP)
+ 	+ $(ZUO) $(workarea) rpm MAKE="$(MAKE)"
+ 
+ .PHONY: pkg
+-pkg: $(ZUO)
++pkg: $(ZUO_DEP)
+ 	+ $(ZUO) $(workarea) pkg MAKE="$(MAKE)"
+ 
+ .PHONY: clean
+-clean: $(ZUO)
++clean: $(ZUO_DEP)
+ 	+ $(ZUO) $(workarea) clean MAKE="$(MAKE)"
+ 	$(RM_ZUO)
+ 
+ # Using `+` here means that $(ZUO) gets built even if `-n`/`--dry-run` is provided to `make`
+ $(ZUO_TARGET): $(srcdir)/zuo/zuo.c
+ 	+ mkdir -p bin
+-	+ $(CC_FOR_BUILD) -DZUO_LIB_PATH='"'"../zuo/lib"'"' -o $(ZUO) $(srcdir)/zuo/zuo.c
++	+ $(CC_FOR_BUILD) -DZUO_LIB_PATH='"'"$(upsrcdir)/zuo/lib"'"' -o $(ZUO) $(srcdir)/zuo/zuo.c
+-- 
+2.41.0
+
diff --git a/gnu/packages/patches/chez-scheme-bin-sh.patch b/gnu/packages/patches/chez-scheme-bin-sh.patch
index 7650914f01..c2a4b292f7 100644
--- a/gnu/packages/patches/chez-scheme-bin-sh.patch
+++ b/gnu/packages/patches/chez-scheme-bin-sh.patch
@@ -1,6 +1,6 @@ 
-From 3c838e6a0c3214d95bf02048cddccfd1b69a679f Mon Sep 17 00:00:00 2001
+From b8428ad25b437acf4bd8210b14db207b71fe44c3 Mon Sep 17 00:00:00 2001
 From: Philip McGrath <philip@philipmcgrath.com>
-Date: Thu, 19 May 2022 13:41:56 -0400
+Date: Wed, 24 Aug 2022 19:55:14 -0400
 Subject: [PATCH] patch s_process for "/bin/sh" on Guix
 
 If:
@@ -14,22 +14,27 @@  then `s_process` will call `execl` with the file specified by
 `_PATH_BSHELL` instead of "/bin/sh".
 
 Checking that the path specified by `_PATH_BSHELL` exists safeguards
-against obscure errors if attempting to use stand-alone executables
-built by the patched Racket in non-Guix envoronments.
+against obscure errors if attempting to use the patched Chez Scheme
+or executables it builds in non-Guix envoronments.
 
 This patch does not change the behavior of `s_system`, which relies
 on `system` from the C library.
 ---
+
+Notes:
+    See also racket-chez-scheme-bin-sh.patch, racket-rktio-bin-sh.patch,
+    and zuo-bin-sh.patch.
+
  c/prim5.c | 21 ++++++++++++++++++++-
  1 file changed, 20 insertions(+), 1 deletion(-)
 
 diff --git a/c/prim5.c b/c/prim5.c
-index 5a07893..bc2736c 100644
+index 90b087f1..284f063f 100644
 --- a/c/prim5.c
 +++ b/c/prim5.c
-@@ -23,6 +23,12 @@
- #include <ctype.h>
- #include <math.h>
+@@ -27,6 +27,12 @@
+ #include <sys/resource.h>
+ #endif
  
 +/* BEGIN PATCH for Guix */
 +#ifndef WIN32
@@ -39,8 +44,8 @@  index 5a07893..bc2736c 100644
 +
  /* locally defined functions */
  static INT s_errno(void);
- static iptr s_addr_in_heap(uptr x);
-@@ -746,6 +752,17 @@ static ptr s_process(char *s, IBOOL stderrp) {
+ static IBOOL s_addr_in_heap(uptr x);
+@@ -875,6 +881,17 @@ static ptr s_process(char *s, IBOOL stderrp) {
  
      INT tofds[2], fromfds[2], errfds[2];
      struct sigaction act, oint_act;
@@ -58,10 +63,10 @@  index 5a07893..bc2736c 100644
  
      if (pipe(tofds)) S_error("process","cannot open pipes");
      if (pipe(fromfds)) {
-@@ -771,7 +788,9 @@ static ptr s_process(char *s, IBOOL stderrp) {
-         CLOSE(1); if (dup(fromfds[1]) != 1) _exit(1);
-         CLOSE(2); if (dup(stderrp ? errfds[1] : 1) != 2) _exit(1);
-         {INT i; for (i = 3; i < NOFILE; i++) (void)CLOSE(i);}
+@@ -911,7 +928,9 @@ static ptr s_process(char *s, IBOOL stderrp) {
+           }
+         }
+ #endif /* __GNU__ Hurd */
 -        execl("/bin/sh", "/bin/sh", "-c", s, NULL);
 +        /* BEGIN PATCH for Guix */
 +        execl(guix_sh, guix_sh, "-c", s, NULL);
@@ -70,7 +75,7 @@  index 5a07893..bc2736c 100644
          /*NOTREACHED*/
      } else {
 
-base-commit: 9df56e7b25bc523663eac3da24be33afc5f76c84
+base-commit: 253230f7dfbb4fe777277d6bbf93f39f9567f086
 -- 
-2.32.0
+2.41.0