xous-core icon indicating copy to clipboard operation
xous-core copied to clipboard

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

Open bunnie opened this issue 2 years ago • 3 comments

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 avatar Dec 15 '22 05:12 bunnie

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

bunnie avatar Dec 15 '22 05:12 bunnie

Did some investigations.

  • [x] see if mold can work with this - yes, but: can't handle custom kernel link.x script (not a feature of mold), requires PIC, which isn't enabled in current std, thus would require a patch to std that could cause it to not be upstreamable. aborting approach. Note build time of services goes from 28s to 20s, so about 30% improvement with mold.
  • [x] see if gold can work with this - NO, gold is bit-rotted and does not support risc-v
  • [x] see if ld can work with this xobs found that the bug still exists (see image below)

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 avatar Dec 30 '22 18:12 bunnie

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.

bunnie avatar Jan 02 '23 16:01 bunnie