Closed dprogm closed 11 months ago
Hey Dirk--sorry I've been so slow on this. I've had some urgent things I've needed to do, so I had to step away for a little bit.
I wish I had better news, but I've honestly got no idea what's causing this off the top of my head, and I'm not sure I've got comparative advantage over you without (a lot) more information.
Did you make any progress in figuring it out? If you run the compile command separately, does it produce a file with problematic permissions? Any idea where the problematic permissions are coming from or what they are?
(I'm not sure how to explain everything working for clangd but not for other tool, since I'd think they'd just both be operating on the output file--except that significant caching goes on around the use of the .d files, so subsequent runs may well not hit them if nothing has changed. To reset those caches you can rm bazel-out/**/*.hedron.compile-commands.headers
.)
@cpsauer Thank you for the reply. I am going to investigate this further the next days and try to answer your questions. The error is caused by the preprocessor compiler flag -MF <file>
. The compiler cannot open this file because of these file permissions (no write permission). I am not sure how clangd
handles such kind of flag. Maybe this is just an issue of the tooling.
TODO list for me:
clangd
handles this flag Ooh, I see. Right, so Bazel must be marking all its cached outputs as readonly when it runs its actions--preventing people from easily changing them and messing up the cache. And then rerunning the command fails because it tries to overwrite. That all makes sense.
This tool actually reads those .d files when available, but there isn't an issue because it's only reading. I'd imagine clangd does the same--or just ignores those dependency file output flags.
To take a step back: What are these other tools that want to overwrite those bazel dependency file outputs? And are you sure you want them to?
^ Dirk, any thoughts here?
@cpsauer I didn't forget about it. But as you pointed out, this might be an issue primarily caused by the dependent tooling. Because Bazel is setting these permissions I don't see a clean way to circumvent it. I am using the VS Code Compiler Explorer Extension that relies on the compilation database. But I am going to create a PR with a fix (filter out such kind of flags) to this repository.
Sorry for taking up your time. But I think we can close this :wink:
Thanks for taking the time to write in--and to leave things better than you found them.
I'm wondering if, maybe, the PR might be better placed with the other tool? I assume it's reading the .d dependency files because it's getting some value out of them (like we do!), so perhaps it could open files in read-only mode? (Either always, or as necessary.) Or if not, it could ignore the flags over there?
Sounds like I should close, so I will, but ofc feel free to write me back. Happy coding!
Thanks for providing this great tool!
In conjunction with clangd everything works like a charm. But I am also using other tools based on the compilation database and experience the following issue:
The corresponding compile command looks like this:
Changing the permissions fixes the problem.