summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2019-12-06 23:07:13 +0100
committerLudovic Courtès <ludo@gnu.org>2020-01-05 11:39:54 +0100
commit3e480b17c73b4e0a86f1323cdaf2dcbbcf723df1 (patch)
treeee190d2c750ee59d2c1a222cc7ea75d1173030f7
parentd63ee94d63c667e0c63651d6b775460f4c67497d (diff)
utils: 'version-compare' delays 'dynamic-link' code.
* guix/utils.scm (version-compare): Delay 'strverscmp' and force it when called.
-rw-r--r--guix/utils.scm11
1 files changed, 7 insertions, 4 deletions
diff --git a/guix/utils.scm b/guix/utils.scm
index 728039fbf0..b3aacfa28b 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -508,14 +508,17 @@ a character other than '@'."
(define version-compare
(let ((strverscmp
- (let ((sym (or (dynamic-func "strverscmp" (dynamic-link))
- (error "could not find `strverscmp' (from GNU libc)"))))
- (pointer->procedure int sym (list '* '*)))))
+ ;; Delay symbol resolution so that this module can be used even on a
+ ;; statically-linked Guile.
+ (delay
+ (let ((sym (or (dynamic-func "strverscmp" (dynamic-link))
+ (error "could not find `strverscmp' (from GNU libc)"))))
+ (pointer->procedure int sym (list '* '*))))))
(lambda (a b)
"Return '> when A denotes a newer version than B,
'< when A denotes a older version than B,
or '= when they denote equal versions."
- (let ((result (strverscmp (string->pointer a) (string->pointer b))))
+ (let ((result ((force strverscmp) (string->pointer a) (string->pointer b))))
(cond ((positive? result) '>)
((negative? result) '<)
(else '=))))))