1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-29 19:30:36 +02:00

Improve DLL search strategy for load-foreign-library

The new non-libltdl foreign library loading algorithm from 3.0.6
fails to cover common cases regarding how libtool names and installs
DLL files.  Notably, it fails to recognize when libtool has added the
major version number into the filename itself, such as libfoo-1.dll
Also, it does not search in binary directories and the PATH for DLL
files, where libtool is likely to install DLLs.

This adds the option to search for dlls with major version numbers
in the filename, and modifies the search strategy for DLL-using
OSs to check bindir and PATH.

For MSYS, libraries are installed with the 'msys-' prefix. So this
modifies load-foreign-library to handle that prefix as well.
It changes the #:rename-on-cygwin? option to #:host-type-rename? to
better reflect that is works on both Cygwin and MSYS.

Partially based on a patch by Hannes Müller.

* NEWS: updated
* doc/ref/api-foreign.texi: document updates to load-foreign-library
  and system-dll-path
* module/system/foreign-library.scm (is-integer-string?): new utility function
  (dll-name-match?): new utility function
  (find-best-dll-from-matches): new utility function
  (dll-exists-with-version): new function that implements new dll search logic
  (file-exists-with-extension): add flag argument to allow new dll search
  (file-exists-in-path-with-extension): add flag argument to all new dll search
  (system-dll-path): new parameter
  (lib->msys): new helper function
  (load-foreign-library): add new optarg flag #:allow-dll-version-suffix?
    Pass new flag to library search functions.
    Implement new search strategy for #:search-system-paths? on DLL systems'
    replace #:rename-on-cygwin? with #:host-type-rename?
        Use that option to rename both MSYS and Cygwin libraries.
  (guile-system-extensions-path): prefer bindir to libdir on DLL systems
* test-suite/tests/foreign.test ("dll-name-match?"): new test category
  ("find-best-dll-from-matches"): new test category
  ("lib->msys"): new unit tests
This commit is contained in:
Michael Gran 2024-12-25 09:41:08 -08:00
parent c9a19a03f8
commit 7b41294049
4 changed files with 346 additions and 109 deletions

15
NEWS
View file

@ -261,6 +261,21 @@ binary-port) used to be implemented in C, making it non-suspendable--a
bummer for programs using suspendable ports and Fibers. It has been
rewritten in Scheme, addressing this limitation.
** improve 'load-foreign-library' handling of DLLs
The non-libltdl load-foreign-library introduced in 3.0.6 does not handle
some common cases with libtool-generated DLLs. It has been updated
to search for DLLs that have a version number appended to the name
by libtool, such as libfoo-1.dll.
Also, it has been updated to do library renaming for MSYS. On Cygwin,
when the #:rename-on-cygwin? option is #t, it already had the capability
to search for "libfoo" as "cygfoo.dll". It has been updated to add the
capability to search for "libfoo" as "msys-foo.dll" on MSYS.
The load-foreign-library option #:rename-on-cygwin? has been changed to
#:host-type-rename?, and handles both Cygwin and MSYS.
* Performance improvements
** Better compilation of calls to procedures with keyword arguments