https://gcc.gnu.org/g:b155cbf0535aa842ddeadf6475cac9f62d329227
commit r17-1513-gb155cbf0535aa842ddeadf6475cac9f62d329227 Author: Pietro Monteiro <[email protected]> Date: Fri Jun 12 08:09:16 2026 -0400 algol68: Use correct library file extension on darwin and windows Changes from v1: - Use TARGET_MACHO and TARGET_PECOFF guards instead of __APPLE__ and _WIN32. -- >8 - 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 those OSes. Search for file with both the lib prefix and without on Windows. gcc/algol68/ChangeLog: * a68-imports.cc (a68_try_suffixes): Use .dylib suffix on Darwin. Use .dll suffix and optional lib prefix on Windows. Signed-off-by: Pietro Monteiro <[email protected]> Diff: --- 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 8b77bbf0b76d..1d4bacec135c 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 TARGET_MACHO + /* 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 TARGET_PECOFF + /* 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);
