r/cpp • MSVC user, r/cpp_modules • Apr 02 '26

Current Status of Module Partitions

A brief recap of the current status of module partitions - as I understand it.

  1. People are using hacks to avoid unneeded recompilations.
  2. The C++ standard has an arcane concept of partition units, which forces build systems to generate BMI files that aren't used (which is wasting work during builds).
  3. The MSVC-compiler (per default) provides a simple, easy to use and efficient implementation of module partitions (no unneeded recompilations, no wasted work during builds), but which is not conformant to the current C++ standard.
  4. A CMake developer is working on a proposal that would fix items 1 and 2, which is probably the smallest required change to the standard, but adds another arcane concept ("anonymous partition units" using the new syntax "module A:;") on top of an already arcane concept.

Questions:

  • How and why did we get into this mess?
  • What's the historical context for this?
  • What was the motivation for MSVC ignoring the standard per default?1

1 Yes, I know the MSVC compiler has this obscure /InternalPartition option for those who want standard conformant behavior.

33 Upvotes

48 comments sorted by

View all comments

Show parent comment

1

u/pjmlp Apr 03 '26

This kind of stuff is possible in a couple of languages that were born with modules from the start.

As long as the public interface doesn't change only relinking is required for the consumers.

However they have the whole compiler and linker as part of the language reference.

I also expected that at least VC++ with its IDE integration, would be clever enough to behave this way, but nope, changing implementation triggers cascade compilation.

It isn't as if this is impossible in C++, Energize C++ and Visual Age for C++ v4, were able to do incremental compilation on method level, and we were still on C++ARM as reference.