-
Notifications
You must be signed in to change notification settings - Fork 24
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
Unable to depend on any crate using cc or bindgen (std only) #163
Comments
Hello! Thanks for documenting and filling in the issues! Just a few notes:
But, in any case, I think it would be very beneficial to have some documentation in the book |
I have only been testing the std use case so that certainly makes sense. All of the problems I ran into have reasonable local solutions available (except the bindgen patch I needed), so once that's landed I think the problem can be neatly wrapped up with some minor fixes to espup (i.e. add |
Turns out the |
@SergioGasquez reading the discussion more closely, I wonder if perhaps there's another more elegant way to fix #164. There's a few separate issues here, so let me try to be specific: Regarding only the use of clang for bindgen, the issue I'm running into without espup's clang is that my host clang gives a bunch of errors like:
By simply setting CLANG_PATH to the clang provided by espup the issue goes away? I don't even need LIBCLANG_PATH. Maybe this is just a PEBKAC issue, but it's hard to see how right now given all the magic in Rust's cross compilation story :) Regarding only the gcc toolchain for esp32, you're correct that these tools are provided in the .embuild directory already so my project can simply have a script that adds, e.g. |
Do you any other clang installed in your system other than espressif clang? If I'm not mistaken, LIBCLANG_PATH is only required in this scenario. I will look to your awesome research when I get back from vacations. Thanks a lot for all your efforts! |
Yes, I have clang-14 from Ubuntu. Digging deeper what's happening here is that even though my host clang supports riscv32 as a target, it doesn't have all the includes and such to realistically compile anything. The expectation is that you can provide some more functional gcc toolchain with all this stuff and then point clang at that to do real work. The espressif packaging of clang does this all for you and bakes the configuration into the binary so it "just works" for both host and target compilation (of xtensa or riscv32). So espup (or something like it) it seems is important even in the world of full Rust and clang support for these targets because you'll still want a way to provide users with a functional clang toolchain for cross compilation. In an ideal world I'd expect rustup to handle this, however. That is, if I tell rustup to install a toolchain for riscv32imc-unknown-none-elf, I expect to be able to compile both pure Rust crates and sys crates utilizing C code targeting that platform. Right now I only get the former.
Just hoping to remove some of the barriers for others getting into this space. I'm just starting out with MCU programming and was hoping Rust could shave off some of the rough edges. For the most part it definitely has, but it added a few sharp corners too :) |
All wrapped up for RISC-V targets. Xtensa support needs a change in cc-rs once it's made tier 3. To work around all you need is |
Thanks for all your research and improving |
Bug description
After completing the espup setup steps here: https://esp-rs.github.io/book/installation/installation.html, a user is unable to depend on any crate that uses cc or bindgen (i.e. any crate that uses C code). This also includes using your own C code in your project with a simple build.rs utilizing the cc crate.
There are several distinct problems here, and I'll attempt to outline them each with tracking issues:
{riscv32imc,xtensa}-esp*-espidf
to CLang triple (e.g.riscv32imc-esp-espidf
toriscv32-esp-elf
)Would you like to work on a fix? Yes
To Reproduce
Steps to reproduce the behavior:
Expected behavior
It's expected that esp-rs projects work when adding dependencies to other crates which utilize C/C++ code via the standard tool paths (cc and bindgen at a minimum).
Screenshots
N/A
Environment
Additional context
Note: I've fixed most of the issues already but need some time to organize the PRs and tracking issues.
The text was updated successfully, but these errors were encountered: