C++ 20 named modules with clang-cl is finally added in CMake 4.4
I've been using named modules in my hobby C++ projects for years but they always trigger some unexpected ICEs when I used MSVC, and I got really tired of experimenting workarounds. After I switched to clang-cl recently, all the related problems I've encountered so far were resolved. The only thing missing now is import std
66
Upvotes
8
u/Air10n Jul 20 '26
MSVC updates on named module are slow and progress is opaque, there are also regressions failing to compile code that was completely fine before. I'm glad I can finally replace it with the open sourced Clang and find some peace
16
u/delta_p_delta_x Jul 20 '26
This is also fixed. You can get this with a nightly CMake build. You'll still need the magic UUIDs (see my comment here), but it otherwise works flawlessly. I use
import std;and named modules, and the MSVC standard library. Pretty cool.Now if only I could convince CMake/VS/Ninja to use the preview 14.52 toolset that I've installed, instead of 14.51...
3
u/Kridenberg Jul 20 '26
And again. IMHO, Clang-Cl biggest (I would say even the only real, but again, there may have specific cases) purpose is to be compatible with Visual Studio. Clang-Cl still cannot be used to compile modules in VS, thus there is nothing big to celebrate, TBH. And as far as Clang-Cl modules issue was already off-loaded by vendors to build systems, I guess we will never see Clang-Cl with modules in Visual Studio (they close those requests)
7
u/gracicot Jul 20 '26
On another note, ninja just fixed a bug with modules so flipping dependencies should be handled gracefully: https://github.com/ninja-build/ninja/issues/2666
CMake + ninja are quite well positioned for named modules.
3
u/cristianadam Jul 20 '26
If you want a faster clang-cl have a look at Qt Creator 20: faster clangd
Do not that I haven't tested regular clang-cl there, only against msvc. But the PGO build of clang-cl should be faster than regular clang-cl.
10
u/[deleted] Jul 20 '26
[removed] — view removed comment