-
Notifications
You must be signed in to change notification settings - Fork 59
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 invokes the compiler driver with -x objective-c++-header which fails for GCC #1694
Comments
If you don't have a compilation database, clangd will parse "*.h" as ObjC++ by default for best parse compatibility. Indeed this interacts poorly with query-driver (using query-driver without a compilation database is a bit unusual). If you add A few other possible workarounds: add an empty compile_flags.txt to suppress the default -xobjective-c++-header, or wrap the driver in a shell script to suppress the flag, or get the paths by hand and add them to the config file directly. |
Duplicate of #1568. I posted a proposed fix to https://reviews.llvm.org/D147905, but its discussion seems to have stalled since my last comment. |
By "compilation database" I'm not sure what you mean; I guess you mean Making the change in a wrapper is tricky to do portably, at least in POSIX sh, because I need to be sure to preserve whitespace in arguments and all that stuff. I guess I could only do this translation if invoked in the exact way clangd invokes the compiler. Adding flags directly into .clangd won't work because the compiler installation is relocatable so the root path is not static.
I thought I had tried this and it didn't work but now I see I made a mistake, because I was only adding flags to .h / .hpp / .hh files but these files I was testing were new-style C++ STL files that have no extension. If I simply force the Add: of I think the change suggested in issue #1568 would be a good one to avoid the issue in the first place however. |
Closing as duplicate of #1568 which is now fixed on trunk |
I am using my own install of GCC, and in order to allow the STL headers to be parsed properly I have added a .clangd file to my GCC install, that looks like this:
And I have --query-driver set to accept this compiler.
Unfortunately this fails because when clangd tries to invoke this compiler to get the compilation database (the system headers) it passes the argument
-x objective-c++-header
and that is obviously an invalid argument to give to GCC, so it fails:But this is not what I want: it finds the wrong version of the system headers.
It fails because this is not a valid GCC command line:
I can't find any way to convince clangd to use a valid language type when it invokes my compiler driver to obtain the compilation database.
System information
Output of
clangd --version
:Ubuntu clangd version 16.0.6 (++20230704084246+7cbf1a259152-1~exp1~20230704204333.104)
Features: linux
Platform: x86_64-pc-linux-gnu
Editor/LSP plugin:
GNU Emacs lsp-mode
Operating system:
GNU/Linux Ubuntu 20.04 x86_64
The text was updated successfully, but these errors were encountered: