The effect of `_MINGW_ASM_CALL` is exactly what I meant by "affecting 
applications". The point of the patch is to make sure that references to 
`str[n]casecmp` are not replaced with `_str[n]icmp`. If there is another 
library which provides external `str[n]casecmp` on the linker's command line, 
it will end up using definition in that library instead of one from CRT import 
library.

Here's output from clang when I'm building tests for my posx32 library, which 
provides it own declaration of `strcasecmp`:

```
In file included from 
F:/posix32/lib/posix32-crt/tests/wstring/wcscasecmp/compat.c:29:
In file included from F:/posix32/lib/posix32-crt/tests/include/string-test.h:20:
In file included from F:/posix32/lib/posix32-crt/include/tests-internal.h:23:
In file included from F:/posix32/lib/posix32-crt/include/string-internal.h:21:
F:/posix32/include/posix32/p32_strings.h:58:15: warning: attribute declaration 
must precede definition [-Wignored-attributes]
   58 | P32_CRT_DECL (P32_DECL) int __cdecl P32_FUNCNAME (strcasecmp) (const 
char *, const char *);
      |               ^
F:/posix32/include/posix32/posix32-decl.h:45:30: note: expanded from macro 
'P32_DECL'
   45 | #define P32_DECL __declspec (dllimport)
      |                              ^
E:/Msys2/ucrt64/include/string.h:131:28: note: previous definition is here
  131 |   __CRT_INLINE int __cdecl strcasecmp (const char *__sz1, const char 
*__sz2) { return _stricmp (__sz1, __sz2); }
      |                            ^
```

Honestly, I'm not sure if clang ends up generating calls to external 
`strcasecmp` or inlined calls to _stricmp.

You may also see that library's declarations are pretty *unusual*, which is 
required to handle all cases such as linking against static version of the 
library, when it cannot provide standard functions with their real names, since 
it can result in multiple definition error when using static version of CRT 
(with MSVC, for example).

- Kirill Makurin

________________________________
From: LIU Hao
Sent: Friday, December 19, 2025 6:12 PM
To: [email protected]; Kirill Makurin; Pali Rohár
Subject: Re: [Mingw-w64-public] Remove inline definitions of str[n]casecmp from 
string.h

在 2025-12-18 22:19, Kirill Makurin 写道:
> I wonder if adding _MINGW_ASM_CALL will or will not affect applications which 
> want to define/declare their own str[n]casecmp function? I don't know how 
> such renames interact with redeclarations.

`_MINGW_ASM_CALL` changes the symbol of a function, so if a user calls 
`strcasecmp`, the compiler calls
`_stricmp` instead. (Clang also attempts to inline the new target, but GCC 
doesn't do that.)

But it's not the same for these functions. If a user calls `strcasecmp`, the 
compiler just calls
`strcasecmp`. The CRT library defines both `strcasecmp` and `_stricmp`, which 
resolve to the same
function when the DLL is loaded.

I'll push this change after the CI passes.


--
Best regards,
LIU Hao

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to