-
Notifications
You must be signed in to change notification settings - Fork 123
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
Building sys crates with internal cc builder and bindgen #321
Comments
In most situation the "simplest" way is let esp-idf-sys handle the bindgen creation for you. In case of your littlefs example, its probably also good to use a forked version that is known to work on esp-idf. It already exist on the esp-idf component registry, so you could add it to the build process described here. That could give you a little-fs sys module inside the esp-idf-sys. You would than go and instead of using the -sys module from littlefs2 rust crate, directly use the generated bindgens from us. In other words the littlefs2 crate would not use its own -sys module but the one you now build. Other than that we propagate a bunch of information in the build script inside esp-idf-sys that gets produced by the embuild crate for consumption in downstream crates. This can be found here and you see it used in esp-idf-hal/svc buildscript. Overall the creation of FFI bindings and the building of a C library into a static lib and including it are two separate things. While not exactly the same but a similar case can be made about the rust bindings for the lvgl crate. I didn't look recently into it but i know that it can work with our system, without even knowing that we exist by essentially doing the heavy lifting by itself. They also generate a static C library and generate bindings off of that. |
The same issue occurs with wamr-rust-sdk. I'm not sure if this is related, but overriding
This issue did not occur before I updated to version 1.79.0 of the esp Rust toolchain. |
ring
orlittlefs2
.Is there a mechanism to forward the environment that is compiling the esp-idf to these other sys dependencies?
Template generate config:
Build failure with
littlefs2
:Crate: https://docs.rs/littlefs2/latest/littlefs2/
Repo: https://github.com/trussed-dev/littlefs2
This crate generates bindings and builds the C littlefs library with the
littlefs2-sys
crate:Crate: https://docs.rs/littlefs2-sys/latest/littlefs2_sys/
Repo: https://github.com/trussed-dev/littlefs2-sys
The
build.rs
file is very simple:https://github.com/trussed-dev/littlefs2-sys/blob/main/build.rs
cargo build results:
Adding the compiler bins to my path manually (fish shell):
From some other bugs I read here, it seems like bindgen might be trying to use some host resources instead of the cross compile ones?
Trying the same for the
ring
crate is extremely siimilar:Crate: https://lib.rs/crates/ring
Repo:https://github.com/briansmith/ring
Adding the compiler path for ring hit some compilation failures that are outside the scope of this issue. However if it succeeded, I think the following bindgen would fail for the same reason as littlefs2.
The text was updated successfully, but these errors were encountered: