fix detection of math library in numpy build #3520
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
(created using
eb --new-pr
)NumPy detects the required math by trying to link a minimal code containing a call to
log(0.)
.The first try is without any libraries, which works with
gcc -fno-math-errno
(our optimization default)because the call gets removed due to not having any effect. So it concludes that
-lm
is not required.This then fails to detect availability of functions such as
acosh
which do not get removed in the sameway and so less exact replacements are used instead which e.g. fail the tests on PPC.
$MATHLIB=m
makes it try-lm
first and is supported until the Meson backend is used in 1.26+.The test code used is:
The issue can be reproduced by putting it in a file
test.c
and running:On PPC I see test failures in e.g. SciPy-bundle-2023.02-gfbf-2022b.eb & SciPy-bundle-2023.07-gfbf-2023a.eb
FAILED core/tests/test_umath.py::TestComplexFunctions::test_loss_of_precision[complex256] - AssertionError: (120, 1.78095631306534887655740488957533e-10, 5.2863423150802063925011506713427e-21, 'arcsinh')
However the issue is not limited to PPC although the fallback functions seem to be "good enough" on x86.
A minimal example I made: https://godbolt.org/z/zGYcW45qE and one that it fails to detect
casinh
without-lm