Closed as not planned
Description
I will attach a zipped up project, with some source code and a Makefile. At the top of the Makefile, there are some variables that point to my build of clang. Those need to be changed, but then I hope you can reproduce this.
The commands in the Makefile are my attempt to follow the docs here.
Steps to demonstrate the issue
- Change this top part of the Makefile to fit your build of clang. I'm building on a Mac so I need that
macos_sdk
setting.
CXX = /Users/rob/Dev/llvm-project/build_phase1/bin/clang++
macos_sdk = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk
flags = -isysroot $(macos_sdk) -std=c++2b
- Run
make
, and you should see this output.
% make
Precompiling interface_part1.ccm -> interface_part1.pcm
Precompiling interface_part2.ccm -> interface_part2.pcm
Precompiling foo.ccm -> foo.pcm
Compiling main.cc -> main.o
Compiling foo.pcm -> foo.o
Compiling interface_part1.pcm -> interface_part1.o
Compiling interface_part2.pcm -> interface_part2.o
Linking program
- You can run the
program
to confirm that it compiled.
% ./program
Starting main()
hello from foo:interface_part1
hello from foo:interface_part2
- Now, change the variable name in the
other()
function ininterface_part1.ccm
. For example changeint a
toint aa
.
void other() {
int aa = 1;
}
- Run
make
again. I see this:
% make
Precompiling interface_part1.ccm -> interface_part1.pcm
Precompiling foo.ccm -> foo.pcm
foo.ccm:5:8: fatal error: module file 'interface_part1.pcm' is out of date and needs to be rebuilt: module file out of date
5 | export import :interface_part2;
| ^
foo.ccm:5:8: note: imported by module 'foo:interface_part2' in 'interface_part2.pcm'
This seems like a problem to me, for a couple reasons:
- The error is misleading. It says
interface_part1.pcm
is out of date and "needs to be rebuilt", but I just rebuilt it. - If
interface_part2.pcm
needs to be rebuilt, because it depends on part1, that seems like these modules are worse than headers at hiding implementation details. I changed a private non-exported functionother()
, and I changed an implementation detail - the name of the local variable. The exposed interface ofinterface_part1
should not change in this case. And I don't think it should trigger the need to recompile things that depend on it.
It's interesting that if I only change the value of int a
in other()
, say int a = 1
to int a = 2
, then then make
rebuilds things as expected without a problem.