-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
Linux: libclang does not discover Clang-specific system headers #201
Comments
Here's the cc1 command as reported by #include <stddef.h>
#include <stdio.h>
int main()
{
size_t lol = 100;
printf("Hello, world!");
} Click to expand...
Unfortunately |
This is a helpful hint and partially confirms what I was suspecting: https://lists.llvm.org/pipermail/cfe-dev/2010-December/012751.html
I noticed that Also relevant: https://clang.llvm.org/docs/LibTooling.html#builtin-includes
The real question is why this isn't an issue with libclang on Windows because I'm pretty sure it does the same thing. (Pretty sure it was the root cause of #98) It does appear to use the resource directory: This implies there's no funny business going on but then I wonder how it works at all: That function is used here in libclang: The Windows logic is basically to find the location of This ends up used in I suspect that in the typical case it's expected that Linux apps will consume a distro-provided shared library and Windows apps will use their own so it may be that |
Workaround for MochiLibraries/ClangSharp.Pathogen#1 uses a pre-built libclag-pathogen.so Workaround for #201 hard-codes a -isystem option to Clang resource directory for tests.
Workaround for MochiLibraries/ClangSharp.Pathogen#1 uses a pre-built libclag-pathogen.so Workaround for #201 hard-codes a -isystem option to Clang resource directory for tests.
It looks like the include portion of the Clang resource directory is ending up in our build products under Comparing it to the resource directory on Lovebuntu, it is missing two things:
In theory neither of those are important for Biohazrd operation so we can probably do without. The folder totals 7.7 MB, which is reasonably small enough that we could feasibly embed it in the If we discovered we needed those libraries for some reason, that balloons to 45 MB which is quite a bit less palatable. |
Turns out on Windows it's just getting it from the UCRT. I'll just package the resource directory in the runtime NuGet package for use on Linux. |
Unlike on Windows, libclang is not automagically finding certain system include paths like it does if you invoke
clang
from the terminal.EG:
#include <stddef.h>
fails becausestddef.h
is missing. Looking atclang -E
, it looks likestddef.h
gets provided by Clang on my machine via/usr/lib/llvm-10/lib/clang/10.0.0/include/stddef.h
(which matches this file in llvm-project.)It's not all headers since
<string>
is able to be found.It seems that on Linux Clang finds these headers relative to where it's installed. I think Clang might have these Clang-specific embedded on Windows? Need to look into whether that's an option that can be enabled when we build
libclang
or something.For now I'm just gonna manually add
builder.AddCommandLineArguments("-isystem/usr/lib/llvm-10/lib/clang/10.0.0/include/");
The text was updated successfully, but these errors were encountered: