bug#30680: [PATCH] Patch Racket to fix bug #30680

2018-08-13 Thread Konrad Hinsen
Timothy Sample  writes:

> Oops!  My fault.  The patch is attached here.  *crosses fingers*

I have ported the patch to Racket 7.0, the modified version is attached.
It gets rid of all the store-related error messages I got when
installing packages with raco, so as far as I am concerned the bug
is indeed fixed.

BTW, the patch (to Guix) for updating Racket to 7.0 is at

 https://debbugs.gnu.org/32355

(but does not yet include this patch to Racket).

Thanks a lot for resolving this issue!

Konrad.

>From da6defb46b69dfb55e5188ed851f5c1443f748ba Mon Sep 17 00:00:00 2001
From: Konrad Hinsen 
Date: Mon, 13 Aug 2018 14:50:37 +0200
Subject: [PATCH] Patch for compilation under Guix

(Port to Racket 7.0 of Timothy Sample's patch for Racket 6.12)

Racket uses checksums to test if it needs to recompile its source
files to bytecode.  If Racket is updated by grafting, the source and
bytecode files get updated, but the checksum stays the same.  Since
the checksum no longer matches the source file, Racket tries to
regenerate the bytecode and write it to the store, causing errors
because the store is immutable.  This patch makes Racket ignore
checksums for files in the store.

See  for details.
---
 collects/compiler/private/cm-minimal.rkt | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/collects/compiler/private/cm-minimal.rkt b/collects/compiler/private/cm-minimal.rkt
index a5a5407..15af6b8 100644
--- a/collects/compiler/private/cm-minimal.rkt
+++ b/collects/compiler/private/cm-minimal.rkt
@@ -7,6 +7,7 @@
  racket/list
  racket/path
  racket/promise
+ racket/string
  openssl/sha1
  setup/collects
  compiler/compilation-path
@@ -543,6 +544,10 @@
   #f
   (list src-hash recorded-hash)))
 
+(define (store-reference? path)
+  (let ([store-prefix (or (getenv "NIX_STORE") "/gnu/store")])
+(string-prefix? (path->string path) store-prefix)))
+
 (define (rkt->ss p)
   (if (path-has-extension? p #".rkt")
   (path-replace-extension p #".ss")
@@ -595,7 +600,8 @@
   (trace-printf "newer src... ~a > ~a" path-time path-zo-time)
   ;; If `sha1-only?', then `maybe-compile-zo' returns a #f or thunk:
   (maybe-compile-zo sha1-only? deps path->mode roots path orig-path read-src-syntax up-to-date collection-cache new-seen)]
- [(different-source-sha1-and-dep-recorded path deps)
+ [(and (not (store-reference? path))
+   (different-source-sha1-and-dep-recorded path deps))
   => (lambda (difference)
(trace-printf "different src hash... ~a" difference)
;; If `sha1-only?', then `maybe-compile-zo' returns a #f or thunk:
-- 
2.18.0



bug#30680: [PATCH] Patch Racket to fix bug #30680

2018-08-12 Thread Timothy Sample
Christopher Lemmer Webber  writes:

> Timothy Sample writes:
>
>> Hi Guix,
>>
>> (Patch is attached below.)
>>
>> This patch fixes .  It does so by
>> patching Racket to treat store files specially.  I have verified that it
>> both fixes the bug above and still recompiles non-store files.
>>
>> As far as I can tell, Racket only uses these checksums as part of its
>> “setup” library.  When deciding whether to use a bytecode file during
>> evaluation, it does not verify the checksum.  That’s why only the
>> “setup” code is patched.
>>
>> As a side note, both GDB and Go have similar problems:
>>
>> • 
>> • 
>>
>> If there ever is a more general solution, this patch will no longer be
>> necessary.
>>
>> (Also, Racket takes a bit of time to build, so reviewers beware!)
>>
>>
>> -- Tim
>
> Oh wait... it seems like the patch is not actually attached?  I assume
> that must be an error!
>
> Actually if I look at the raw view of the email I see:
>
> --=-=-=
> Content-Type: message/external-body;
>  
> name="/home/samplet/code/guix-wip-racket/0001-gnu-racket-Ignore-bytecode-checksums-in-the-store.patch";
>  access-type=local-file
>
> Content-Type: text/x-patch
> Content-ID: <87pnynbfy0@ngyro.com>
> Content-Transfer-Encoding: binary
>
>
>
> --=-=-=
>
> So it looks like it should be attached, but I don't see the file
> contents?
>
> Perhaps this is an error on my end!  But I'm very eager to test this
> patch!

Oops!  My fault.  The patch is attached here.  *crosses fingers*

>From 69383706548fadf550c84b3f0d07fc55d1c67858 Mon Sep 17 00:00:00 2001
From: Timothy Sample 
Date: Sun, 12 Aug 2018 11:12:38 -0400
Subject: [PATCH] gnu: racket: Ignore bytecode checksums in the store.

Fixes .

* gnu/packages/patches/racket-store-checksum-override.patch: New file.
* gnu/packages/scheme.scm (racket)[sources]: Add it.
---
 .../racket-store-checksum-override.patch  | 42 +++
 gnu/packages/scheme.scm   |  3 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/racket-store-checksum-override.patch

diff --git a/gnu/packages/patches/racket-store-checksum-override.patch b/gnu/packages/patches/racket-store-checksum-override.patch
new file mode 100644
index 0..b22facca0
--- /dev/null
+++ b/gnu/packages/patches/racket-store-checksum-override.patch
@@ -0,0 +1,42 @@
+Racket uses checksums to test if it needs to recompile its source
+files to bytecode.  If Racket is updated by grafting, the source and
+bytecode files get updated, but the checksum stays the same.  Since
+the checksum no longer matches the source file, Racket tries to
+regenerate the bytecode and write it to the store, causing errors
+because the store is immutable.  This patch makes Racket ignore
+checksums for files in the store.
+
+See  for details.
+
+diff -ruN racket-6.12/collects/compiler/cm.rkt racket-6.12-patched/collects/compiler/cm.rkt
+--- racket-6.12/collects/compiler/cm.rkt	1969-12-31 19:00:00.0 -0500
 racket-6.12-patched/collects/compiler/cm.rkt	2018-08-12 06:36:46.061142149 -0400
+@@ -7,6 +7,7 @@
+  racket/list
+  racket/path
+  racket/promise
++ racket/string
+  openssl/sha1
+  racket/place
+  setup/collects
+@@ -627,6 +628,10 @@
+   #f
+   (list src-hash recorded-hash)))
+ 
++(define (store-reference? path)
++  (let ([store-prefix (or (getenv "NIX_STORE") "/gnu/store")])
++(string-prefix? (path->string path) store-prefix)))
++
+ (define (rkt->ss p)
+   (if (path-has-extension? p #".rkt")
+   (path-replace-extension p #".ss")
+@@ -679,7 +684,8 @@
+   (trace-printf "newer src... ~a > ~a" path-time path-zo-time)
+   ;; If `sha1-only?', then `maybe-compile-zo' returns a #f or thunk:
+   (maybe-compile-zo sha1-only? deps path->mode roots path orig-path read-src-syntax up-to-date collection-cache new-seen)]
+- [(different-source-sha1-and-dep-recorded path deps)
++ [(and (not (store-reference? path))
++   (different-source-sha1-and-dep-recorded path deps))
+   => (lambda (difference)
+(trace-printf "different src hash... ~a" difference)
+;; If `sha1-only?', then `maybe-compile-zo' returns a #f or thunk:
diff --git a/gnu/packages/scheme.scm b/gnu/packages/scheme.scm
index 4178a45a8..b30245cce 100644
--- a/gnu/packages/scheme.scm
+++ b/gnu/packages/scheme.scm
@@ -421,7 +421,8 @@ implementation techniques and as an expository tool.")
  (patches (search-patches
;; See: https://github.com/racket/racket/issues/1962
;; This can be removed in whatever Racket release comes after 6.12
-   "racket-fix-xform-issue.patch"
+   

bug#30680: [PATCH] Patch Racket to fix bug #30680

2018-08-12 Thread Christopher Lemmer Webber
Timothy Sample writes:

> Hi Guix,
>
> (Patch is attached below.)
>
> This patch fixes .  It does so by
> patching Racket to treat store files specially.  I have verified that it
> both fixes the bug above and still recompiles non-store files.
>
> As far as I can tell, Racket only uses these checksums as part of its
> “setup” library.  When deciding whether to use a bytecode file during
> evaluation, it does not verify the checksum.  That’s why only the
> “setup” code is patched.
>
> As a side note, both GDB and Go have similar problems:
>
> • 
> • 
>
> If there ever is a more general solution, this patch will no longer be
> necessary.
>
> (Also, Racket takes a bit of time to build, so reviewers beware!)
>
>
> -- Tim

Oh wait... it seems like the patch is not actually attached?  I assume
that must be an error!

Actually if I look at the raw view of the email I see:

--=-=-=
Content-Type: message/external-body;
 
name="/home/samplet/code/guix-wip-racket/0001-gnu-racket-Ignore-bytecode-checksums-in-the-store.patch";
 access-type=local-file

Content-Type: text/x-patch
Content-ID: <87pnynbfy0@ngyro.com>
Content-Transfer-Encoding: binary



--=-=-=

So it looks like it should be attached, but I don't see the file
contents?

Perhaps this is an error on my end!  But I'm very eager to test this
patch!





bug#30680: [PATCH] Patch Racket to fix bug #30680

2018-08-12 Thread Timothy Sample
Hi Guix,

(Patch is attached below.)

This patch fixes .  It does so by
patching Racket to treat store files specially.  I have verified that it
both fixes the bug above and still recompiles non-store files.

As far as I can tell, Racket only uses these checksums as part of its
“setup” library.  When deciding whether to use a bytecode file during
evaluation, it does not verify the checksum.  That’s why only the
“setup” code is patched.

As a side note, both GDB and Go have similar problems:

• 

If there ever is a more general solution, this patch will no longer be
necessary.

(Also, Racket takes a bit of time to build, so reviewers beware!)

<<< message/external-body; name="/home/samplet/code/guix-wip-racket/0001-gnu-racket-Ignore-bytecode-checksums-in-the-store.patch"; access-type=local-file: Unrecognized >>>

-- Tim