-
Notifications
You must be signed in to change notification settings - Fork 11.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Confusing "module file out of date" errors with C++20 modules #70569
Comments
@llvm/issue-subscribers-clang-modules Author: None (rnikander)
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
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
% 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
% ./program
Starting main()
hello from foo:interface_part1
hello from foo:interface_part2
void other() {
int aa = 1;
}
% 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:
It's interesting that if I only change the value of |
Yes, this is the reason.
This is not strictly correct. It is true that
This looks like an overlook in the current design intentions. Or maybe To me, the root cause of the issue may be the expectation/consensus of hiding implementation details. And the topic involves BMI format/optimization/ABI. For example, for the following example:
With optimization enabled, the generated code of
Yes, the implementation detail of It is technically available to not leak the implementation of Also it is a problem of the ABI. If the non-exported function is an inline function, we have to generate the function body in the calling unit. Otherwise we're violating the ABI. And the final step may be format design/implementation, which is the direct reason for this issue. But I guess we can't solve the underlying issue if we don't solve the first 2 issues. |
Thanks @ChuanqiXu9, what you explained there makes sense to me. I see why the non-exported function causes a recompile, in general ... so I think it's mainly the error message that's confusing me here. And it would be good to know how to hide the |
Currently, maybe we can only put that into the implementation units. |
This may be covered by #71034. Let's track the underlying issue there. |
Let's track this in #71618. |
@rnikander FYI, see the newest comments in #71618 |
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.
files.tgz
The commands in the Makefile are my attempt to follow the docs here.
Steps to demonstrate the issue
macos_sdk
setting.make
, and you should see this output.program
to confirm that it compiled.other()
function ininterface_part1.ccm
. For example changeint a
toint aa
.make
again. I see this:This seems like a problem to me, for a couple reasons:
interface_part1.pcm
is out of date and "needs to be rebuilt", but I just rebuilt it.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
inother()
, sayint a = 1
toint a = 2
, then thenmake
rebuilds things as expected without a problem.The text was updated successfully, but these errors were encountered: