A macOS patch

"Chun Tian (binghe)" <[email protected]> Mon, 26 May 2025 14:08:56 +1000
Newsgroups gmane.lisp.gcl.devel
Organization The Australian National University
Message-ID <[email protected]>
This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--IyZ6Zl0QXwFKJJtkv0gkPoTYKwVysirY7
Content-Type: multipart/mixed; boundary="qqorkFfTBbEtnwVGyDEdlq1hxGAgYXCNe";
 protected-headers="v1"
From: "Chun Tian (binghe)" <[email protected]>
To: [email protected]
Message-ID: <[email protected]>
Subject: A macOS patch

--qqorkFfTBbEtnwVGyDEdlq1hxGAgYXCNe
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Greetings,

When building GCL 2.7 on various versions of macOS, I found that GCL need=
s to
load different system libraries in different versions of macOS, and the L=
isp
function LIB-NAME defined in lsp/gcl_dl.lsp is used to compute the full p=
ath of
these libraries from just the name.

Currently on macOS the code assumes that the needed library must be under=

"/usr/lib/system/". But this is only true for libraries like
"libsystem_*.dylib". All other libraries, e.g. libSystem.B.dylib, is unde=
r
"/usr/lib/".

The following patch has been verified on all macOS versions from 10.6 to =
15.x:

diff --git a/lsp/gcl_dl.lsp b/lsp/gcl_dl.lsp
index 6f6b35f44..4d8f9962e 100644
--- a/lsp/gcl_dl.lsp
+++ b/lsp/gcl_dl.lsp
@@ -3,9 +3,16 @@

 (export '(mdlsym mdl lib-name))

+(defvar *dll-extension* #+darwin ".dylib" #+cygwin ".dll" #-(or darwin c=
ygwin)
".so")
+
 (defun lib-name (p)
-  (if (or (string=3D p "") (string=3D p "libc") (string=3D p "libm")) ""=

-    (string-concatenate #+darwin "/usr/lib/system/" p #+darwin ".dylib"
#+cygwin ".dll" #-(or darwin cygwin) ".so")));FIXME
+  (cond ((or (string=3D p "") (string=3D p "libc") (string=3D p "libm"))=

+         "")
+        #+darwin ; "/usr/lib/system/" is macOS-specific
+        ((string<=3D "libsystem" p)
+         (string-concatenate "/usr/lib/system/" p *dll-extension*))
+        (t
+         (string-concatenate #+darwin "/usr/lib/" p *dll-extension*))))

 (defun mdl (n p vad)
   (let* ((sym (mdlsym n (lib-name p)))

* * *

Note also that, in the above patch, I defined a new variable *dll-extensi=
on* to
eliminate some code duplication. This is unnecessary, and feel free to el=
iminate
it. But I think it should be useful to have such a special variable expor=
ted in
SI package, for users who needs to load dynamic libraries by just filenam=
e
without extension name.

--Chun


--qqorkFfTBbEtnwVGyDEdlq1hxGAgYXCNe--

--IyZ6Zl0QXwFKJJtkv0gkPoTYKwVysirY7
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEES+aY+4laoC0TwmVKFUkg2jrYR8gFAmgz6VkACgkQFUkg2jrY
R8jIrxAAqSaZ+Gu9CyT6C7Uwmqy4xBhuPwrBaznGdz3ogXMVvDIzQsd+z1lh3JK2
v5LH0svvX3O8B6H5dnLUEQCrgmX3hC5WT5y2ejaKk/RWxNxfpX9caLVwMvBsLGXB
Wk/uvS6RFmTYHvjHJspNlDIqQCGcgnNd0VFkF5t6X4xvoRLZHr/yhoei5PiAdXsY
cQgVLorKd2WABP/IrUr/kpMMrmMBuZaDvBR3aYG0C5XgTOPcZYHCvfse+KWNFn1v
ACeu6TT9v1GUh3QljRPTJQ2PzhxHXKi7Wns+aDKG/cbP22NbQGqNhIQdj+JFbqv6
ya05hRD7hqj4teIJydoluATb4JaAsqhW8ykwjkRKvPtItP6aFYCTK1xnkaq4pOTS
4wgoMdkh5FYd2zo5HxKvpTxRNLDrUZaEteMl+hG0v91T7fupwGznTVtXcKe2vtzd
8cKRi74f6KhdALUdkCwf1XmV7hETbEEh6Oj+v6Tw+rhPqSBbBT4ZfPQurGuUKOvm
/8R5Om8QTzJdNXWwrK8YML7tKbgNsxgut6K8gsJ6CsEqaF42uOxd9x68J/JtX7mu
bXJNFnlU+erzbs1WP2GvvHaALzZVIjjdMoKlhXsxNf4IQ7T4C54iiuVpgo5bjZlf
5/Sd1j/YrNE7zR98TwB9Z5Xl5qEh5zEhNB69I1UwX4EvMuH2gVM=
=ze0C
-----END PGP SIGNATURE-----

--IyZ6Zl0QXwFKJJtkv0gkPoTYKwVysirY7--