Clang-cl.exe support for C++ modules

More testing reveals that I needed to additionally pass .\Hello.pcm itself as an input file.

Therefore, the following works, and produces Hello.exe (with a strange warning):

> clang-cl.exe /std:c++20 .\Hello.cppm /clang:--precompile /Fo.\Hello.pcm
> clang-cl.exe /std:c++20 .\use.cpp /clang:-fprebuilt-module-path=. .\Hello.pcm /Fe.\Hello.exe
clang-cl: warning: argument unused during compilation: '/std:c++20' [-Wunused-command-line-argument]
> .\Hello.exe
Hello World!

The following also works:

> clang-cl.exe /std:c++20 .\Hello.cppm /clang:--precompile /Fo.\Hello.pcm
> clang-cl.exe /std:c++20 .\use.cpp /clang:"-fmodule-file=Hello=.\Hello.pcm" .\Hello.pcm /Fe.\Hello.exe
clang-cl: warning: argument unused during compilation: '/std:c++20' [-Wunused-command-line-argument]
> .\Hello.exe
Hello World!

So, clang-cl.exe supports at least the minimal example.

2 Likes