r/cpp • u/holyblackcat • Mar 09 '26
The compilation procedure for C++20 modules
https://holyblackcat.github.io/blog/2026/03/09/compiling-modules.html
104
Upvotes
r/cpp • u/holyblackcat • Mar 09 '26
View all comments
Show parent comment
6
u/not_a_novel_account cmake dev Mar 09 '26 edited Mar 09 '26
In-library you don't recompile everything, you only recompile the partitions which depended on the changed interface.
I'm trying to understand the use case:
export module Stooges;, internally you have some partitions:export module Stooges:Moe;,export module Stooges:Larry;,export module Stooges:Curly;.MoeandLarryimport:Curly, if you changeCurly, they need to rebuild along withCurly. If you changeMoeorLarry, only the changed partition needs to rebuild.import Stooges;. Your problem seems to be, "If I only actually needLarry, I still need to rebuild ifMoechanges."I guess this is true, it's just not how I do application development. I don't have huge in-development applications where I have a rapidly changing upstream interface which I'm updating constantly. If that's your use case, yes you need more granular modules, but this comes with its own tradeoffs.
In practice, most libraries will be distributed as
import boost;orimport fmt;orimport beman;. You wouldn't expect to update these dependencies and not need to rebuild based on the granular parts you happen to use.