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

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

Open
bunnie opened this issue Dec 15, 2022 · 3 comments
Assignees
Labels
Blocked Issues blocked because of bugs in upstream projects

Comments

@bunnie
Copy link
Member

bunnie commented Dec 15, 2022

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 bunnie added the technical debt Not broken, but done poorly label Dec 15, 2022
@bunnie bunnie self-assigned this Dec 15, 2022
@bunnie
Copy link
Member Author

bunnie commented Dec 15, 2022

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

@bunnie
Copy link
Member Author

bunnie commented Dec 30, 2022

Did some investigations.

  • 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.
  • see if gold can work with this - NO, gold is bit-rotted and does not support risc-v
  • 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 added a commit that referenced this issue Jan 2, 2023
this was done by eliminating the use of the `cos()` function
in the Xous code base, which triggers the link time optimiztaion
bug.

The code is also smaller, too boot.
@bunnie
Copy link
Member Author

bunnie commented Jan 2, 2023

lto fat restored in 79be209 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 (rust-lang/rust#105734) ever gets fixed, especially if users eventually want to use cos(), sin(), etc.

@bunnie bunnie changed the title lto fat is broken in rust 1.66 Can't use f32 transcendental functions (sin, cos) because lto fat is broken in rust 1.66 Jan 2, 2023
@bunnie bunnie added Blocked Issues blocked because of bugs in upstream projects and removed technical debt Not broken, but done poorly labels Jan 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Blocked Issues blocked because of bugs in upstream projects
Projects
None yet
Development

No branches or pull requests

1 participant