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

Remove g++ dependency to find out the system headers #2

Open
JBakamovic opened this issue Apr 19, 2018 · 4 comments
Open

Remove g++ dependency to find out the system headers #2

JBakamovic opened this issue Apr 19, 2018 · 4 comments

Comments

@JBakamovic
Copy link
Owner

Solution:

  1. (Better) Find out which toolchain is being used for the project given the configuration file we are using.
  2. Depending on the platform we're running on use appropriate toolchain. But then we have to find out which ones are existing on the system and we can run into another bunch of problems ...
@MaskRay
Copy link

MaskRay commented Nov 4, 2018

It is available as clang::HeaderSearchOptions::UserEntries https://github.com/llvm-mirror/clang/tree/master/include/clang/Lex/HeaderSearchOptions.h#L102

But it isn't exposed as a libclang API.

g++/clang++ -v -E -x c++ is the best for a libclang based tool.

@JBakamovic
Copy link
Owner Author

g++/clang++ -v -E -x c++ is the best for a libclang based tool.

Yes, that's exactly how it is implemented right now but it would be nice to have this information exposed by libclang API as you mentioned. It probably shouldn't be too hard to write a patch for that? I may check it out if I find some spare time ... I'm currently occupied with finishing the code-completion feature.

Although, having a dependency on a C/C++ compiler for C/C++ language server is not to be unexpected, right 😃

@MaskRay
Copy link

MaskRay commented Nov 4, 2018

It would be hard. As you may probably end up replicating lots of C++ types in libclang counterparts. I am unclear if this kind of change will be accepted by upstream clang.

Another thing that may be out-of-scope of this function is when cross compilation is involved. clangDriver also has logic to detect various system search paths when it knows it is used as cross compiler, e.g. clang --target=ppc64le aarch-linux-gnu-clang

@JBakamovic
Copy link
Owner Author

It would be hard. As you may probably end up replicating lots of C++ types in libclang counterparts. I am unclear if this kind of change will be accepted by upstream clang.

I am not sure I see why that would be the case. For example, CompilerInstance header is already used by the libclang implementation which is AFAICT exactly what we would need to implement fetch-system-headers functionality: there is getHeaderSearchOpts() in CompilerInstance class.

Another thing that may be out-of-scope of this function is when cross compilation is involved. clangDriver also has logic to detect various system search paths when it knows it is used as cross compiler, e.g. clang --target=ppc64le aarch-linux-gnu-clang

Cross-compilations are usually handled by setting up proper sysroot and seems like this is also configurable via Sysroot field from HeaderSearchOptions. As far as I am concerned I believe this is already handled by internal clang driver implementation.

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

No branches or pull requests

2 participants