aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Buck <dev@icepic.de>2024-11-10 19:23:01 +0100
committerLudovic Courtès <ludo@gnu.org>2024-11-18 10:58:42 +0100
commit23cbbe6860782c5d4a0ba599ea1cda0642e91661 (patch)
treeb646cc1efacbd56fc6c47440c82513f4f79cb777
parent7c9fcc3e6ee55fdfd35860bd2186eeae90575e3f (diff)
downloadguix-23cbbe6860782c5d4a0ba599ea1cda0642e91661.tar.gz
guix-23cbbe6860782c5d4a0ba599ea1cda0642e91661.zip
records: Fix ABI check in cross-compilation context.
Fixes <https://issues.guix.gnu.org/74296>. * guix/records.scm (define-record-type*)[compute-abi-cookie]: Use 32bit hash value for abi check to prevent `record-abi-mismatch-error` in a cross-compile context. Change-Id: I889747b1a2837bee8bf9b4de5729fdcf1b165380 Signed-off-by: Ludovic Courtès <ludo@gnu.org>
-rw-r--r--guix/records.scm18
1 files changed, 13 insertions, 5 deletions
diff --git a/guix/records.scm b/guix/records.scm
index dca1e3c2e7..fa2d42e17b 100644
--- a/guix/records.scm
+++ b/guix/records.scm
@@ -415,11 +415,19 @@ inherited."
;; list of symbols.
(syntax-case field-specs ()
(((field get properties ...) ...)
- (string-hash (object->string
- (syntax->datum #'((field properties ...) ...)))
- (cond-expand
- (guile-3 (target-most-positive-fixnum))
- (else most-positive-fixnum))))))
+ ;; Passing (target-most-positive-fixnum) as the second argument of
+ ;; 'string-hash' won't have the intended effect when cross-compiling
+ ;; because that second argument is used to compute a modulo after the
+ ;; hash has been computed on an 'unsigned long'. Instead, only keep
+ ;; the 32 most significant bits on 64-bit platforms, unconditionally.
+ ;; See <https://issues.guix.gnu.org/74296>.
+ (let ((hash-value
+ (string-hash
+ (object->string (syntax->datum #'((field properties ...) ...))))))
+ (cond
+ ((< most-positive-fixnum (ash 1 32)) hash-value)
+ ((< most-positive-fixnum (ash 1 64)) (ash hash-value -32))
+ (else (error "unexpected!" most-positive-fixnum)))))))
(syntax-case s ()
((_ type syntactic-ctor ctor pred