> On 8 Jun 2026, at 14:07, Pietro Monteiro <[email protected]> wrote:
>
> Darwin uses .dylib as extension for libraries. Windows uses .dll, and
> sometimes doesn't prefix the library filename with "lib".
>
> Use those extensions when opening library files to search for imports
> on thoses OSes. Search for file with both the lib prefix and withouti
> on Windows.
>
> gcc/algol68/ChangeLog:
>
> * a68-imports.cc (a68_try_suffixes): Use .dylib suffix on Darwin.
OK from a Darwin PoV.
Iain
> Use .ddl suffix and optional lib prefix on Windows.
>
> Signed-off-by: Pietro Monteiro <[email protected]>
> ---
> gcc/algol68/a68-imports.cc | 30 ++++++++++++++++++++++++++++++
> 1 file changed, 30 insertions(+)
>
> diff --git a/gcc/algol68/a68-imports.cc b/gcc/algol68/a68-imports.cc
> index 8b77bbf0b76..e0fe87368e5 100644
> --- a/gcc/algol68/a68-imports.cc
> +++ b/gcc/algol68/a68-imports.cc
> @@ -365,6 +365,35 @@ a68_try_suffixes (std::string *pfilename)
>
> const char* basename = lbasename (pfilename->c_str());
> size_t basename_pos = basename - pfilename->c_str ();
> +
> +#if defined (__APPLE__)
> + /* Macos uses .dylib as extension for libraries. */
> + filename = pfilename->substr (0, basename_pos) + "lib" + basename +
> ".dylib";
> + fd = open (filename.c_str (), O_RDONLY | O_BINARY);
> + if (fd >= 0)
> + {
> + *pfilename = filename;
> + return fd;
> + }
> +#elif defined (_WIN32)
> + /* Windows uses .dll. Maybe prefixed with lib. */
> + filename = pfilename->substr (0, basename_pos) + "lib" + basename + ".dll";
> + fd = open (filename.c_str (), O_RDONLY | O_BINARY);
> + if (fd >= 0)
> + {
> + *pfilename = filename;
> + return fd;
> + }
> + /* Maybe not prefixed with lib. */
> + filename = pfilename->substr (0, basename_pos) + basename + ".dll";
> + fd = open (filename.c_str (), O_RDONLY | O_BINARY);
> + if (fd >= 0)
> + {
> + *pfilename = filename;
> + return fd;
> + }
> +#else
> + /* Other supported systems use .so. */
> filename = pfilename->substr (0, basename_pos) + "lib" + basename + ".so";
> fd = open (filename.c_str (), O_RDONLY | O_BINARY);
> if (fd >= 0)
> @@ -372,6 +401,7 @@ a68_try_suffixes (std::string *pfilename)
> *pfilename = filename;
> return fd;
> }
> +#endif
>
> filename = pfilename->substr (0, basename_pos) + "lib" + basename + ".a";
> fd = open (filename.c_str (), O_RDONLY | O_BINARY);
> --
> 2.43.0
>