1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-03 18:50:19 +02:00
Commit graph

21369 commits

Author SHA1 Message Date
Michael Gran
1d1fde4ba1 Prefer LTLIBGNU to gnulib_library in Makefile.am 2025-03-30 18:51:27 -07:00
Michael Gran
decd4d25b9 explicitly add the gnulib library in LD_ADD 2025-03-30 18:51:20 -07:00
Michael Gran
08e1876d71 Add compiled guile-tools program
For systems that do not have a posix shell.

* configure.ac (GUILE_TOOLS_EXE): new conditional
* libguile/Makefile.am (guile-tools)[GUILE_TOOLS_EXE]: new binary target
* libguile/guile-tools.c: new file
* meta/Makefile.am (guile.scm): new data
  [!GUILE_TOOLS_EXE](install-exec-hook): don't alias guile-tools to guild
  (CLEANFILES): add guild.exe
2025-03-30 18:50:51 -07:00
Michael Gran
9ae3069437 In posix test, skip AT_SYMLINK_NOFOLLOW test if symlinks unsupported
* test-suite/tests/posix.test ("AT_SYMLINK_NOFOLLOW"): skip if unsupported
2025-03-30 18:40:55 -07:00
Michael Gran
7aa3b482fb In posix test, skip ttyname test if not supported
* test-suite/tests/posix.test ("ttyname"): skip if unsupported
2025-03-30 18:40:37 -07:00
Michael Gran
e33dd7bfd8 In i18n test, modify locale testing to focus on UTF-8
fr_FR was mostly being tested as an 8-bit locale.  This changes
the tests to focus on fr_FR.utf8.  But it adds a section for fr_FR 8-bit
currency.  Divergence in vendor-supplied locales often occurs
in currency.

MINGW, which only handles 8-bit locales when using MSVCRT, was being tested
as if its 8-bit CP1252 locale was UTF-8.  While the tests were included
as better than nothing, it is technically incorrect. These tests are
no longer run. Soon, Guile's MINGW build will link to UCRT, and it will
have UTF-8 locales.

The responses for some tests were modified to allow reasonable responses
from Cygwin/MSYS/MinGW locales and to skip on unreasonable responses.

* test-suite/tests/i18n.test (mingw?): rename to old-ms?
  (old-ms?): new helper
  (%french-locale-name): use platform's default 8-bit locale
  (%french-utf8-locale-name, %turkish-utf8-locale-name, %german-utf8-locale-name)
  (%greek-utf8-locale-name): don't use 8-bit locales on MINGW
  ("text collation (French)"): use utf-8
  ("locale-digit-grouping (French)"): use utf-8
  (french-number-string=?): modify to make symmetric and to handle
     U+2024 as a valid spacer
  ("French: integer", "negative integer" "fraction", "fraction, 1 digit"):
  ("French"): rename to "French UTF-8"
  ("French UTF-8: 12345.678", "Fraction"): use utf-8, allow U+2024
  ("French UTF-8: positive inexact zero"): expect euro sign
  ("French 8-bit"): new currency tests
2025-03-30 18:39:31 -07:00
Michael Gran
1e0cf93a0a handle different errors messages for unbound variables 2025-03-30 18:33:23 -07:00
Michael Gran
993ac2fd74 Modify http header parser to use new read-line "\r\n" handling
* module/web/http.scm (read-header-line): modify for new read-line
2025-03-30 18:32:02 -07:00
Michael Gran
9bb8793a6c Allow read-line to handle "\r\n" as a line terminator
Adds CRLF as a line ending. %read-line will return
these. In the case of CRLF, %read-line will return a string "\r\n"
as the line ending.

* libguile/rdelim.c (scm_read_line): handle CRLF line delimiter
* module/ice-9/suspendable-ports.scm (%read-line): modify to handle CRLF
    line delimiter
  (read-line): use modified %read-line
* test-suite/tests/rdelim.test ("two lines, split, CRLF"): new test
   ("two long lines, split, CRLF"): new test
* doc/ref/api-io.texi: update read-line documentation
2025-03-30 18:31:36 -07:00
Michael Gran
8d388c97e7 Add option to disable time limit in eval-in-sandbox
On systems without SIGALRM, the other features of eval-in-sandbox
may still be useful.  This adds the option to set #:time-limit to
#f to indicate no timeout.

* NEWS: updated
* module/ice-9/sandbox.scm (eval-in-sandbox): allow #:time-limit key
    to be #f to disable time limit
* doc/ref/api-evaluation.texi (eval-in-sandbox): update documentation
* test-suite/tests/sandbox.scm ("eval-in-sandbox"): throw unsupported
    if no SIGALARM
  ("eval-in-sandbox no timeout"): new tests for eval-in-sandbox
2025-03-30 18:30:09 -07:00
Michael Gran
68af1c93e7 In i18n test, add more reasonable test passes for french currency
* test-suite/tests/i18n.test ("french utf-8: number" "fraction"):
  ("positive inexact zero", "one cent", "very little money"): more
    success and failure conditions
2025-03-30 18:27:47 -07:00
Michael Gran
c8e0454692 WIN32: new internal define %UCRT when compiled with UCRT C library
This variable will help indicate if, on Win32, the C library is
closer to C99 capable.

* libguile/posix.c (scm_init_posix): new define %UCRT
* test-suite/tests/i18n.test (old-ms?): use new define allow UTF-8
    tests on MINGW
2025-03-30 18:25:41 -07:00
Michael Gran
0f748b32aa Avoid writing nulls in check-guile.log
Null characters in check-guile.log confuse grep.

* test-suite/tests/strings.test ("string-utf8-length"): add test names
* test-suite/tests/web-uri.test ("encode"): add test names
2025-03-30 18:20:36 -07:00
Michael Gran
153be2e6a5 In web-server test, skip server test if no threads provided
* test-suite/tests/web-server.test ("server is listening"): skip if no threads
2025-03-30 18:19:36 -07:00
Michael Gran
ba4939e31f MINGW: in ports test, use binary mode for line counter tests
The line counter tests presumes newline-only line endings.  Use binary
mode to avoid CRLF endings.

* test-suite/tests/ports.test ("line endings"): write test file in binary
    mode
2025-03-30 18:19:02 -07:00
Michael Gran
1838ef8ef6 In ports.test, convert some pass-if tests to pass-if-equal
* test-suite/tests/ports.test ("line counter"): convert several tests to
    use pass-if-equal
2025-03-30 18:18:20 -07:00
Michael Gran
50371bc6ed Replace SCM_INLINE_GC_KIND_* enums with libgc's GC_I_* defines
Guile has an enum scm_inline_gc_kind used to replace GC constants
that were private.  Those defines were made public in 2015, so it
is should be safe to use them now.

Replace SCM_INLINE_GC_KIND_POINTERLESS with GC_I_PTRFREE.
Replace SCM_INLINE_GC_KIND_NORMAL with GC_I_NORMAL.

* libguile/gc-inline.h (scm_inline_gc_kind): remove type
  (scm_inline_gc_alloc): kind argument is now int
  (scm_inline_gc_malloc_pointerless): use GC_I_PTRFREE
  (scm_inline_gc_malloc): use GC_I_NORMAL
* libguile/intrinsics.c (allocate_words_with_freelist): use GC_I_NORMAL
  (allocate_pointerless_words): use GC_I_PTRFREE
2025-03-30 18:13:03 -07:00
Michael Gran
c214a15e47 libgc's GC_REDIRECT_TO_LOCAL is obsolete.
Removed in v7.2g in 2016.

* libguile/bdw-gc.h (GC_REDIRECT_TO_LOCAL): remove
2025-03-30 18:12:52 -07:00
Michael Gran
5d4373248f allow webserver to run when SIGPIPE not defined
* module/web/server/http.scm (http-open): only set SIGPIPE sigaction when
    SIGPIPE is defined.
2025-03-30 18:12:32 -07:00
Michael Gran
69e1f96a93 Win32: don't setjmp to Guile frames
For 64-bit Windows, there was an existing special setjmp handling
to avoid jumping into Guile frames.  Expand this handling to 32-bit
Windows as well.

*
2025-03-30 18:11:03 -07:00
Michael Gran
4cac137b01 Lightening: _WIN32 updates from upstream lightning
Pulls in a few updates for WIN32 from upstream GNU lightning.
Based on patches from GNU Lightning.
2025-03-30 18:10:58 -07:00
Michael Gran
0b70769247 Win32: add replacement for mkdtemp
* libguile/posix-w32.c (mkdtemp): new win32 replacement procedure
* libguile/posix-w32.h: add declaration for mkdtemp
  (HAVE_MKDTEMP): new define
* libguile/filesys.c: include posix-w32.h
2025-03-30 18:10:48 -07:00
Michael Gran
c08debbd39 In lightening, don't use visibility hidden on DLL using systems
* libguile/lightening/lightening.h
  [!_WIN32 && !__CYGWIN__] (JIT_API): don't define to visiblity hidden
2025-03-30 18:10:35 -07:00
Michael Gran
faa6b8cf82 WIN32: use GCC builtin ffs to replace missing function
FFS is missing on MINGW.

* libguile/lightening/lightening/x86-cpu.c
  [__GNUC__ && _WIN32](USE_BUILTIN_FFS): new macro
  (__ffs): wrapper function
  (ffsw): use __ffs;
2025-03-30 18:10:30 -07:00
Michael Gran
2177f3f6c5 filesys.test: fixes for copy-file test on MinGW
In the copy-file test, is uses call-with-input-file and get-string-all
to retrieve file contents. Since the file is not opened in binary mode,
CRLF line ending may be added when writing and then reading the string
back from the filesystem.

* test-suite/tests/filesys.test (normalize-newlines): new helper function
  ("copy file: copy-file dest content"): pass even if CRLF line endings
  are added
  ("copy file: read only dest"): handle posibility of geteuid not
  being defined
2025-03-30 18:10:24 -07:00
Michael Gran
6b4d829d40 in filesys test, add helper function for deleting files and symlinks
On Windows, a file needs to have write permission to be deleted.
This adds a helper to handle that case, but, is used generally.

* test-suite/tests/filesys.test (%delete-file): new helper function
  Replace every delete-file call with %delete-file.
2025-03-30 18:10:16 -07:00
Michael Gran
cc1c79ae34 In test suite, ensure file ports are closed before deletion
On Windows, open file ports cannot be deleted.

* test-suite/tests/ports.test ("relative canonicalization with common prefixes"):
    close port before deletion
* test-suite/tests/posix.test (utime-unless-unsupported): take a port arg
  ("file port"): use new utime-unless-unsupported. Close port before deletion.
* test-suite/tests/filesys.test ("port representing a regular file"):
    throw unsupported before creating file
2025-03-30 18:10:07 -07:00
Michael Gran
1174e1eb9d Allows modification of shell used by open-pipe
open-pipe executes a shell command in a subprocess. This commit adds
the ability to modify the shell used for executing commands.
The default "/bin/sh -c" can be inspected and modified by the
new procedure-with-setter 'pipe-shell-command-transformer'.

This useful in MinGW since its "sh" is not in "/bin".

* module/ice-9/popen.scm (%command-transformer): new procedure
  (pipe-shell-command-transformer): new procedure-with-setter
  (open-pipe): use new command transformer
* doc/ref/posix.texi (open-pipe): mention pipe-shell-command-transformer
  (pipe-shell-command-transformer): document new procedure
* test-suite/tests/popen.test ("pipe-shell-command-transformer"): new tests
  Also, modify open-pipe shell for MinGW
* NEWS: updated
* test-suite/tests/ports.test (mingw?): new variable
    Also, modify open-pipe shell for MinGW
2025-03-30 18:09:37 -07:00
Michael Gran
9d625278f7 fixes for chmodat test
* test-suite/tests/filesys.test (chmodat): some chmodat tests don't test if it
   exists. Mark unwritable file writable before deleting.
  ("port representing a regular file"): reorder to avoid unclosed
     port on exception.
2025-03-30 18:02:21 -07:00
Michael Gran
afda13e4ac For MinGW, use native signal func in sigaction
For MinGW, there is a native signal function in UCRT. It handles
a limited set of signals.

* libguile/scmsigs.c (scm_sigaction_for_thread)[__MINGW32__]: removed
  (scm_sigaction_for_thread)[!__MINGW32__]: use for MinGW as well.
    For signals outside UCRT's native signal set, always return SIG_IGN.
2025-03-30 18:02:02 -07:00
Jan (janneke) Nieuwenhuizen
70f434111b guix: Add guile-patched, guile-mingw.
Build it:

    GUIX_PACKAGE_PATH=guix guix build --target=x86_64-w64-mingw32 guile-mingw

Run it:

    WINEPATH=$(guix shell wine64 -- winepath -w                                     \
        $(echo $(guix gc -R                                                         \
                      $(GUIX_PACKAGE_PATH=guix guix build                           \
                                         --target=x86_64-w64-mingw32 guile-mingw))) \
                   | sed 's,$,/bin,g' | tr '\n' ';')                                \
            guix shell wine64 -- wine                                               \
            $(GUIX_PACKAGE_PATH=guix guix build --target=x86_64-w64-mingw32         \
                               guile-mingw)/bin/guile.exe                           \
            -c '(format #t "Hello  ~a world!\n" %host-type)'

* guix/guile-patched.scm,
guix/mingw.scm: New files.
2025-03-30 18:01:15 -07:00
Rutger van Beusekom
12ad1a9ad2 DRAFT Add partial `scm_fcntl' support for MinGW.
* libguile/filesys.c (_mingw_debug_p)[__MINGW32__: New function.
(scm_fcntl)[__MINGW32__]: Add support creating non-blocking sockets.
2025-03-30 17:59:44 -07:00
Jan (janneke) Nieuwenhuizen
2b86a3b1cb Add `scm_sigaction_for_thread' stub for MinGW.
* libguile/scmsigs.c (scm_sigaction_for_thread)[__MINGW32__]: New stub.
(SIGHUP, SIGPIPE)[__MINGW32__]: New defines.
2025-03-30 17:59:38 -07:00
Jan (janneke) Nieuwenhuizen
eaa38d6381 Install 'mingw_take_signal' on MinGW.
After installing a signal handler, these are handled

    * C-c
    * kill -SIGINT <guile.exe-pid> (the wine process) works

these result in a direct terminate (or kill even?)

    - kill <guile.exe-pid>
    - wine cmd /c guile -c '(kill <guile-exe.pid> SIGINT)'
    - wine cmd /c guile -c '(kill <guile-exe.pid> SIGTERM)'

* libguile/scmsigs.c (mingw_take_signal)[__MINGW32__]: New function.
install_mingw_take_signal)[__MINGW32__]: New function.
(scm_init_scmsigs)[__MINGW32__]: Use it.
2025-03-30 17:59:22 -07:00
Jan (janneke) Nieuwenhuizen
b55397ea5d Make `read-bytes' suspendable for socket reads on MinGW.
On MinGW, port-read will block on sockets if no data is available.
Avoid blocking by using select first.

* module/ice-9/suspendable-ports.scm (read-bytes): For socket ports,
guard port-read with select.
2025-03-30 17:59:11 -07:00
Jan (janneke) Nieuwenhuizen
a043eaf349 Support for x86_64-w64-mingw32.
On x86-64-MinGW the size of long is 4.  As long is used for
SCM_FIXNUM_BIT, that would mean incompatible .go files, and waste of
cell space.  So we would like to use long long, but the GMP interface
uses long.

To get around this, the x86-64-MinGW port now requires the use of
mini-GMP.  Mini-GMP has been changed to use intptr_t and uintptr_t.

Likewise, "integers.{h,c}" and "numbers.{h,c}" now use intptr_t instead
of scm_t_inum or long, and uintptr_t instead of unsigned long.

* configure.ac: When x86_64-w64-mingw32, require mini-GMP.
* libguile/mini-gmp.h: Use intptr_t instead of long, uintptr_t instead
of unsigned long throughout.
* libguile/mini-gmp.c: Likewise.
* libguile/scm.h (SCM_INTPTR_T_BIT): New define.
* libguile/numbers.h (SCM_FIXNUM_BIT): Use it.
* libguile/numbers.c (L1, UL1): New macros.  Use them thoughout instead
of 1L, 1UL.
(verify): Use SCM_INTPTR_T_BIT.
(verify): Use SCM_INTPTR_T_MAX and SCM_INTPTR_T_MIN.
(scm_from_inum): Remove macro.
Use intptr_t and uintptr_t instead of scm_t_inum or long, and unsigned
long.
* libguile/numbers.h (scm_from_intptr, scm_from_uintptr, scm_to_intptr,
scm_to_uintptr): New defines.
* libguile/integers.h: Use intptr_t and uintptr_t instead of scm_t_inum
and unsigned long.
* libguile/integers.c (L1) : New macro.  Use it thoughout instead of 1L.
Use intptr_t and uintptr_t instead of long and unsigned long.
(long_magnitude): Rename to...
(intptr_t_magnitude): ...this.  Use intptr_t, uintptr_t.
(negative_long): Rename to...
(negative_t_intptr): ...this.  Use uintptr_t, INTPTR_MIN.
(inum_magnitude): Use intptr_t.
(ulong_to_bignum): Rename to...
(uintptr_t_to_bignum): ...this.  Use uintptr_t.
(long_to_bignum): Rename to...
(intptr_t_to_bignum): ...this.  Use intptr_t.
(long_to_scm): Rename to...
(intptr_t_to_scm): ...this.  Use intptr_to_bignum.
(ulong_to_scm): Rename to...
(uintptr_t_to_scm): ...this.  Use uintptr_to_bignum.
(long_sign): Rename to..
(intptr_t_sign): ...this.  Use SCM_SIZEOF_INTPTR_T.
(bignum_cmp_long): Rename to...
(bignum_cmp_intptr_t): ...this.  Use uintptr_t.
* libguile/array-map.c (array_compare): Use uintptr_t instead of
unsigned long and intptr_t instead of long.
* libguile/arrays.c (make-shared-array): Use ssize_t instead of long.
* libguile/bytevectors.c (is_signed_int32, is_unsigned_int32)
[MINGW32 && __x86_64__]: Use ULL.
(twos_complement): Use uintptr_t instead of unsigned long.
* libguile/hash.c (JENKINS_LOOKUP3_HASHWORD2): Likewise.
(narrow_string_hash, wide_string_hash, scm_i_string_hash,
scm_i_locale_string_hash, scm_i_latin1_string_hash,
scm_i_utf8_string_hash, scm_i_struct_hash, scm_raw_ihashq,
scm_raw_ihash): Use and return uintptr_t instead of unsigned long.
(scm_hashv, scm_hash): Use SCM_UINTPTR_T_MAX.
* libguile/hash.h (scm_i_locale_string_hash, scm_i_latin1_string_hash,
scm_i_utf8_string_hash): update prototypes.
* libguile/scmsigs.c (sigaction): Use intptr_t instead of long.
* libguile/strings.c (scm_i_make_symbol, (scm_i_c_make_symbol): Use
uintptr_t instead of unsigned long.
* libguile/strings.h (scm_i_make_symbol, (scm_i_c_make_symbol): Update
declacations.
* libguile/srfi-60.c: Use scm_to_uintptr, scm_from_intptr and variants
throughout.
* libguile/symbols.c (symbol-hash): Use scm_from_uintptr.

Co-authored-by: Mike Gran <spk121@yahoo.com>
Co-authored-by: Andy Wingo <wingo@pobox.com>
2025-03-30 17:57:12 -07:00
Jan (janneke) Nieuwenhuizen
5caf66a51a Add 'set-port-binary/text-mode!' procedure for MinGW.
* libguile/ports.c (scm_init_ports)[O_BINARY]: Define 'O_BINARY'.
[O_TEXT]: Define 'O_TEXT'.
(scm_c_set_port_binary_text_mode_x): New function.
* libguile/ports.h (scm_set_binary_text_mode_x): Declare it.
* module/ice-9/ports.scm (ice-9): Export it as
'set-port-binary/text-mode!'.
* doc/ref/api-io.texi (File Ports): Document it.
2025-03-30 16:38:05 -07:00
Jan (janneke) Nieuwenhuizen
a3018d6d0e mingw: canonicalize-path: Also canonicalize drive letter and '/'.
* libguile/posix-w32.c (canonicalize_device_name,
slashify_file_name): New static functions.
(canonicalize_file_name_mingw): Use them in new function.
* libguile/posix-w32.h (canonicalize_file_name_mingw): Declare it.
(canonicalize_file_name): New define.
* libguile/filesys.c[__MINGW32__]: Include posix-w32.h to use it.
* libguile/fports.c[__MINGW32__]: Likewise.
2025-03-30 16:38:00 -07:00
Jan (janneke) Nieuwenhuizen
79ea1082d0 Link fix for MinGW.
This fixes

    libguile/threads.c:1502: undefined reference to `select_used_without_including_sys_select_h'

* libguile/threads.c: Include sys/select.h.
2025-03-30 16:34:17 -07:00
Michael Gran
af96820e07 Windows 11: for fport input from the console, ignore terminal returns
There is an apparent bug in Windows 11 (not Windows 10) where,
when reading from an fd backed by the Console, a single
return character will always be available.

* libguile/posix-w32.c (console_has_return_keyevent_w32): new procedure
* libguile/posix-w32.h: declare console_has_return_keyevent_w32
* libguile/fports.c [__MINGW32__](fport_input_waiting): ignore return keyevent
2025-03-23 10:26:40 -07:00
Michael Gran
adbf2156ab Remove posix-w32 subsitutes that require access to process handles
Now that Guile uses the posix_spawn gnulib module, several of Guile's
custom w32 functions substitutes no longer work. Some functions
relied on populating and maintaining an internal PID-to-Handle database,
which is no longer possible.

kill, getpriority, setpriority, getaffinity and setaffinity
are removed. waitpid is simplified and does not handle ENOHANG.

* NEWS: updated
* libguile/posix-w32.c (struct proc_record, find_proc, proc_handle): removed
  (record_proc, delete_proc, prepare_child_handle, compenv): removed
  (prepare_envblk, lookup_cmd, prepare_cmdline, start_child): removed
  (kill, getpriority, setpriority, sched_getaffinity): removed
  (sched_setaffinity): removed
  (waitpid): modified to just use _cwait. ENOHANG emlation removed.
* libguile/posix-w32.h (CPU_ZERO, CPU_ISSET, CPU_SET, CPU_SETSIZE): removed
  (cpu_set_t, PRIO_PROCESS, PRIO_PGRP, PRIO_USER): removed
  (HAVE_START_CHILD, HAVE_KILL, HAVE_GETPRIORITY): removed
  (HAVE_SETPRIORITY, HAVE_SCHED_GETAFFINITY, HAVE_SCHED_SETAFFINITY): removed
  declarations for waitpid, start_child, kill, getpriority: removed
  declarations for setpriority, sched_getaffinity, sched_set_affinity: Removed
2025-03-22 21:57:59 -07:00
Michael Gran
2e51d3fa26 In piped_process, replace dprintf with more portable functions
dprint is missing on many non-glic platforms

* libguile/posix.c (piped_process): replace dprintf with sprintf+write
2025-03-22 21:33:33 -07:00
Michael Gran
9c86c5936e Allow piped-process and system* to exist when fork is undefined
piped-process only uses fork to match legacy behavior, but on systems
that never had fork, there is no need to match that behavior.
piped-process and system* can be provided without fork.

* libguile/posix.c (piped_process): allow function definition without HAVE_FORK,
    but stub out internal dummy process with HAVE_FORK
  (restore_sigaction, scm_dynwind_sigaction, scm_system_star): don't
    require HAVE_FORK
  (scm_init_popen): don't require HAVE_FORK
  (scm_init_posix): don't require HAVE_FORK to add posix feature or
    register popen extension
2025-03-22 21:32:45 -07:00
Michael Gran
87402c849e MinGW32: cast arguments to execvp
MinGW32's MSVCRT library requires strict casting for exec family functions

* libguile/posix.c (scm_execl, scm_execlp, scm_execle) [__MINGW32__]: cast
  arguments
2025-03-22 21:02:42 -07:00
Michael Gran
0f2125e66f Add missing #include in syscalls.h
SCM_SYSCALL uses scm_async_tick.

* libguile/syscalls.h: include async.h
2025-03-22 14:17:41 -07:00
Michael Gran
0e20c0c8c6 Add replacement for missing getpagesize() on MINGW
* libguile/posix-w32.c (getpagesize_w32): new procedure
* libguile/posix-w32.h: declaration of getpagesize_w32
* libguile/loader.c [__MINGW32__](scm_bootstrap_loader): use new procedure
* libguile/vm.c [__MINGW32__](scm_i_vm_prepare_stack): use new procedure
2025-03-22 14:17:30 -07:00
Michael Gran
0b9f58c339 Fix NEWS for load-foreign-library
NEWS update was in wrong location. This fixes news entry
from 7b41294049

* NEWS: update
2025-03-22 11:31:24 -07:00
Michael Gran
7b41294049 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
2025-03-22 07:05:31 -07:00
Michael Gran
c9a19a03f8 Cygwin/MSYS: 00-socket.test: abstract sockets are unsupported
Binding to AF_UNIX abstract sockets is not supported on Cygwin and
presumably MSYS as well.

* test-suite/tests/00-socket.text ("AF_UNIX abstract"): throw unsupported
  on Cygwin and MSYS
2025-03-22 06:42:21 -07:00
Michael Gran
73a8ca88fb ports.test: catch pipe errors
Refactors a couple of the ports tests to catch errors in the test runner,
so that the test suite will print ERROR on failure.

* test-suite/tests/ports.test (pipe:write, pipe:read): modified
2025-03-22 06:27:51 -07:00