microsoft / STL

MSVC's implementation of the C++ Standard Library.
Other
9.88k stars 1.45k forks source link

Drop support for Win7 / Server 2008 R2 #4742

Closed StephanTLavavej closed 4 days ago

StephanTLavavej commented 1 week ago

This PR for VS 2022 17.12 drops support in the STL for targeting Win7 and Server 2008 R2.

Rationale

Support for all editions of Win7 and its counterpart Server 2008 R2 will have completely ended by the time that VS 2022 17.12 ships for production use. This includes extended security updates (the final, last resort, paid program). After that point, the OSes are insecure. Security is Microsoft's top priority, so it makes no sense for the STL to attempt to support fundamentally insecure systems. Removing this machinery will improve performance for everyone running supported OSes.

I've already gotten approval from my bosses and boss-like entities. I understand that Windows 7 was popular, so some of our programmer-users might have concerns about this change. However, Windows has already made its decision, and keeping this machinery in the STL won't make Win7 systems secure. End-users need to upgrade.

End-of-support dates

The big ones are already gone:

There's one highly obscure embedded edition which is almost, but not quite, an issue:

I'm not really supposed to talk about release dates, but with VS 2022 17.11 Preview 2 released just last week, it's safe to say that the POSReady edition isn't a concern for VS 2022 17.12.

Commits

As usual, I've been careful to preserve binary compatibility.

Cauterizing GetCurrentPackageId

This is technically a bonus cleanup - instead of removing machinery dealing with the conditional absence of Win8 APIs, it's removing machinery dealing with the conditional presence of Win8 APIs. I figured that it was better to review in a single PR (but an isolated commit) to understand the final state of winapisupp.cpp.

Going all the way back to VS 2015 RTM, __crtIsPackagedApp was dllexported but never declared for users. Because there are no actual clients to worry about, we can cauterize its implementation, dramatically simplifying winapisupp.cpp while preserving bincompat. The function needs to continue to exist in order to satisfy our dllexport validation, but it doesn't need to do anything useful.

Here's the programmer-archaeology. I dug up internal TFS changeset 1280651 from 2014-06-17. This changeset "Remove /guard support from toolset for Dev14 CTP2" unquestionably predated VS 2015 RTM. I downloaded $/DevDiv/pu/WinC/vctools/crt and searched for all mentions of this function:

C:\Users\stl\Downloads\crt>rg __crtIsPackagedApp
crtw32\stdcpp\filesys.h
30:     if (__crtIsPackagedApp()) \
69:     if (__crtIsPackagedApp() || AreFileApisANSI())

crtw32\misc\winapisupp.cpp
104:*__crtIsPackagedApp() - Check if the current app is a Packaged app
122:extern "C"  BOOL __cdecl __crtIsPackagedApp (

crtw32\h\awint.h
37:_CRTIMP2 BOOL __cdecl __crtIsPackagedApp(void);

The paths have changed over the years, but they're all internal to the STL's separately compiled code, not available via user-visible headers. The only usage was in our experimental filesystem implementation, so the function was unnecessarily dllexported (via _CRTIMP2). This was common back then, because we were confused about how our separately compiled code worked. In this case, different TUs within the STL's separately compiled code (whether the DLL or the static LIB) had to communicate, but they didn't have to communicate with user TUs. There is Only One STL (that DLL or static LIB) so there are no mismatch concerns. We had just mindlessly copy-pasted the _CRTIMP2 incantation.

The experimental filesystem usage was removed very early on in VS 2015's lifecycle. That was internal TFS changeset 1536084 on 2015-10-10, "Removed __crtIsPackagedApp and added FILE_FLAG_BACKUP_SEMANTICS to applicable Windows API calls."

So we can make the following changes: