I am actually wrong. If we would pass -Wl and friends as is to clang.exe it would handle them correctly by itself.
Note: clang.exe installed with Visual Studio uses link.exe, just like cl.exe would.
Hi Ileana,
The fix seems incomplete.
See attached file for `libtool --mode=link` invocation with clang-cl. You may notice that the flag passed with -Wl is passed twice: once on its own (just like it was with cl.exe with the bug) and once properly with -Wl.
Do you think checking compiler's name is a good idea? AFAIK, all three of cl.exe, clang-cl.exe and icl.exe (MSVC-like compilers handled by Automake's `compile` wrapper) define _MSC_VER macro. If libtool does check, it should be at least consistent with `compile`
wrapper.
Maybe libtool could check during configuration whether compiler defines this macro to decide how to pass linker flags? Since `compile` wrapper should usually be involved, we need to just pass -Wl flags and friends as is, `compile` takes care of them.
There is one problematic case though. If we would use clang.exe installed with Visual Studio, this will not work. It defines _MSC_VER, but it usus gcc-like command line options.
- Kirill Makurin
From: Ileana Dumitrescu
Sent: Friday, May 30, 2025 2:24 AM
To: 74175-done@debbugs.gnu.org
Cc: Kirill Makurin
Subject: Re: bug#74175: libtool mishandles some compiler flags when used with MSVC tools
On 13/11/2024 21:59, Ileana Dumitrescu wrote:
> Hi Kirill,
>
> On 02/11/2024 09:17, Kirill Makurin wrote:
>> The encountered bugs are as follows:
>>
>> 1. When libtool is used with MSVC tools, libtool's link step
>> mishandles compiler flags like`-Wl` and `-Xlinker`. For example, `-
>> Wl,- def:FILENAME` becomes plain `-def:FILENAME` when libtool invokes
>> the compiler*. (as seen in make-msvc.txt)
This part of the bug report has a patch applied [1] in the development
branch now, which should migrate to master after some more time. MSVC
building and testing has greatly improved, so I will hopefully get
another stable release with these fixes out in a couple months.
[1]https://cgit.git.savannah.gnu.org/cgit/libtool.git/commit/?h=development&id=4ded381a6f09cb761a05403450b5e34fec945f5a
--
Ileana Dumitrescu
GPG Public Key: FA26 CA78 4BE1 8892 7F22 B99F 6570 EA01 146F 7354