Closed elotom closed 1 year ago
Same for updated rustc: rustc 1.69.0-nightly (e7a099116 2023-04-17) (1.69.0.0) binary: rustc commit-hash: e7a0991164b497f97a9af93183eb4ea51d0f5c48 commit-date: 2023-04-17 host: x86_64-unknown-linux-gnu release: 1.69.0-nightly LLVM version: 15.0.0
I have checked the latest version also with the same result: rustc 1.69.0-nightly (4896f6b45 2023-05-16) (1.69.0.1) binary: rustc commit-hash: 4896f6b455b005c410fb7ef87a2f96bf5b1b73cb commit-date: 2023-05-16 host: x86_64-unknown-linux-gnu release: 1.69.0-nightly LLVM version: 16.0.1
Tested also the latest IDF-5.1 with gcc riscv32-esp-elf-gcc (crosstool-NG esp-12.2.0_20230208) 12.2.0 with the same result
This is most likely some ABI issue between GCC & LLVM, given that it's for a RISCV target this is probably worth posting upstream. They would most likely want it to be reproducible without hardware though.
You could try building esp-idf with clang and see if that helps. You can do this by installing the clang component via idf_tools.py install esp-clang
and then setting the toolchain to clang via export IDF_TOOLCHAIN=clang
.
This is most likely some ABI issue between GCC & LLVM, given that it's for a RISCV target this is probably worth posting upstream. They would most likely want it to be reproducible without hardware though.
You could try building esp-idf with clang and see if that helps. You can do this by installing the clang component via
idf_tools.py install esp-clang
and then setting the toolchain to clang viaexport IDF_TOOLCHAIN=clang
.
Compiling my C sources with Clang fixed the issue.
In which case I'll close this! Hopefully upstream both GCC and CLANG soft float ABI converge towards eachother.
@MabezDev Is building ESP-IDF with clang
an officially (or semi-officially) supported option now?
@MabezDev Is building ESP-IDF with
clang
an officially (or semi-officially) supported option now?
I'm not sure on official, but I would guess semi-official, as in it should be doable. Expect more issues on Xtensa though (with regards to code size, last time I checked a clang built bootloader exceeded the 64KB allowance, but maybe that's changed.).
Do you have any pointer to the upstream gcc/clang ABI mismatches? Are these only w.r.t. soft-float? Even so, sounds quite scary and weird. As in stuff compiled with clang cannot interop with stuff compiled with gcc...
I never found any upstream issues about it, and tbh, it was just a hunch on my end. It seemed to solve the issue for @elotom though, perhaps that can expand on thier findings.
I'm binding a Rust function to a C function that uses floating point operations. When the float/double variable is set to the value != 0 I got a panic (Illegal instruction) exception. I'm using ESP32-C3-DEVKITC-02. I checked both idf releases 4.4 and 5.0 with the same result. My project code works fine on esp32S3.
To reproduce the issue please clone https://github.com/elotom/rust-esp32-std-demo/tree/c-float-panic-issue then run the following commands:
The C function only sets 1 to the float value. The same issue occurs for double variables.
The Rust function calls test_float() and the program panic:
rustc --version --verbose
: