Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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($<$<COMPILE_LANGUAGE:CXX>:/arm64EC>)
set(VCLIBS_EXPLICIT_MACHINE "/machine:arm64ec")
else()
Expand All @@ -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)
Expand Down
9 changes: 1 addition & 8 deletions stl/inc/yvals_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion stl/src/atomic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include <yvals.h>

#include <synchapi.h>
#include <Windows.h>

namespace {
SRWLOCK _Shared_ptr_lock = SRWLOCK_INIT;
Expand Down
3 changes: 2 additions & 1 deletion stl/src/sharedmutex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <__msvc_threads_core.hpp>
#include <synchapi.h>

#include <Windows.h>

#include "primitives.hpp"

Expand Down
10 changes: 6 additions & 4 deletions stl/src/winapinls.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <yvals_core.h>

#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))
Comment thread
StephanTLavavej marked this conversation as resolved.

#include <yvals.h>

Expand All @@ -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)) ^^^
11 changes: 6 additions & 5 deletions stl/src/winapisupp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion stl/src/xonce2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
#include <yvals_core.h>

#include <cstdlib>
#include <synchapi.h>

#include <Windows.h>

// Provides forwarders for InitOnceBeginInitialize and InitOnceComplete for
// environments that can't use /ALTERNATENAME.
Expand Down