[PATCH v2 0/1] MR11397: symcrypt: Fix a compilation error.
Log: To enable older versions of i686-w64-mingw32-gcc to compile successfully. On some systems, the installed version of i686-w64-mingw32-gcc is relatively old, and upgrading it is difficult, which often leads to compilation errors. Signed-off-by: chenjiangyi <chenjiangyi@uniontech.com> While compiling Wine on my system, a compilation error occurs, as shown in the figure below 。 {width=900 height=580} Below is the version of i686-w64-mingw32-gcc I am using {width=900 height=197} -- v2: libs: Fix a compilation error. https://gitlab.winehq.org/wine/wine/-/merge_requests/11397
From: chenjiangyi <chenjiangyi@uniontech.com> Log: To enable older versions of i686-w64-mingw32-gcc to compile successfully. On some systems, the installed version of i686-w64-mingw32-gcc is relatively old, and upgrading it is difficult, which often leads to compilation errors. Signed-off-by: chenjiangyi <chenjiangyi@uniontech.com> --- libs/symcrypt/lib/mlkem_primitives.c | 8 ++++++++ libs/symcrypt/lib/sha512.c | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/libs/symcrypt/lib/mlkem_primitives.c b/libs/symcrypt/lib/mlkem_primitives.c index ab8a6e86c82..f17a42e26db 100644 --- a/libs/symcrypt/lib/mlkem_primitives.c +++ b/libs/symcrypt/lib/mlkem_primitives.c @@ -244,11 +244,19 @@ cleanup: #define VEC128_TYPE_UINT16 __m128i #define VEC128_LOAD_UINT16( addr ) _mm_loadu_si128( (__m128i*) (addr) ) +#if __GNUC__ >= 10 #define VEC64_LOAD_UINT16( addr ) _mm_loadu_si64( (PBYTE) (addr) ) +#else +#define VEC64_LOAD_UINT16( addr ) _mm_loadl_epi64( (__m128i const*) (addr) ) +#endif #define VEC32_LOAD_UINT16( addr ) _mm_cvtsi32_si128( SYMCRYPT_LOAD_LSBFIRST32( addr ) ) #define VEC128_STORE_UINT16( addr, vec ) _mm_storeu_si128( (__m128i*) (addr), (vec) ) +#if __GNUC__ >= 10 #define VEC64_STORE_UINT16( addr, vec ) _mm_storeu_si64( (PBYTE) (addr), (vec) ) +#else +#define VEC64_STORE_UINT16( addr, vec ) _mm_storel_epi64( (__m128i*) (addr), (vec) ) +#endif #define VEC32_STORE_UINT16( addr, vec ) SYMCRYPT_STORE_LSBFIRST32( (addr), _mm_cvtsi128_si32( vec ) ) #define VEC128_SET_UINT16( value ) _mm_set1_epi16( (value) ) diff --git a/libs/symcrypt/lib/sha512.c b/libs/symcrypt/lib/sha512.c index 0b763c54677..4a6d3df71c5 100644 --- a/libs/symcrypt/lib/sha512.c +++ b/libs/symcrypt/lib/sha512.c @@ -1307,6 +1307,10 @@ SymCryptSha512AppendBlocks_ull3( #endif #endif +#if !SYMCRYPT_MS_VC && __GNUC__ < 10 + #define _mm_storeu_si64(p, a) (_mm_storel_epi64((__m128i*)(p), (a))) +#endif + #define XMMADD( _a, _b ) _mm_add_epi64((_a), (_b)) #define XMMAND( _a, _b ) _mm_and_si128((_a), (_b)) #define XMMOR( _a, _b ) _mm_or_si128((_a), (_b)) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11397
Should be gated on GCC >= 9, not 10. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78782 I also think it'll do the wrong thing with Clang, since it reports \_\_GNUC\_\_ = 4. (Clang supports that function since 3.9.0.) Or we could simply make this workaround unconditional. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11397#note_145698
On Wed Jul 15 10:53:13 2026 +0000, Alfred Agrell wrote:
Should be gated on GCC >= 9, not 10. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78782 I also think it'll do the wrong thing with Clang, since it reports \_\_GNUC\_\_ = 4. (Clang supports that function since 3.9.0.) Or we could simply make this workaround unconditional. What do you mean by "unconditional"? So, we just do it like :
#define VEC64_LOAD_UINT16( addr ) _mm_loadl_epi64( (__m128i const*) (addr) ) #define VEC64_STORE_UINT16( addr, vec ) _mm_storel_epi64( (__m128i*) (addr), (vec) ) #define XMMSTORE_UINT64( _a, _addr ) _mm_storel_epi64((__m128i*)(p), (a)) without any conditional checks? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11397#note_145699
On Wed Jul 15 10:53:32 2026 +0000, JiangYi Chen wrote:
What do you mean by "unconditional"? So, we just do it like : #define VEC64_LOAD_UINT16( addr ) _mm_loadl_epi64( (__m128i const*) (addr) ) #define VEC64_STORE_UINT16( addr, vec ) _mm_storel_epi64( (__m128i*) (addr), (vec) ) #define XMMSTORE_UINT64( _a, _addr ) _mm_storel_epi64((__m128i*)(p), (a)) without any conditional checks? Correct. To me, that feels cleaner than a version check, especially if it checks for versions of all three compilers.
But I'm not the maintainer of this area, so I could be wrong. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11397#note_145700
On Wed Jul 15 11:01:36 2026 +0000, Alfred Agrell wrote:
Correct. To me, that feels cleaner than a version check, especially if it checks for versions of all three compilers. But I'm not the maintainer of this area, so I could be wrong. Thank you , I will adopt your suggestion.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/11397#note_145712
On Wed Jul 15 13:06:05 2026 +0000, JiangYi Chen wrote:
Thank you , I will adopt your suggestion. We could probably use `__has_builtin` for the condition. I also wonder if we could provide a fallback implementation for missing functions in intrin.h.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/11397#note_145720
On Wed Jul 15 15:34:01 2026 +0000, Jacek Caban wrote:
We could probably use `__has_builtin` for the condition. I also wonder if we could provide a fallback implementation for missing functions in intrin.h. Won't work. \_mm_loadu_si64 is not an intrinsic, it's just an inline function that calls \_mm_loadl_epi64. [(Source)](https://gcc.gnu.org/viewcvs?rev=269497&root=gcc&view=rev)
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/11397#note_145722
participants (4)
-
Alfred Agrell (@Alcaro) -
chenjiangyi -
Jacek Caban (@jacek) -
JiangYi Chen (@meshine)