esp-rs / rust

Rust for the xtensa architecture. Built in targets for the ESP32 and ESP8266
https://www.rust-lang.org
Other
742 stars 39 forks source link

esp32s3 miscompilation (with `lto = false`) #186

Closed dimpolo closed 1 year ago

dimpolo commented 1 year ago

I tried this code:

repo: https://github.com/dimpolo/miscompile relevant code: https://github.com/dimpolo/miscompile/blob/cc4b61b113115887343097f9ba7df3f8ed0e9556/src/main.rs#L32-L45

cargo run
cargo run --release

I expected to see this happen: adding --release should not make a difference

Instead, this happened:

 > cargo run
-0.5732682
-0.57328224
-0.57328206
-0.5732818
-0.57328165
-0.5732814
-0.5732812
-0.573281
-0.5732808
-0.57328063
...

 > cargo run --release
0.5732682
1.7202483
4.0127697
8.573706
17.47281
33.58494
56.554703
76.10143
85.23757
88.43065
...

Meta

rustc --version --verbose:

rustc 1.71.0-nightly (4ca000ac8 2023-07-13) (1.71.0.1)
binary: rustc
commit-hash: 4ca000ac85a4f486ed080c281c86ea2287592027
commit-date: 2023-07-13
host: x86_64-pc-windows-msvc
release: 1.71.0-nightly
LLVM version: 16.0.4

Sorry this isn't very minimized, but the linked repo should be a good enough starting point

MabezDev commented 1 year ago

Your repo links 404 for me. Is it a duplicate of #180 perhaps?

dimpolo commented 1 year ago

Sorry, forgot to set it to public. Reading through that issue this is quite likely a duplicate. Adding rustflags = [..., "-C", "target-feature=-fp"] solved my issue. Might I suggest to update the name of #180 to something like "miscompilation of hardware float multiplication"?