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

find_clang.cr, function parse_clang_output takes only first include path while skipping others #42

Closed
ZaWertun opened this issue May 13, 2020 · 3 comments · Fixed by #43

Comments

@ZaWertun
Copy link
Contributor

ZaWertun commented May 13, 2020

For example I have this flags (https://github.com/Papierkorb/bindgen/blob/master/clang/find_clang.cr#L380), I'll include only -internal-isystem part:

...
 "-internal-isystem",
 "/usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10",
 "/usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/x86_64-redhat-linux",
 "/usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/backward",
 "/usr/local/include",
 "/usr/lib64/clang/10.0.0/include",
 "-internal-externc-isystem",
...

And this function returns only first one dir - /usr/include/c++/10, skipping the /usr/local/include, /usr/lib64/clang/10.0.0/include and others.
And because I don't have /usr/lib64/clang/10.0.0/include in include paths defined, later I see this error running crystal spec:

In file included from /tmp/.kMdBOGbindgen:1:
In file included from /home/zawertun/tmp/bindgen@Papierkorb/spec/integration/c_wrapper.cpp:1:
In file included from /usr/lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/cstdlib:75:
/usr/include/stdlib.h:31:10: fatal error: 'stddef.h' file not found
#include <stddef.h>
         ^~~~~~~~~~

File stddef.h can be found in the /usr/lib64/clang/10.0.0/include dir, if I add this include manually - crystal spec finishes without errors.

@docelic
Copy link
Collaborator

docelic commented May 13, 2020

Will check what's going on.

@ZaWertun
Copy link
Contributor Author

It just takes next item after -internal-isystem.

when "-internal-isystem"
      system_include_dirs << flags[index + 1]
      index += 1

I'll create PR.

@docelic
Copy link
Collaborator

docelic commented May 13, 2020

Merged, thanks! I guess further improvements to this (e.g. possibly using llvm-config to get these flags instead of clang++) can be done through #36 at some later point.

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

Successfully merging a pull request may close this issue.

2 participants