-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
lib/libm/wf_[lt]gamma: Define _IEEE_LIBM only if not set. #15183
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
Conversation
Code size report:
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #15183 +/- ##
=======================================
Coverage 98.39% 98.39%
=======================================
Files 161 161
Lines 21204 21204
=======================================
Hits 20864 20864
Misses 340 340 ☔ View full report in Codecov by Sentry. |
Since the code only ever uses |
@agatti Given that knowledge, do you think the change in this PR is still a good way forward, does it fix the crash? |
@dpgeorge I believe this is still needed. This PR will fix the case when you want to use Picolibc's libc with MicroPython's libm - the TLS issue is for when you want to use both Picolibc's libc and libm, and MicroPython for everything else. I can add the TLS fix to #12853 if you think it's needed in the context of a RISC-V test environment to also work with an external libm implementation. |
Better yet, with this PR in, the CI scripts can be updated to include Picolibc compatibility tests for Arm and Lx106 targets. The CI machine can have |
Ooh, I think this would be very interesting! I've been side-eyeing the amount of newlib stuff that ends up in the stm32 builds lately, and wondering how much code size we'd save by using picolibc instead... |
For now is it reasonable for MicroPython to not support or test that combo, assuming the riscv picolibc builds work properly with MicroPython libm? Similar to my previous comment, though, it might be interesting to experiment with picolibc libm at some point, as a comparison for code size, performance, and accuracy. I haven't looked, but I'm guessing it might be more optimised for riscv perhaps? |
(Off-topic comment about the fdlibm readme.)
This unexpectedly triggered a bit of nostalgia. 😿 |
That's what I think as well. In fact if you get the latest
As an aside, whilst waiting for something else to compile I did try that with minimal TLS initialisation code to see that for myself. Weirdly, the |
fdilibm was originally meant to see _IEEE_LIBM defined from outside the libm code, not it being hardcoded in. Picolibc assumes this assumption holds true and attempts to define itself, conflicting with the existing definition. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
4978959
to
d7aa2fe
Compare
That would be interesting to try, using picolibc instead of newlib. In the meantime, this PR is good to merge. |
fdilibm was originally meant to see _IEEE_LIBM defined from outside the libm code, not it being hardcoded in (see section 4 in https://netlib.org/fdlibm/readme). Picolibc assumes this assumption holds true and attempts to define it itself, conflicting with the existing definition.
Although Picolibc provides its own libm support, on RISC-V the version of Picolibc installed on the CI machine currently crashes when running the math tests. This is a stop-gap solution that would make things work until either a fix for the test crashes is found or a newer version of Picolibc is provided by the CI machine's package repository.
Edit: Picolibc crashes due to its lgammaf implementation requiring TLS support enabled.