Hi Jonathan,

On Tue, 13 Jul 2021, Jonathan Marler wrote:

The problem here appears to be the inclusion of
`__attribute__((__gnu_inline__))` which is what
tells the compiler NEVER to emit the function definition.  Removing this
attribute allows the compiler
to emit the function which allows its address to be taken, and prevents
linker errors if the compiler
decides not to inline a call to it.

Note that this applies to multiple functions in the ws2 header files.

Signed-off-by: Jonathan Marler <[email protected]>
---
mingw-w64-headers/crt/_mingw.h.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mingw-w64-headers/crt/_mingw.h.in b/mingw-w64-headers/crt/_
mingw.h.in
index b7fb99f42..002079910 100644
--- a/mingw-w64-headers/crt/_mingw.h.in
+++ b/mingw-w64-headers/crt/_mingw.h.in
@@ -87,7 +87,7 @@ limitations in handling dllimport attribute.  */
# define __CRT_INLINE __inline
#else
# if ((__MINGW_GNUC_PREREQ(4, 3) || defined(__clang__)) &&
__STDC_VERSION__ >= 199901L)
-#  define __CRT_INLINE extern inline __attribute__((__gnu_inline__))
+#  define __CRT_INLINE extern inline
# else
#  define __CRT_INLINE extern __inline__
# endif
--
2.25.4

Your analysis is certainly correct, but I think this particular fix affects more cases than really needed - __CRT_INLINE is used in lots of places, and I think many (or at least some) of them are such where an external definition actually exists, and the behaviour of only taking the address of the external definition, and inlining only when the compiler thinks it's worthwhile, is the desired one.

We've got a couple other defines for inline functions, I think __mingw_ovr might be one that is for inline functions where there doesn't exist any non-inline definition elsewhere. So it might be safer (or at least less disruptive) to just change individual functions, where we've checked that there's no corresponding external definition, to use that instead of flat out changing the macro affecting all of them.

// Martin



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

Reply via email to