On 2026/11/04 23:36, Eric Botcazou wrote: >> Hi, below is a long existing patch in MSYS2's MINGW GCC, and I'm upstreaming >> it because I think it's actually needed by all Windows targets, not only >> MSYS2 / mingw-w64. > > No, it's actually needed by none of them, since GNU ld can directly link to > DLLs, see the GNU ld manual section 6.15 for a complete exposition, and we do > not use dllimport/dllexport decoration in Ada. >
I've just read the manual, and I think import library is still needed here. According to the manual, directly link to DLL is possible, but usually not easy to use under Cygwin/MSYS2, because: 1. GCC only adds -L<path>/lib by default, while DLLs are usually placed under <path>/bin, so you have to manually add a -L for this. 2. DLLs are usually versioned, so you can't use -lfoo, but have to use, e.g. -lfoo-17 Regarding 2, I think we can slightly edit the original patch and remove $(LIBRARY_VERSION) from import lib, so that we got libgnat.dll.a instead of libgnat-17.dll.a, and users can easily link with -lgnat. Below is a fixup patch. --- >From 8dea423acf74a67cdf7b758097fe9e0744c8c63c Mon Sep 17 00:00:00 2001 From: Zhongteng Gui <[email protected]> Date: Wed, 4 Nov 2026 23:57:17 +0800 Subject: [PATCH] ada: Make import lib unversioned This alignes with other import libraries, and allows users to use -lgnat instead of -lgnat-17 for linking. Fixes r17-5944-gcfb2e0e8e9d7c5. gcc/ada/ChangeLog: * gcc-interface/Makefile.in (gnatlib-shared-win32): Remove $(LIBRARY_VERSION) from import lib. Signed-off-by: Zhongteng Gui <[email protected]> --- gcc/ada/gcc-interface/Makefile.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/ada/gcc-interface/Makefile.in b/gcc/ada/gcc-interface/Makefile.in index 6a91f12a7bd..6e6fa7ec0a2 100644 --- a/gcc/ada/gcc-interface/Makefile.in +++ b/gcc/ada/gcc-interface/Makefile.in @@ -798,14 +798,14 @@ gnatlib-shared-win32: -o libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \ $(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS) \ $(SO_OPTS)libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \ - -Wl,-out-implib,libgnat$(hyphen)$(LIBRARY_VERSION).dll.a \ + -Wl,-out-implib,libgnat.dll.a \ $(MISCLIB) cd $(RTSDIR); $(GCC_FOR_ADA_RTS) -shared -shared-libgcc \ $(PICFLAG_FOR_TARGET) \ -o libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \ $(GNATRTL_TASKING_OBJS) \ $(SO_OPTS)libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \ - -Wl,-out-implib,libgnarl$(hyphen)$(LIBRARY_VERSION).dll.a \ + -Wl,-out-implib,libgnarl.dll.a \ $(THREADSLIB) -Wl,libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) gnatlib-shared-darwin: -- 2.56.0.windows.4
