betrusted-io / xous-core

The Xous microkernel
Apache License 2.0
522 stars 85 forks source link

Can't use `f32` transcendental functions (`sin`, `cos`) because lto `fat` is broken in rust 1.66 #285

Open bunnie opened 1 year ago

bunnie commented 1 year ago

Rust 1.66 breaks lto fat due to a panic inside sin()/cos() routines.

This issue is to investigate this further. Two options:

  1. Create pure Rust versions of sin/cos that don't break in LTO
  2. Pull out the entire FFT analysis routine and do it on the tester host side

2 is probably the better outcome but definitely a lot more work and risk on production quality.

bunnie commented 1 year ago

Note: Losing fat and going to thin adds 600kiB to the Xous binary size

bunnie commented 1 year ago

Did some investigations.

Seems like we have to wait for llvm to fix this.

Next step: try to excise out the one broken function, or maybe it can be bodged around in some way...

image

bunnie commented 1 year ago

lto fat restored in 79be209790518d13541e5d0e3c8ec0eedbb00ff7 because I have gone through and eliminated calls to f32::cos() through the entire system and replaced it with a less-accurate, but more compact and more importantly not crashing quadrant table-lookup based cosine implementation.

The llvm issue is still real. Renaming the bug and leaving it open to remind ourselves to revisit the issue someday if the llvm issue (https://github.com/rust-lang/rust/issues/105734) ever gets fixed, especially if users eventually want to use cos(), sin(), etc.