On Tue, 1 Nov 2022, LIU Hao wrote:
在 2022/11/1 05:00, Martin Storsjö 写道:
https://reviews.llvm.org/D137073 should fix it (but it isn't merged yet).
Anyway, as for fixing the issue, we already have the situation where
__MINGW_FORTIFY_VA_ARG is defined to 0 on Clang (since it doesn't implement
__builtin_va_arg_pack()). The other instances that you're changing in this
patch, outside of the __MINGW_FORTIFY_VA_ARG blocks, shouldn't be strictly
necessary to change to fix the issue at hand - they're just changed for
consistency?
Oh thanks, wasn't familiar with Clang. And yes, the others were changed as I
thought they might be referenced (address taken) by someone in the future. As
a permanent solution it would be good to replace `static inline` with `extern
/GNU/ inline`.
So either we'd keep those as-is and just patch the cases within
__MINGW_FORTIFY_VA_ARG, or we can add extra conditionals and two
implementation alterantives of these functions too - e.g. something like
this:
.. Which alternative do you prefer?
Which function was it that caused errors in Clang?
Just had a quick glance. The only function that isn't protected by
`__MINGW_FORTIFY_VA_ARG` seems to be `vsnwprintf`, so probably it's fine to
keep `__mingw_bos_ovr` for it. (and it would be the only reference?)
No, the same applies for vsprintf, vsnprintf (twice in the patch) and
vsnwprintf.
Attached is a patch that goes on top of this, which reverts the parts
which should be strictly unnecessary (and currently are breaking Clang on
i386).
// Martin
From 1df6eab483b8dc35cd3ab8c26b395a4bcc1417a2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <[email protected]>
Date: Mon, 31 Oct 2022 13:23:09 +0200
Subject: [PATCH] Revert parts to unbreak Clang/i386
---
mingw-w64-headers/crt/_mingw_mac.h | 12 ++++++++----
mingw-w64-headers/crt/stdio.h | 16 ++++------------
2 files changed, 12 insertions(+), 16 deletions(-)
diff --git a/mingw-w64-headers/crt/_mingw_mac.h b/mingw-w64-headers/crt/_mingw_mac.h
index 63028e454..9734a052e 100644
--- a/mingw-w64-headers/crt/_mingw_mac.h
+++ b/mingw-w64-headers/crt/_mingw_mac.h
@@ -333,12 +333,16 @@
# define __mingw_bos_ptr_chk_warn(p, n, maxtype) \
(__mingw_bos_known(p) && __builtin_constant_p((n)) && __mingw_bos(p, maxtype) < (size_t)(n) \
? __mingw_chk_fail_warn() : __mingw_bos_ptr_chk(p, n, maxtype))
+# define __mingw_bos_ovr __mingw_ovr \
+ __attribute__((__always_inline__)) \
+ __mingw_attribute_artificial
+# define __mingw_bos_extern_ovr extern __inline__ __cdecl \
+ __attribute__((__always_inline__, __gnu_inline__)) \
+ __mingw_attribute_artificial
+#else
+# define __mingw_bos_ovr __mingw_ovr
#endif /* __MINGW_FORTIFY_LEVEL > 0 */
-#define __mingw_bos_extern_ovr extern __inline__ __cdecl \
- __attribute__((__always_inline__, __gnu_inline__)) \
- __mingw_attribute_artificial
-
/* If _FORTIFY_SOURCE is enabled, some inline functions may use
__builtin_va_arg_pack(). GCC may report an error if the address
of such a function is used. Set _FORTIFY_VA_ARG=0 in this case.
diff --git a/mingw-w64-headers/crt/stdio.h b/mingw-w64-headers/crt/stdio.h
index c08b45e6d..5042409a2 100644
--- a/mingw-w64-headers/crt/stdio.h
+++ b/mingw-w64-headers/crt/stdio.h
@@ -420,9 +420,7 @@ int vprintf (const char *__format, __builtin_va_list __local_argv)
return __mingw_vfprintf( stdout, __format, __local_argv );
}
-int vsprintf (char *__stream, const char *__format, __builtin_va_list __local_argv) __MINGW_ASM_CALL(__mingw_vsprintf);
-
-__mingw_bos_extern_ovr
+__mingw_bos_ovr
__attribute__((__format__ (gnu_printf, 2, 0))) __MINGW_ATTRIB_NONNULL(2)
int vsprintf (char *__stream, const char *__format, __builtin_va_list __local_argv)
{
@@ -465,9 +463,7 @@ int snprintf (char *__stream, size_t __n, const char *__format, ...)
#endif /* __MINGW_FORTIFY_VA_ARG */
-int vsnprintf (char *__stream, size_t __n, const char *__format, __builtin_va_list __local_argv) __MINGW_ASM_CALL(__mingw_vsnprintf);
-
-__mingw_bos_extern_ovr
+__mingw_bos_ovr
__attribute__((__format__ (gnu_printf, 3, 0))) __MINGW_ATTRIB_NONNULL(3)
int vsnprintf (char *__stream, size_t __n, const char *__format, __builtin_va_list __local_argv)
{
@@ -854,9 +850,7 @@ char * tmpnam(char * __dst)
int __cdecl __ms_vsnprintf(char * __restrict__ d,size_t n,const char * __restrict__ format,va_list arg)
__MINGW_ATTRIB_DEPRECATED_MSVC2005 __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
- int vsnprintf (char * __restrict__ __stream, size_t __n, const char * __restrict__ __format, va_list __local_argv) __MINGW_ASM_CALL(__ms_vsnprintf);
-
- __mingw_bos_extern_ovr
+ __mingw_bos_ovr
__attribute__((__format__ (ms_printf, 3, 0))) __MINGW_ATTRIB_NONNULL(3)
int vsnprintf (char * __restrict__ __stream, size_t __n, const char * __restrict__ __format, va_list __local_argv)
{
@@ -1140,9 +1134,7 @@ int snwprintf (wchar_t *__stream, size_t __n, const wchar_t *__format, ...)
#endif /* __MINGW_FORTIFY_VA_ARG */
-int vsnwprintf (wchar_t *__stream, size_t __n, const wchar_t *__format, __builtin_va_list __local_argv) __MINGW_ASM_CALL(__mingw_vsnwprintf);
-
-__mingw_bos_extern_ovr
+__mingw_bos_ovr
/* __attribute__((__format__ (gnu_wprintf, 3, 0))) */ __MINGW_ATTRIB_NONNULL(3)
int vsnwprintf (wchar_t *__stream, size_t __n, const wchar_t *__format, __builtin_va_list __local_argv)
{
--
2.25.1
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public