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.

(cherry picked from commit 3f6c32a88f)
This commit is contained in:
Ludovic Courtès 2022-11-07 22:26:54 +01:00 committed by Marius Bakke
parent 883fefe160
commit 047425a662
No known key found for this signature in database
GPG Key ID: A2A06DF2A33A54FA

View File

@ -447,9 +447,14 @@ If an error occurs while creating the binding, defer the error report until
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