-
Notifications
You must be signed in to change notification settings - Fork 50
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
ffigen is unable to locate system headers #338
Comments
I am not really not sure as to why ffigen is not able to detect the system headers, while clang can. Since ffigen utilises LLVM itself. I am guessing that You can just use compiler-opts to supply include path or you can also set the environment variable About the The best way to detect if the bindings are not correct as of now, would be to check for We do currently use non zero exit code but thats only when ffigen is not able to generate anything. But I guess it would be a good to have a non zero exit code incase ffigen emitted any |
Thanks @mannprerak2 that makes sense. I'm not exactly sure how to proceed here, because the required This feels a bit like dart-archive/ffigen#193 where |
Since the env variable export CPATH="$(clang -v 2>&1 | grep "Selected GCC installation" | rev | cut -d' ' -f1 | rev)/include" Now I don't have to run |
This is what I usually use on Linux to find missing stuffs:
For example, for
|
I had the same issue on Windows, and I fixed this by running ffigen in a |
I've had similar issues developing https://github.com/dart-lang/native/tree/main/pkgs/c_compiler. The requirement there is that it's all native/pkgs/c_compiler/lib/src/cbuilder/run_cbuilder.dart Lines 164 to 167 in 2de8813
Even when using clang, you need the system headers from a visual studio installation (clang doesn't have system headers for Windows). When Until then using @timleg002's solution is a good workaround. |
Bumps [actions/setup-java](https://github.com/actions/setup-java) from 3.11.0 to 3.12.0. - [Release notes](https://github.com/actions/setup-java/releases) - [Commits](actions/setup-java@5ffc13f...cd89f46) --- updated-dependencies: - dependency-name: actions/setup-java dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [actions/setup-java](https://github.com/actions/setup-java) from 3.11.0 to 3.12.0. - [Release notes](https://github.com/actions/setup-java/releases) - [Commits](actions/setup-java@5ffc13f...cd89f46) --- updated-dependencies: - dependency-name: actions/setup-java dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
My understanding is that
ffigen
should use the same system include path asclang
, but when I runffigen
on Linux it is unable to find several system header files (stdarg.h
,stdbool.h
, etc.) whileclang
andgcc
are able to locate them and compile code perfectly fine.This was originally reported as fzyzcjy/flutter_rust_bridge#108, but after some investigation we found the underlying bug was in
ffigen
. This may also be related to #345.Steps to reproduce:
Interestingly, if I run
ffigen
from/
(requires replacing theoutput
field with its absolute path), the header files are located correctly.The generated bindings without extra compiler options:
The code generated *with* extra compiler options:
As a side note, whenever this happens
ffigen
falls back to usingint
for any types it is unable to locate instead of erroring out (i.e. returning a non-zero exit code), meaning the only way for a build tool to detect these errors is by doing a hackystring.contains()
on the output.Instead of falling back to
int
,ffigen
should omit a function entirely when it contains a type that can't be resolved. Unless the caller gets lucky and the function actually does return something that is compatible withffi.Int32
, any attempt to use the generated wrapper is going to result in broken code or UB.The text was updated successfully, but these errors were encountered: