-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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
[Clangd] C++20 modules support ignores CompileFlags.Add/Remove compiling a module preamble #112635
Comments
@llvm/issue-subscribers-clang-modules Author: Petr Polezhaev (petr-polezhaev)
When used with `compile_commands.json` clangd seem to ignore flag modifications from `.clangd` when (and only when) compiling module information, leading to module search issues
Given
If I remove This breaks support for compiling with gcc (that requires |
@llvm/issue-subscribers-clangd Author: Petr Polezhaev (petr-polezhaev)
When used with `compile_commands.json` clangd seem to ignore flag modifications from `.clangd` when (and only when) compiling module information, leading to module search issues
Given
If I remove This breaks support for compiling with gcc (that requires |
I can fix this (and did so in a hack locally) but I would like to know what was the intent in code to know hohw to fix. As far as I can tell, in the codebase you are meant to use I see three options for fixing this:
I think 2 is the easiest, 1 is probably goes against the codebase intents and 3 is (IMO) the most correct one but I am not sure why it was coupled with the compilation database in the first place. @ChuanqiXu9 since you are the author of the implementation in the first place, what is your preference? |
Pretty appreciated to see someone else to take part in this area! I prefer 3. Maybe it worths to take a look at https://github.com/ChuanqiXu9/clangd-for-modules for my following plan. Previously, in the first step, we hope the compilation of different TUs won't interact with each other so that we can avoid some thread safe problems. Then we tried to create |
I'd actually recommend something like 2). Coupling of Moreover A similar argument goes for needing compile flags, So I'd rather introduce: struct ProjectModules {
...
using CmdProvider = std::function<std::optional<tooling::CompileCommand>(PathRef)>
virtual void setCmdProvider(CmdProvider C) {}
...
}; and then call this in |
Sorry for disappearing - I missed the notification in mail and only saw your replies now. |
When used with
compile_commands.json
clangd seem to ignore flag modifications from.clangd
when (and only when) compiling module information, leading to module search issuesGiven
compile_commands.json
:.clangd
:test.cppm
:main.cpp
:Results in:
If I remove
-ffoobar
fromcompile_commands.json
it works correctlyThis breaks support for compiling with gcc (that requires
-fmodule-ts
and other arguments clang does not understand) and using clangd, while generatingcompile_commands.json
with cmake. Using.clangd
to remove unsupported options (and add other options needed for clang) works for the rest of the functionality but not for modulesThe text was updated successfully, but these errors were encountered: