Skip to content
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

Add a --query-driver flag to clangd-indexer #1717

Closed
tetsuo-cpp opened this issue Aug 2, 2023 · 1 comment
Closed

Add a --query-driver flag to clangd-indexer #1717

tetsuo-cpp opened this issue Aug 2, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@tetsuo-cpp
Copy link

Hi there! I'm trying to build a static index for a codebase that I'm cross-compiling.

I believe that in order to use clangd in this situation, you need to provide a path to the compiler with the --query-driver flag so that clangd can find the appropriate headers. However, there's no such flag for clangd-indexer. So when I try to build the index, I'm seeing a lot of include errors as it's not finding the correct headers.

Is there a way to get this to work that I've missed? And if not, would you accept a patch to add a flag like this to clangd-indexer?

@tetsuo-cpp tetsuo-cpp added the enhancement New feature or request label Aug 2, 2023
@HighCommander4
Copy link

HighCommander4 commented Aug 2, 2023

Is there a way to get this to work that I've missed?

The alternative to --query-driver is to specify your cross-compiler's system include paths manually.

You can run <cross-compiler> -E -v -xc++ - (this is what clangd does when --query-driver is specified; replace -xc++ with -xc if working on C code), look at the list of system include paths printed after #include <...> search starts here, and add a corresponding -isystem <path> to your source files' compile commands for each one.

Unfortunately, the simplest way to add those -isystem <path> flags would be using a clangd config file, but that's not hooked up for clangd-indexer either...

So that leaves you with arranging for your compile_commands.json to contain those -isystem flags, which may or may not be straightforward depending on how you're generating your compile_commands.json.

And if not, would you accept a patch to add a flag like this to clangd-indexer?

I don't call the shots so I can't guarantee that a patch would be accepted, but I think that would be a nice addition and fill a logical gap. I'm happy to provide guidance if you'd like to write a patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants