-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[C++20] [Modules] The '#pragma comment(lib, ...)' and '#pragma detect_mismatch' directives in named modules shouldn't leak #61783
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
Comments
@llvm/issue-subscribers-clang-modules |
I'm not sure that's incorrect, though - you could have the object implementation of the module in that |
I think it is super weird that the pragma's semantics leak to other TUs. And it just works surprisingly for the |
It is like the pragma is being exported somehow. That shouldn't happen in my opinion. Only the module that specified the |
Is there something in my example that doesn't hold/make sense though? Like I /think/ you can build an ABI compatible implementation of a C++ module, so clients don't have to build object files from modules themselves, maybe? If you can do that, I think it makes a lot of sense for a pragma link directive in a module to impact clients of the module to cause the library to be linked in. I guess: when would you /not/ want this behavior? (like, you used the module, if the module has the pragma link, well your use of the module links in the implementation object file which then causes the pragma link to happen... ) |
I don't feel good about the behavior since it looks like an implicit linking information, which smells bad. We should prefer explicit information. And a bad example in my mind is that we have two modules ( Also according to the doc (https://learn.microsoft.com/en-us/cpp/preprocessor/comment-c-cpp?view=msvc-170), it looks like there are other types of comments. So may be there are other worse examples. So I think we shouldn't export things which is not explicitly exported by the named modules. How do you think about this? |
Just now I had a chat with a MSVC's developer. He tells me that the #pragmas in MSVC will leak the #pragma to the users. Also it is still very odd to me. I think it may be better to be consistent with MSVC for the issue since the |
Reproducer:
and
// user.cpp import mod;
now the IR for
user.cpp
will contain the metadata!0 = !{!"msvcprt.lib"}
which is leaked from another translation unitmod.cppm
. This is incorrect. The root cause of the problem is thatEagerlyDeserializedDecls
is designed for headers and it didn't take care for named modules. We need to redesign a new mechanism for named modules.The text was updated successfully, but these errors were encountered: