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

--target=wasm32-unknown-unknown: 'stdio.h' file not found #2829

Open
ahaoboy opened this issue May 3, 2024 · 5 comments
Open

--target=wasm32-unknown-unknown: 'stdio.h' file not found #2829

ahaoboy opened this issue May 3, 2024 · 5 comments

Comments

@ahaoboy
Copy link

ahaoboy commented May 3, 2024

Input C/C++ Header

#include <stdio.h>

Bindgen Invocation

 bindgen ./test.h -o test.rs  -- --target=wasm32-unknown-unknown

stdlib.h, inttypes.h, string.h, assert.h also have the same problem

Actual Results

./test.h:1:10: fatal error: 'stdio.h' file not found
panicked at bindgen-cli/main.rs:52:36:
Unable to generate bindings: ClangDiagnostic("./test.h:1:10: fatal error: 'stdio.h' file not found\n")

Expected Results

No errors and compiled successfully

@pvdrz
Copy link
Contributor

pvdrz commented May 3, 2024

you need to tell clang where to find such headers for that platform.

@ahaoboy
Copy link
Author

ahaoboy commented May 4, 2024

you need to tell clang where to find such headers for that platform.

Can you explain this in more detail? How do I use the parameters passed to clang, because I don't know where the header files are exactly, and using other targets, it doesn't give me an error, is it because the environment is missing some libraries?

 bindgen ./test.h -o test.rs  -- --target=x86_64-unknown-linux-gnu

@pvdrz
Copy link
Contributor

pvdrz commented May 9, 2024

Yes, clang cannot find any stdio.h header for the wasm32-unknown-unknown target in the directories where system headers usually are. So you need to get the right toolchain for that target or use a target for which you actually have the headers.

I haven't ever cross compiled to wasm but I found this post stating that wasm32-unknown-unknown requires a special toolchain.

@ahaoboy
Copy link
Author

ahaoboy commented May 10, 2024

I found this post stating that wasm32-unknown-unknown requires a special toolchain.

This shows that many people have encountered the same problem, but we must use some cumbersome methods to bypass this problem. Using new toolchains such as zig-cc will increase the complexity. And this blog seems to be released on 2023-01-01, we can only look forward to subsequent support.

@pvdrz
Copy link
Contributor

pvdrz commented May 14, 2024

I don't think we can do anything from the bindgen side to alleviate this.

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