From: Vitaly Lipatov <lav@etersoft.ru> When clang < 13 cross-compiles for Windows, it sets _MSC_VER to 1911 (< 1912). The #if/#elif chain in __config checked _MSC_VER < 1912 first, which prevented the elif branch from defining _LIBCPP_DEFER_NEW_TO_VCRUNTIME. This caused placement new/delete to be defined in both vcruntime_new.h and the libc++ <new> header, resulting in redefinition errors. Fix by checking _LIBCPP_ABI_MICROSOFT first to always define _LIBCPP_DEFER_NEW_TO_VCRUNTIME when using vcruntime, then handle the aligned allocation check as a nested condition. --- include/msvcrt/__config | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/include/msvcrt/__config b/include/msvcrt/__config index 78ff1b2ab4e..02b3eefa6ba 100644 --- a/include/msvcrt/__config +++ b/include/msvcrt/__config @@ -992,15 +992,17 @@ template <unsigned> struct __static_assert_check {}; // If we are getting operator new from the MSVC CRT, then allocation overloads // for align_val_t were added in 19.12, aka VS 2017 version 15.3. -#if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912 -# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION -#elif defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME) +#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME) # define _LIBCPP_DEFER_NEW_TO_VCRUNTIME -# if !defined(__cpp_aligned_new) +# if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912 +# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION +# elif !defined(__cpp_aligned_new) // We're defering to Microsoft's STL to provide aligned new et al. We don't // have it unless the language feature test macro is defined. # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION # endif +#elif defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912 +# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION #endif #if defined(__APPLE__) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10577