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

compilation failure with "cargo check --tests" for espidf #125714

Open
benstockil opened this issue May 29, 2024 · 1 comment
Open

compilation failure with "cargo check --tests" for espidf #125714

benstockil opened this issue May 29, 2024 · 1 comment
Labels
C-bug Category: This is a bug. O-ESP-IDF Target: Espressif IoT Development Framework T-libs Relevant to the library team, which will review and decide on the PR/issue.

Comments

@benstockil
Copy link

Running cargo check --tests fails to compile test for the esp-idf-template (tested on mcu esp32-c3, default template options).

   Compiling test v0.0.0 (/home/ben/.local/share/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test)
error[E0308]: mismatched types
   --> /home/ben/.local/share/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/test_result.rs:102:18
    |
101 |         None => match status.signal() {
    |                       --------------- this expression has type `Option<i32>`
102 |             Some(libc::SIGABRT) => TestResult::TrFailed,
    |                  ^^^^^^^^^^^^^ expected `i32`, found `usize`

For more information about this error, try `rustc --explain E0308`.
error: could not compile `test` (lib) due to 1 previous error

rust-lang/libc#3658 introduced these constants for espidf, where previously the error was a missing constant altogether (rust-lang/rust-analyzer#16552).

Steps to Reproduce

  • cargo generate esp-rs/esp-idf-template cargo
    • Which MCU to target?: esp32c3
    • Configure advanced template options?: false
  • cd <project name> && cargo check --tests

Meta

rustc --version --verbose:

rustc 1.80.0-nightly (da159eb33 2024-05-28)
binary: rustc
commit-hash: da159eb331b27df528185c616b394bb0e1d2a4bd
commit-date: 2024-05-28
host: x86_64-unknown-linux-gnu
release: 1.80.0-nightly
LLVM version: 18.1.6
@benstockil benstockil added the C-bug Category: This is a bug. label May 29, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 29, 2024
@Vollbrecht
Copy link

Vollbrecht commented May 29, 2024

First of a short general remark, while we can push for making it possible to build crossplatform test this way they will never be runnable. For us the way forward is to build tests and use an external test harness, in the concrete case we are using the embedded-test crate for such adventures.

A current workaround to don't have rust-analyzer go insane on trying to build that tests the normal way is:
Explicitly tell it inside your Cargo.toml by defining a section - depending on if you are building a lib, bin or a test - with the harness=false field.
That will tell the system to not use the inbuilt rust test harness.

For your example project you would add a section like this

[[bin]]
name = "your project name"
harness = false

That said this answer is only trying to answer to the underlying issue of building test against espidf as a crossplatform target and
not going into the detail of defining the right or wrong things inside rust libc

@jieyouxu jieyouxu added T-libs Relevant to the library team, which will review and decide on the PR/issue. O-ESP-IDF Target: Espressif IoT Development Framework and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. O-ESP-IDF Target: Espressif IoT Development Framework T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants