clangd shows many compilation errors when sccache is in use (example: "In included file: 'algorithm' file not found")
Categories
(Developer Infrastructure :: Developer Environment Integration, defect, P4)
Tracking
(firefox83 fixed)
Tracking | Status | |
---|---|---|
firefox83 | --- | fixed |
People
(Reporter: mstange, Assigned: mossop)
References
(Blocks 1 open bug)
Details
Attachments
(4 files)
I tried out mach ide vscode
today on macOS, and it completed successfully, but now VSCode displays a large amount of build errors.
Some of those build errors complain about not finding std headers.
Reporter | ||
Comment 1•4 years ago
|
||
I invoked the command using MOZCONFIG=.mozconfig-opt mach ide vscode
from my srcdir. I have a copy of srcdir/mach
at ~/bin/mach
.
I am using sccache.
Reporter | ||
Comment 2•4 years ago
•
|
||
Here's an example of a somewhat simple file, gfx/layers/composite/Diagnostics.cpp. I can't seem to find a way to copy the whole list of errors as text.
Reporter | ||
Comment 3•4 years ago
|
||
The "Clang Language Server" section of the Output pane has the following:
[Error - 5:55:58 p.m.] Request textDocument/hover failed.
Message: Task was cancelled.
Code: -32001
Furthermore, in the process manager I can still see clangd chugging away in the background.
Reporter | ||
Updated•4 years ago
|
Reporter | ||
Comment 4•4 years ago
|
||
Reporter | ||
Updated•4 years ago
|
Reporter | ||
Updated•4 years ago
|
Reporter | ||
Comment 5•4 years ago
|
||
I have created a version of my mozconfig
file which does not include the sccache configuration line ac_add_options --with-ccache=/Users/mstange/.mozbuild/sccache/sccache
, and re-run mach ide vscode
with that.
It works! No more errors.
Reporter | ||
Updated•4 years ago
|
Comment 6•4 years ago
•
|
||
Markus and I discussed this a bit in chat. The problem seems to be related to the use of sccache
, which shows up at the beginning of the compile commands in compile_commands.json
. It confuses clangd into thinking sccache
is the compiler, which leads clangd
to be unable to successfully determine what the compiler's built-in include paths are (leading to things like <algorithm>
not being resolved).
In my setup, I use ccache
(rather than sccache
), and this works because clang's libTooling special-cases ccache
as a compiler wrapper, so it knows to ignore it in the compiler command and look at the next argument instead.
Possible ways to fix this:
- Submit a patch to clang libTooling to include
sccache
in the list of things they recognize as a compiler wrapper. - Modify our Clangd build backend to strip out the
sccache
from the generated commands incompile_commands.json
.
Updated•4 years ago
|
Assignee | ||
Comment 7•4 years ago
|
||
(In reply to Botond Ballo [:botond] from comment #6)
- Modify our Clangd build backend to strip out the
sccache
from the generated commands incompile_commands.json
.
Seems likely that this would be the fastest route for now. Would a patch be accepted?
Comment 8•4 years ago
•
|
||
(In reply to Dave Townsend [:mossop] from comment #7)
(In reply to Botond Ballo [:botond] from comment #6)
- Modify our Clangd build backend to strip out the
sccache
from the generated commands incompile_commands.json
.Seems likely that this would be the fastest route for now.
Agreed
Would a patch be accepted?
Yep -- thanks! Feel free to flag me or Andi for review.
Assignee | ||
Updated•4 years ago
|
Comment 9•4 years ago
|
||
(In reply to Botond Ballo [:botond] from comment #8)
(In reply to Dave Townsend [:mossop] from comment #7)
(In reply to Botond Ballo [:botond] from comment #6)
- Modify our Clangd build backend to strip out the
sccache
from the generated commands incompile_commands.json
.Seems likely that this would be the fastest route for now.
Agreed
Would a patch be accepted?
Yep -- thanks! Feel free to flag me or Andi for review.
Could we write two compile_commands.json
, one with and one without sccache
? I use the output for some things and I'm not 100% certain that there's a simple transformation from one form to the other...
Comment 10•4 years ago
|
||
(In reply to Nick Alexander :nalexander [he/him] from comment #9)
Could we write two
compile_commands.json
, one with and one withoutsccache
? I use the output for some things and I'm not 100% certain that there's a simple transformation from one form to the other...
We already have ./mach build-backend -b CompileDB
to write a "regular" compile_commands.json, and ./mach build-backend -b Clangd
to write the one for clangd with non-unified commands. I imagined that stripping sccache
would only be done for the clangd one.
Assignee | ||
Comment 11•4 years ago
|
||
Depends on D93532
Comment 12•4 years ago
|
||
(In reply to Botond Ballo [:botond] from comment #10)
(In reply to Nick Alexander :nalexander [he/him] from comment #9)
Could we write two
compile_commands.json
, one with and one withoutsccache
? I use the output for some things and I'm not 100% certain that there's a simple transformation from one form to the other...We already have
./mach build-backend -b CompileDB
to write a "regular" compile_commands.json, and./mach build-backend -b Clangd
to write the one for clangd with non-unified commands. I imagined that strippingsccache
would only be done for the clangd one.
That works for me -- thanks for the reminder, botond.
Assignee | ||
Comment 13•4 years ago
|
||
(In reply to Botond Ballo [:botond] from comment #10)
(In reply to Nick Alexander :nalexander [he/him] from comment #9)
Could we write two
compile_commands.json
, one with and one withoutsccache
? I use the output for some things and I'm not 100% certain that there's a simple transformation from one form to the other...We already have
./mach build-backend -b CompileDB
to write a "regular" compile_commands.json, and./mach build-backend -b Clangd
to write the one for clangd with non-unified commands. I imagined that strippingsccache
would only be done for the clangd one.
Looks like the patch I just pushed doesn't differentiate between the two, any tips on how to do that?
Comment 14•4 years ago
|
||
(In reply to Dave Townsend [:mossop] from comment #13)
We already have
./mach build-backend -b CompileDB
to write a "regular" compile_commands.json, and./mach build-backend -b Clangd
to write the one for clangd with non-unified commands. I imagined that strippingsccache
would only be done for the clangd one.Looks like the patch I just pushed doesn't differentiate between the two, any tips on how to do that?
Answered in Phabricator.
Comment 15•4 years ago
|
||
Pushed by dtownsend@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/d0e5422a86b2 Strip ccache compilation wrappers from the clangd compilation database. r=botond
Comment 16•4 years ago
|
||
bugherder |
Updated•2 years ago
|
Description
•