llvmlite icon indicating copy to clipboard operation
llvmlite copied to clipboard

Skip test if libm is not found.

Open sklam opened this issue 4 years ago • 7 comments

No guarantee that libm is search-able in path.

The test is failing in my OSX Big Sur.

sklam avatar Jul 20 '21 16:07 sklam

Anyone with a BigSure system to confirm this fix?

esc avatar Jul 21 '21 08:07 esc

I'm on BigSur and all tests pass without this patch: https://gist.github.com/guilhermeleobas/29863546c0e766bb438a7d4aa23c8f04

guilhermeleobas avatar Nov 13 '21 21:11 guilhermeleobas

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?

esc avatar Nov 15 '21 09:11 esc

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!

guilhermeleobas avatar Nov 15 '21 14:11 guilhermeleobas

@sklam is this needed? Or did it turn out to be some anomaly on your system?

gmarkall avatar Dec 21 '21 16:12 gmarkall

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.

jakirkham avatar Aug 09 '22 20:08 jakirkham

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.

stuartarchibald avatar Aug 10 '22 09:08 stuartarchibald

I've cherrypicked the prefered changes from https://github.com/numba/llvmlite/pull/870 into this PR

sklam avatar Aug 23 '22 18:08 sklam

Thanks Siu! 🙏 Should add improvements on that are welcome (if others have any) 🙂

jakirkham avatar Aug 23 '22 18:08 jakirkham

This is pending llvmlite_155.

esc avatar Aug 24 '22 15:08 esc

This is pending llvmlite_155.

This passed!

esc avatar Aug 24 '22 19:08 esc

Thanks all! 🙏

jakirkham avatar Aug 24 '22 22:08 jakirkham