syscalls: Adjust for lack of 'libutil.so' on glibc >= 2.34.

This is a re-implementation of 3c8b6fd94c
done in a way that works for both glibc >= 2.34 and earlier versions.

* guix/build/syscalls.scm (syscall->procedure): When LIBRARY is true,
fall back to global symbols if (dynamic-link library) fails.
This commit is contained in:
Ludovic Courtès 2022-11-07 22:26:54 +01:00
parent c9984bfc50
commit 3f6c32a88f
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -445,9 +445,14 @@ (define* (syscall->procedure return-type name argument-types
the returned procedure is called."
(catch #t
(lambda ()
;; Note: When #:library is set, try it first and fall back to libc
;; proper. This is because libraries like libutil.so have been subsumed
;; by libc.so with glibc >= 2.34.
(let ((ptr (dynamic-func name
(if library
(dynamic-link library)
(or (false-if-exception
(dynamic-link library))
(dynamic-link))
(dynamic-link)))))
;; The #:return-errno? facility was introduced in Guile 2.0.12.
(pointer->procedure return-type ptr argument-types