Open Nyrmburk opened 3 weeks ago
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 LIBCLANG_PATH
by sourcing export-esp.sh
seems to interfere with the compilation of the regular x86_64-unknown-linux-gnu
target when bindgen
is used by crates:
thread 'main' panicked at /home/alix_anneraud/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bindgen-0.69.4/lib.rs:899:13:
assertion `left == right` failed: "x86_64-unknown-linux-gnu" "x86_64-unknown-linux-gnu"
left: 4
right: 8
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/littlefs2This 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-sysThe
build.rs
file is very simple: https://github.com/trussed-dev/littlefs2-sys/blob/main/build.rscargo 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/ringAdding 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.