I'm looking at the driver test cases for clang modules: https://github.com/llvm-mirror/clang/blob/master/test/Driver/modules.cpp
It includes steps to produce .pcm.o files. I'm wondering what they are for.
Given a c++20 module
// a-m.cc
module;
#include <iostream>
export module a;
export void do_a() { std::cout << "A\n"; }
You can compile it using
clang++ -std=c++20 -x c++-module --precompile a-m.cc -o a.pcm
which produces the precompiled module file a.pcm.
But there are also steps to compile .pcm files to .o files.
From the driver tests:
clang++ -std=c++20 a.pcm -S -o a.pcm.o
How are the .pcm.o files meant to be used?
If I write a main program
// main.cc
import a;
int main() {
do_a();
return 0;
}
Compile with
clang++ -std=c++20 -c main.cc -fmodule-file=a=a.pcm
And then try to link with the .pcm.o, I get
clang++ main.o a.pcm.o
/usr/bin/ld:a.pcm.o: file format not recognized; treating as linker script
/usr/bin/ld:a.pcm.o:2: syntax error
clang-13: error: linker command failed with exit code 1 (use -v to see invocation)
Note: you can compile a-m.cc
clang++ std=c++20 -c a-m.cc -o a.o
and link with a.o, but what are the .pcm.o files for? and can they be used to avoid compiling a-m.cc again after you've precompiled it?