llvmlite
llvmlite copied to clipboard
Skip test if libm is not found.
No guarantee that libm is search-able in path.
The test is failing in my OSX Big Sur.
Anyone with a BigSure system to confirm this fix?
I'm on BigSur and all tests pass without this patch: https://gist.github.com/guilhermeleobas/29863546c0e766bb438a7d4aa23c8f04
I'm on BigSur and all tests pass without this patch: https://gist.github.com/guilhermeleobas/29863546c0e766bb438a7d4aa23c8f04
OK. Thank you! Just to confirm: this patch is NOT needed for you on OSX Big Sur and all tests pass fine?
I'm on BigSur and all tests pass without this patch: https://gist.github.com/guilhermeleobas/29863546c0e766bb438a7d4aa23c8f04
OK. Thank you! Just to confirm: this patch is NOT needed for you on OSX Big Sur and all tests pass fine?
Yes, that's correct!
@sklam is this needed? Or did it turn out to be some anomaly on your system?
Think this is a real issue.
TBH don't recall macOS shipping a libm per se in the past. Instead macOS provides this functionality through system libraries (like libSystem.B.dylib). It use to be that one wouldn't link to libm on macOS as it didn't exist (so one had to handle this specially in build scripts). However macOS now ships a libm.tbd (perhaps for ease of use?), but this is just a shim to system libraries.
To demonstrate this we can take a C file like so
#include <math.h>
#include <stdio.h>
int main() {
printf("The value of e is: %f\n", exp(1));
return 0;
}
Build it (works fine whether or not -lm is there)...
$ clang -lm main.c
...and inspect the linkages
$ otool -L ./a.out
./a.out:
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.100.3)
Note that no libm.dylib shows up.
Should add with the advent of dlyd shared cache on macOS 11, libSystem.B.dylib does not exist as a file either, but that is a different story.
Even though Python can return a result for this, it appears to be incorrect as well.
Python 3.10.5 | packaged by conda-forge | (main, Jun 14 2022, 07:09:13) [Clang 13.0.1 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes.util import find_library
>>> from os.path import exists
>>> find_library("m")
'/usr/lib/libm.dylib'
>>> exists(find_library("m"))
False
Also would note this test caused us issues in conda-forge recently ( https://github.com/conda-forge/llvmlite-feedstock/pull/62#issuecomment-1209762518 ).
Given all of this would suggest dropping this test on macOS or perhaps use libSystem.B.
xref: https://github.com/conda-forge/llvmlite-feedstock/pull/62#issuecomment-1210408912 suggest discussing a point release to coincide with Numba 0.56.1 to patch this test.
I've cherrypicked the prefered changes from https://github.com/numba/llvmlite/pull/870 into this PR
Thanks Siu! 🙏 Should add improvements on that are welcome (if others have any) 🙂
This is pending llvmlite_155.
This is pending
llvmlite_155.
This passed!
Thanks all! 🙏