r/cpp • MSVC Dev Lead • 16d ago

MSVC Build Tools Preview updates - November 2026

https://devblogs.microsoft.com/cppblog/msvc-build-tools-preview-updates-november-2026/

Hi, MSVC dev lead here. We're back with more MSVC Build Tools Preview blog posts. Here's what's new since mid-September. The preview is up to version 14.53 now, as 14.52 is GA (blog post coming soon).

Instructions to install & use the latest preview bits are atΒ https://aka.ms/msvc/preview.

60 Upvotes

20 comments sorted by

15

u/Jonny_H 16d ago

Added opt-in automatic load-time function selection for link-time code generation. The [[msvc::auto_dispatch]] attribute can generate CPU-specific implementations from one function body for selection by a supporting loader.

Neat, is this like gcc's function multiversioning extension? Though what's a "supporting loader" in this context? Is that just saying the support code is autogenerated by the compiler and run at load time? Or is it something the developer needs to provide or setup somehow?

14

u/Ambitious-Method-961 16d ago edited 16d ago

This feature immediately jumped out at me but I can't find any info on it on Microsoft's website.

I swear I saw a presentation from some Visual Studio people a while ago where they were showing the possibilities of generating multiple version of a function and then selecting which one to dispatch to at application load time and doing some kind of in-memory patching, but I can't for the life of me find the presentation now. I was wondering if this was that very feature.

edit: I found the video (https://www.youtube.com/watch?v=LTM1was1dTU) and it was manual function selection via [[msvc::dispatch]], although I can't find any info on that attribute either.

12

u/ack_error 16d ago edited 16d ago

OK, figured it out. The dispatch feature is live and in fact already used by vcruntime140.dll; you can dump the dynamic relocation table with dumpbin /loadconfig. It's usable in the preview with /experimental:loadTimeSelection but there are quirks.

Manual function selection uses dispatch, with the simplest form being [[msvc:dispatch(for: CAP)]]. It's weird because CAP must be an enumerated value matching one of the values in <overridecapabilities.h>, but that header defines macros instead which won't work. If you create an enum with CAP_AVX2 equal to OVRDCAP_AMD64_AVX2 and then declare another instance of a function with [[msvc:dispatch(for: CAP_AVX2)]], then you will have the function dynamically overridden for AVX2. This is in addition to the base function with the default compile-time settings. The OS loader will select the implementation at load time and patch the call path to use the selected version.

auto_dispatch uses the same loader mechanism but is accessed differently. Instead of taking capability flags, it takes one or more strings similar to /arch: AVX, AVX2, AVX512, APX, AVX10.1, e.g. [[msvc::auto_dispatch("AVX", "AVX2")]]. There doesn't appear to be one for SSE4.1. When tagged, the code generator will report X functions cloned for automatic dispatch and it will emit multiple implementations. This only works with LTCG, it will appear to compile without /GL but will crash in memcmp() on startup otherwise. Hopefully this limitation is eventually lifted.

Details:

  • Requires Windows 11, doesn't work on Windows 10. The program will load and run, but just with the base function implementation.
  • The loader patches JMP instructions directly, so no indirect call as with standard manual function pointer dispatch. However, it patches a trampoline instead of the actual call sites, so you will get CALL+JMP or JMP+JMP instead of plain CALL/JMP. This looks like an MSVC implementation detail since the PE dynamic relocation mechanism is more general.
  • The x86 ISA feature flags available for dispatch are quite limited. There's AVX, AVX2, AVX512F, and SSE4.1, but no SSE3, SSSE3, SSE4.2, much less the really detailed ones like AVX_VNNI. ARM64 is better, it appears to just reflect out the standard FEAT_* flags.
  • This isn't a viable replacement for [[gnu::target]] since it always creates at least two versions, base and specified. You can't specify AVX and just get an AVX function. And unfortunately, [[msvc::enable]] still doesn't accept anything other than APX.

3

u/Ambitious-Method-961 15d ago

Great work! Usage of the trampoline was covered in the presentation I used (they referred to it as a thunk) and it's a memory and load-time optimisation at the expense of adding a layer of indirection.

u/ericbrumer are the dispatch and auto_dispatch attributes something for public use or are they still restricted to internal Windows/MS usage as per that cppcon video?

2

u/Tringi github.com/tringi 15d ago

Requires Windows 11, doesn't work on Windows 10. The program will load and run, but just with the base function implementation.

Do you know which Windows Server version supports this feature?

4

u/ack_error 14d ago

No, I only have non-server editions to test against. In theory, the mechanism can also be emulated on downlevel OSes, as long as you can modify code segments (not always allowed).

5

u/ack_error 16d ago

There's an internal submitted bug that has some examples: https://developercommunity.visualstudio.com/t/msvc::dispatch:-nested-all-ins/11145351

Unfortunately it looks tied to OS loader support, which will limit its usability.

7

u/Tringi github.com/tringi 16d ago

I've noticed that this case of inlining of optimized rotation is also fixed. Probably a side effect of some other work.

9

u/domiran game engine dev 16d ago

Any timeline on reflection? 😭

8

u/fortsnek274 16d ago

Any timeline on any C++26?

0

u/[deleted] 16d ago

[deleted] β€” view deleted comment

1

u/fortsnek274 16d ago

I hope somebody will get the pitchforks out if MS uses that excuse all the way to C++29.

But we should know sometime next week, right?

-1

u/pjmlp 16d ago

Like Apple and Google nowadays, they already have security as possible reason to decrease resources on C++.

C# is not getting all the low level coding improvements, and now a revamp of the unsafe memory model, for no reason.

Likewise they now have a Visual C++ backend for Rust compiler, rustc_codegen_utc.

So they might be in no rush for anything post C++23, just like there is nothing happening on C front since C11 and C17 support was added, and even that wasn't 100% of it.

3

u/caroIine 14d ago

But Apple support many useful features from C++26 already https://developer.apple.com/xcode/cpp/

1

u/pjmlp 14d ago edited 14d ago

Because every now and then, Apple updates XCode baseline to upstream clang, they aren't actively contributing to clang as they used to.

They are quite clear in what languages we should be writing future applications, Fortify your app: Essential strategies to strengthen security

Also note that modules are completly removed from that page, there are no references to the related papers.

1

u/Daniela-E Living on C++ trunk, WG21 |πŸ‡©πŸ‡ͺ NB 15d ago

Was it?

2

u/schmerg-uk 16d ago

The link as shared redirects to https://devblogs.microsoft.com/cppblog/microsoft-c-msvc-build-tools-v14-51-preview-released-how-to-opt-in/ which is 6 months out of date (Feb 2026) if want to consider updating the redirect and/or the quoted link

4

u/cpppm MSVC Game Dev PM 16d ago

https://aka.ms/msvc/preview

Thanks for pointing it out. The link is now updated.

2

u/schmerg-uk 15d ago

Ta... we're just exploring the 14.52 release (looking to move to a full C++23 impl) now but as a non-LTSC release we're aware that we'll then have to keep moving fwd until the next LTSC release that follows that

2

u/cpppm MSVC Game Dev PM 12d ago

14.52 is a LTS! Read the announcement post here

1

u/schmerg-uk 12d ago

Saw that but thank you !