diff --git a/CMakeLists.txt b/CMakeLists.txt index d6289e713e6..e9af9b3a4fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,25 +58,18 @@ if("${VCLIBS_TARGET_ARCHITECTURE}" STREQUAL "x86") set(VCLIBS_TARGET_ARCHITECTURE "x86") set(VCLIBS_I386_OR_AMD64 "i386") set(VCLIBS_X86_OR_X64 "x86") - - # Note that we set _WIN32_WINNT to a high level to make declarations available, but still engage downlevel - # runtime dynamic linking by setting our own _STL_WIN32_WINNT back to Windows XP. - add_compile_definitions(_X86_ _VCRT_WIN32_WINNT=0x0501 _STL_WIN32_WINNT=0x0501) elseif(VCLIBS_TARGET_ARCHITECTURE STREQUAL "x64") set(VCLIBS_TARGET_ARCHITECTURE "x64") set(VCLIBS_I386_OR_AMD64 "amd64") set(VCLIBS_X86_OR_X64 "x64") - add_compile_definitions(_AMD64_ _VCRT_WIN32_WINNT=0x0501 _STL_WIN32_WINNT=0x0501) elseif(VCLIBS_TARGET_ARCHITECTURE STREQUAL "arm64") set(VCLIBS_TARGET_ARCHITECTURE "arm64") set(VCLIBS_I386_OR_AMD64 "arm64") set(VCLIBS_X86_OR_X64 "arm64") - add_compile_definitions(_ARM64_ _VCRT_WIN32_WINNT=0x0A00 _STL_WIN32_WINNT=0x0A00) elseif(VCLIBS_TARGET_ARCHITECTURE STREQUAL "arm64ec") set(VCLIBS_TARGET_ARCHITECTURE "arm64ec") set(VCLIBS_I386_OR_AMD64 "arm64ec") set(VCLIBS_X86_OR_X64 "arm64") # Yes, really: `%VCToolsInstallDir%lib\arm64ec` only contains the Link Options - add_compile_definitions(_AMD64_ _ARM64EC_ _VCRT_WIN32_WINNT=0x0501 _STL_WIN32_WINNT=0x0501) add_compile_options($<$:/arm64EC>) set(VCLIBS_EXPLICIT_MACHINE "/machine:arm64ec") else() @@ -92,6 +85,7 @@ set(STL_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/out/lib/${VCLIBS_I386_OR set(STL_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/out/lib/${VCLIBS_I386_OR_AMD64}") set(STL_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/out/bin/${VCLIBS_I386_OR_AMD64}") +# Note that we set _WIN32_WINNT to a high level to make declarations available. add_compile_definitions( _ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH WIN32_LEAN_AND_MEAN STRICT _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS _WIN32_WINNT=0x0A00 NTDDI_VERSION=NTDDI_WIN11_GE) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 5f9a98b1f8c..9cfc910eea6 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -1955,14 +1955,7 @@ _EMIT_STL_ERROR(STL1013, "The STL doesn't support /RTCc because it rejects confo #error In yvals_core.h, defined(MRTDLL) implies defined(_M_CEE_PURE); !defined(_M_CEE_PURE) implies !defined(MRTDLL) #endif // defined(MRTDLL) && !defined(_M_CEE_PURE) -#define _STL_WIN32_WINNT_VISTA 0x0600 // _WIN32_WINNT_VISTA from sdkddkver.h -#define _STL_WIN32_WINNT_WIN10 0x0A00 // _WIN32_WINNT_WIN10 from sdkddkver.h - -// Note that the STL DLL builds will set this to XP for ABI compatibility with VS2015 which supported XP. -#ifndef _STL_WIN32_WINNT -// The earliest Windows supported by this implementation is Windows 10 -#define _STL_WIN32_WINNT _STL_WIN32_WINNT_WIN10 -#endif // !defined(_STL_WIN32_WINNT) +// The earliest Windows supported by this implementation is Windows 10. #ifdef __cpp_noexcept_function_type #define _NOEXCEPT_FNPTR noexcept diff --git a/stl/src/atomic.cpp b/stl/src/atomic.cpp index 367defd27b9..0aab1685960 100644 --- a/stl/src/atomic.cpp +++ b/stl/src/atomic.cpp @@ -5,7 +5,7 @@ #include -#include +#include namespace { SRWLOCK _Shared_ptr_lock = SRWLOCK_INIT; diff --git a/stl/src/sharedmutex.cpp b/stl/src/sharedmutex.cpp index fac73f1e388..5b2f262cd8a 100644 --- a/stl/src/sharedmutex.cpp +++ b/stl/src/sharedmutex.cpp @@ -2,7 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include <__msvc_threads_core.hpp> -#include + +#include #include "primitives.hpp" diff --git a/stl/src/winapinls.cpp b/stl/src/winapinls.cpp index e118cf604ce..9d8227c2855 100644 --- a/stl/src/winapinls.cpp +++ b/stl/src/winapinls.cpp @@ -1,9 +1,11 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#include - -#if _STL_WIN32_WINNT < _STL_WIN32_WINNT_VISTA +// Previously, x64/x86 Desktop builds had to support targeting old versions of Windows, so we dllexported functions to +// dynamically load new Windows APIs. Now, we directly call those Windows APIs, and the dllexported functions have +// become simple wrappers, but they still need to be preserved for binary compatibility. The ARM64, App, and OneCore +// builds never supported targeting old versions of Windows, so they never provided these dllexported functions. +#if !(defined(_M_ARM64) || defined(_CRT_APP) || defined(_ONECORE)) #include @@ -29,4 +31,4 @@ extern "C" _CRTIMP2 int __cdecl __crtGetLocaleInfoEx(_In_opt_ LPCWSTR const lpLo return GetLocaleInfoEx(lpLocaleName, LCType, lpLCData, cchData); } -#endif // _STL_WIN32_WINNT < _STL_WIN32_WINNT_VISTA +#endif // ^^^ !(defined(_M_ARM64) || defined(_CRT_APP) || defined(_ONECORE)) ^^^ diff --git a/stl/src/winapisupp.cpp b/stl/src/winapisupp.cpp index de6f6ae4d29..fa6b46c53aa 100644 --- a/stl/src/winapisupp.cpp +++ b/stl/src/winapisupp.cpp @@ -35,7 +35,11 @@ extern "C" _CRTIMP2 BOOL __cdecl __crtIsPackagedApp() noexcept { #endif // !defined(_CRT_WINDOWS) && !defined(UNDOCKED_WINDOWS_UCRT) -#if _STL_WIN32_WINNT < _WIN32_WINNT_VISTA +// Previously, x64/x86 Desktop builds had to support targeting old versions of Windows, so we dllexported functions to +// dynamically load new Windows APIs. Now, we directly call those Windows APIs, and the dllexported functions have +// become simple wrappers, but they still need to be preserved for binary compatibility. The ARM64, App, and OneCore +// builds never supported targeting old versions of Windows, so they never provided these dllexported functions. +#if !(defined(_M_ARM64) || defined(_CRT_APP) || defined(_ONECORE)) // TRANSITION, ABI: preserved for binary compatibility extern "C" _CRTIMP2 ULONGLONG __cdecl __crtGetTickCount64() noexcept { @@ -150,16 +154,13 @@ extern "C" _CRTIMP2 BOOL __cdecl __crtSetFileInformationByHandle(_In_ HANDLE con _In_reads_bytes_(dwBufferSize) LPVOID const lpFileInformation, _In_ DWORD const dwBufferSize) noexcept { return SetFileInformationByHandle(hFile, FileInformationClass, lpFileInformation, dwBufferSize); } -#endif // _STL_WIN32_WINNT < _WIN32_WINNT_VISTA - -#if _STL_WIN32_WINNT < _WIN32_WINNT_WIN8 // TRANSITION, ABI: preserved for binary compatibility extern "C" _CRTIMP2 void __cdecl __crtGetSystemTimePreciseAsFileTime(_Out_ LPFILETIME lpSystemTimeAsFileTime) noexcept { GetSystemTimePreciseAsFileTime(lpSystemTimeAsFileTime); } -#endif // _STL_WIN32_WINNT < _WIN32_WINNT_WIN8 +#endif // ^^^ !(defined(_M_ARM64) || defined(_CRT_APP) || defined(_ONECORE)) ^^^ extern "C" _Success_(return > 0 && return < BufferLength) DWORD __stdcall __crtGetTempPath2W( _In_ DWORD BufferLength, _Out_writes_to_opt_(BufferLength, return +1) LPWSTR Buffer) noexcept { diff --git a/stl/src/xonce2.cpp b/stl/src/xonce2.cpp index 70866190367..0e3968f57dd 100644 --- a/stl/src/xonce2.cpp +++ b/stl/src/xonce2.cpp @@ -4,7 +4,8 @@ #include #include -#include + +#include // Provides forwarders for InitOnceBeginInitialize and InitOnceComplete for // environments that can't use /ALTERNATENAME.