-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Closed
Labels
Description
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 compile_commands.json:
[
{
"directory": "/path/to/example",
"command": "/usr/bin/clang++ -std=c++23 -ffoobar test.cppm",
"file": "test.cppm",
"output": "build/test.cppm.o"
},
{
"directory": "/path/to/example",
"command": "/usr/bin/clang++ -std=c++23 -ffoobar main.cpp",
"file": "main.cpp",
"output": "build/main.cpp.o"
}
]
.clangd:
CompileFlags:
CompilationDatabase: "."
Remove:
- "-ffoobar"
test.cppm:
export module test;
export void test() {}
main.cpp:
import test;
int main() { return 0; }
E[02:40:54.668] Scanning modules dependencies for /home/test/clangd_modules_test/test.cppm failed: error: unknown argument: '-ffoobar'
I[02:40:54.668] Built prerequisite modules for file /home/test/clangd_modules_test/test.cppm in 0.00 seconds
E[02:40:54.668] Scanning modules dependencies for /home/test/clangd_modules_test/main.cpp failed: error: unknown argument: '-ffoobar'
I[02:40:54.668] Built prerequisite modules for file /home/test/clangd_modules_test/main.cpp in 0.00 seconds
If I remove -ffoobar from compile_commands.json it works correctly
This breaks support for compiling with gcc (that requires -fmodule-ts and other arguments clang does not understand) and using clangd, while generating compile_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 modules
