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

Export CLANG_PATH so bindgen works with cross compilation #171

Merged
merged 2 commits into from
Feb 1, 2023

Conversation

jasta
Copy link
Contributor

@jasta jasta commented Jan 27, 2023

Fixes #164

CLANG_PATH is relevant for bindgen to be able to find required headers and library files. Without exporting this along with LIBCLANG_PATH, you'll get a mismatch using bindgen and if the host clang doesn't support full cross compilation of C code (which is common for Ubuntu in my case, at least), then ultimately bindgen will not be able to compile the code its trying to generate bindings for. The user will see weird errors like basic types int16_t and such are missing or common header files like string.h aren't available.

Fixes esp-rs#164

CLANG_PATH is relevant for bindgen to be able to find required headers
and library files.  Without exporting this along with LIBCLANG_PATH,
you'll get a mismatch using bindgen and if the host clang doesn't
support full cross compilation of C code (which is common for Ubuntu in
my case, at least), then ultimately bindgen will not be able to compile
the code its trying to generate bindings for.  The user will see weird
errors like basic types int16_t and such are missing or common header
files like string.h aren't available.
@jasta
Copy link
Contributor Author

jasta commented Jan 27, 2023

BTW I ran into an issue testing this PR on the latest main branch:

https://gist.github.com/2fbeb823580cff6b56994d68f0720904

Using cargo run --release fixed the issue? Weird...

Copy link
Member

@SergioGasquez SergioGasquez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution! I just left a few minor comments, and, rebasing should fix the CI issues.

src/toolchain/llvm.rs Outdated Show resolved Hide resolved
src/toolchain/llvm.rs Outdated Show resolved Hide resolved
Co-authored-by: Sergio Gasquez Arcos <[email protected]>
@SergioGasquez SergioGasquez merged commit 8e45be7 into esp-rs:main Feb 1, 2023
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 this pull request may close these issues.

export-esp.sh does not set CLANG_PATH which can confuse bindgen (and any crate using clang-sys)
2 participants