Skip to content

BUG: NetBSD: fails due to missing log2l(), log1pl(), and expm1l() #23379

Open

Description

@0-wiz-0

Describe the issue:

numpy builds fine on NetBSD with Python 3.11.2. However, when running the self tests, I see an error.

/usr/pkg/bin/python3.11 -c "import numpy; numpy.test()"
Traceback (most recent call last):
  File "/scratch/wip/py-numpy/work/.destdir/usr/pkg/lib/python3.11/site-packages/numpy/core/__init__.py", line 23, in <module>
    from . import multiarray
  File "/scratch/wip/py-numpy/work/.destdir/usr/pkg/lib/python3.11/site-packages/numpy/core/multiarray.py", line 10, in <module>
    from . import overrides
  File "/scratch/wip/py-numpy/work/.destdir/usr/pkg/lib/python3.11/site-packages/numpy/core/overrides.py", line 6, in <module>
    from numpy.core._multiarray_umath import (
ImportError: /scratch/wip/py-numpy/work/.destdir/usr/pkg/lib/python3.11/site-packages/numpy/core/_multiarray_umath.so: Undefined PLT symbol "log2l" (symnum = 437)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/scratch/wip/py-numpy/work/.destdir/usr/pkg/lib/python3.11/site-packages/numpy/__init__.py", line 141, in <module>
    from . import core
  File "/scratch/wip/py-numpy/work/.destdir/usr/pkg/lib/python3.11/site-packages/numpy/core/__init__.py", line 49, in <module>
    raise ImportError(msg)
ImportError: 

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.11 from "/usr/pkg/bin/python3.11"
  * The NumPy version is: "1.24.2"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: /scratch/wip/py-numpy/work/.destdir/usr/pkg/lib/python3.11/site-packages/numpy/core/_multiarray_umath.so: Undefined PLT symbol "log2l" (symnum = 437)

Reproduce the code example:

Try running the self tests for numpy 1.24.2 on NetBSD.

Error message:

See above.

Runtime information:

Can't print that due to the import error shown above.
Python 3.11.2, numpy 1.24.2.

Context for the issue:

This is obviously a bug in NetBSD (http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=53234) but perhaps you can suggest a workaround.
This problem is new in the 1.24.x series of numpy, 1.23.5 builds and tests (mostly) fine in the same environment:
8 failed, 18561 passed, 782 skipped, 1306 deselected, 41 xfailed, 2 xpassed, 59 warnings in 199.07s (0:03:19)

Activity

  1. 0-wiz-0 commented on Mar 13, 2023

    @0-wiz-0
    Author

    The following hack made numpy 1.24.2 build and run the self tests on NetBSD:

    --- numpy/core/src/common/mem_overlap.c.orig    2023-02-05 17:13:47.573364500 +0000
    +++ numpy/core/src/common/mem_overlap.c
    @@ -921,3 +921,17 @@ solve_may_have_internal_overlap(PyArrayO
         /* Solve */
         return solve_diophantine(nterms, terms, -1, max_work, 1, x);
     }
    +
    +#ifdef __NetBSD__
    +/* hack for missing log2l() symbol - see https://github.com/numpy/numpy/issues/23379 */
    +/* in this file because it's included by all _multiarray_* so files */
    +long double log2l(long double arg) {
    +    return log2(arg);
    +}
    +long double log1pl(long double arg) {
    +    return log1p(arg);
    +}
    +long double expm1l(long double arg) {
    +    return expm1(arg);
    +}
    +#endif
    --- numpy/linalg/umath_linalg.cpp.orig  2023-02-05 17:13:47.689365400 +0000
    +++ numpy/linalg/umath_linalg.cpp
    @@ -4567,3 +4567,16 @@ PyMODINIT_FUNC PyInit__umath_linalg(void
     
         return m;
     }
    +
    +#ifdef __NetBSD__
    +/* hack for missing log2l() symbol - see https://github.com/numpy/numpy/issues/23379 */
    +long double log2l(long double arg) {
    +    return log2(arg);
    +}
    +long double log1pl(long double arg) {
    +    return log1p(arg);
    +}
    +long double expm1l(long double arg) {
    +    return expm1(arg);
    +}
    +#endif
    

    Obviously this is not intended to be committed as-is but as an inspiration for a fix :)

    Test result afterwards:

    FAILED .destdir/usr/pkg/lib/python3.11/site-packages/numpy/core/tests/test_casting_floatingpoint_errors.py::test_floatingpoint_errors_casting[longdouble-to-f8] - Failed: DID NOT WARN. No warnings of type (<class 'RuntimeWarning'>,) were emitted.
    FAILED .destdir/usr/pkg/lib/python3.11/site-packages/numpy/core/tests/test_getlimits.py::test_known_types - AssertionError:
    FAILED .destdir/usr/pkg/lib/python3.11/site-packages/numpy/core/tests/test_nep50_promotions.py::test_nep50_weak_integers_with_inexact[g] - OverflowError: cannot convert longdouble infinity to integer
    FAILED .destdir/usr/pkg/lib/python3.11/site-packages/numpy/core/tests/test_nep50_promotions.py::test_nep50_weak_integers_with_inexact[G] - OverflowError: cannot convert longdouble infinity to integer
    FAILED .destdir/usr/pkg/lib/python3.11/site-packages/numpy/core/tests/test_numeric.py::TestFloatExceptions::test_floating_exceptions[g] - AssertionError: Type <class 'numpy.ndarray'> did not raise fpe error 'underflow'.
    FAILED .destdir/usr/pkg/lib/python3.11/site-packages/numpy/core/tests/test_numeric.py::TestFloatExceptions::test_floating_exceptions[G] - AssertionError: Type <class 'numpy.complex256'> did not raise fpe error ''.
    FAILED .destdir/usr/pkg/lib/python3.11/site-packages/numpy/core/tests/test_umath.py::TestSpecialFloats::test_unary_spurious_fpexception[data10-escape10-e-log1p] - AssertionError: Got warnings: [<warnings.WarningMessage object at 0x735181aa5160>]
    FAILED .destdir/usr/pkg/lib/python3.11/site-packages/numpy/core/tests/test_umath.py::TestSpecialFloats::test_unary_spurious_fpexception[data10-escape10-f-log1p] - AssertionError: Got warnings: [<warnings.WarningMessage object at 0x7351814c2e60>]
    FAILED .destdir/usr/pkg/lib/python3.11/site-packages/numpy/core/tests/test_umath.py::TestSpecialFloats::test_unary_spurious_fpexception[data10-escape10-d-log1p] - AssertionError: Got warnings: [<warnings.WarningMessage object at 0x7351848473e0>]
    FAILED .destdir/usr/pkg/lib/python3.11/site-packages/numpy/core/tests/test_umath.py::TestSpecialFloats::test_unary_spurious_fpexception[data11-escape11-e-log1p] - AssertionError: Got warnings: [<warnings.WarningMessage object at 0x735184856520>]
    FAILED .destdir/usr/pkg/lib/python3.11/site-packages/numpy/core/tests/test_umath.py::TestSpecialFloats::test_unary_spurious_fpexception[data11-escape11-f-log1p] - AssertionError: Got warnings: [<warnings.WarningMessage object at 0x73518485f6a0>]
    FAILED .destdir/usr/pkg/lib/python3.11/site-packages/numpy/core/tests/test_umath.py::TestSpecialFloats::test_unary_spurious_fpexception[data11-escape11-d-log1p] - AssertionError: Got warnings: [<warnings.WarningMessage object at 0x735181588260>]
    FAILED .destdir/usr/pkg/lib/python3.11/site-packages/numpy/core/tests/test_umath.py::TestSpecialFloats::test_unary_spurious_fpexception[data12-escape12-e-log1p] - AssertionError: Got warnings: [<warnings.WarningMessage object at 0x735184866520>]
    FAILED .destdir/usr/pkg/lib/python3.11/site-packages/numpy/core/tests/test_umath.py::TestSpecialFloats::test_unary_spurious_fpexception[data12-escape12-f-log1p] - AssertionError: Got warnings: [<warnings.WarningMessage object at 0x735184871420>]
    FAILED .destdir/usr/pkg/lib/python3.11/site-packages/numpy/core/tests/test_umath.py::TestSpecialFloats::test_unary_spurious_fpexception[data12-escape12-d-log1p] - AssertionError: Got warnings: [<warnings.WarningMessage object at 0x73518487f2a0>]
    FAILED .destdir/usr/pkg/lib/python3.11/site-packages/numpy/core/tests/test_umath.py::TestSpecialFloats::test_unary_spurious_fpexception[data13-escape13-e-log1p] - AssertionError: Got warnings: [<warnings.WarningMessage object at 0x7351848872a0>]
    FAILED .destdir/usr/pkg/lib/python3.11/site-packages/numpy/core/tests/test_umath.py::TestSpecialFloats::test_unary_spurious_fpexception[data13-escape13-f-log1p] - AssertionError: Got warnings: [<warnings.WarningMessage object at 0x735181588260>]
    FAILED .destdir/usr/pkg/lib/python3.11/site-packages/numpy/core/tests/test_umath.py::TestSpecialFloats::test_unary_spurious_fpexception[data13-escape13-d-log1p] - AssertionError: Got warnings: [<warnings.WarningMessage object at 0x735184892da0>]
    FAILED .destdir/usr/pkg/lib/python3.11/site-packages/numpy/core/tests/test_umath.py::TestSpecialFloats::test_unary_spurious_fpexception[data14-escape14-e-log1p] - AssertionError: Got warnings: [<warnings.WarningMessage object at 0x73518489bde0>]
    FAILED .destdir/usr/pkg/lib/python3.11/site-packages/numpy/core/tests/test_umath.py::TestSpecialFloats::test_unary_spurious_fpexception[data14-escape14-f-log1p] - AssertionError: Got warnings: [<warnings.WarningMessage object at 0x7351848a5de0>]
    FAILED .destdir/usr/pkg/lib/python3.11/site-packages/numpy/core/tests/test_umath.py::TestSpecialFloats::test_unary_spurious_fpexception[data14-escape14-d-log1p] - AssertionError: Got warnings: [<warnings.WarningMessage object at 0x7351848899a0>]
    FAILED .destdir/usr/pkg/lib/python3.11/site-packages/numpy/core/tests/test_umath.py::TestSpecialFloats::test_unary_spurious_fpexception[data15-escape15-e-log1p] - AssertionError: Got warnings: [<warnings.WarningMessage object at 0x7351848c3a60>]
    FAILED .destdir/usr/pkg/lib/python3.11/site-packages/numpy/core/tests/test_umath.py::TestSpecialFloats::test_unary_spurious_fpexception[data15-escape15-f-log1p] - AssertionError: Got warnings: [<warnings.WarningMessage object at 0x7351848d6b20>]
    FAILED .destdir/usr/pkg/lib/python3.11/site-packages/numpy/core/tests/test_umath.py::TestSpecialFloats::test_unary_spurious_fpexception[data15-escape15-d-log1p] - AssertionError: Got warnings: [<warnings.WarningMessage object at 0x7351848e1ae0>]
    FAILED .destdir/usr/pkg/lib/python3.11/site-packages/numpy/core/tests/test_umath.py::TestAVXUfuncs::test_avx_based_ufunc - AssertionError:
    FAILED .destdir/usr/pkg/lib/python3.11/site-packages/numpy/core/tests/test_umath.py::TestAVXFloat32Transcendental::test_sincos_float32 - AssertionError: Arrays are not almost equal up to 2 ULP (max difference is 67 ULP)
    FAILED .destdir/usr/pkg/lib/python3.11/site-packages/numpy/core/tests/test_umath.py::test_nextafter_0 - AssertionError
    FAILED .destdir/usr/pkg/lib/python3.11/site-packages/numpy/distutils/tests/test_log.py::test_log_prefix[info] - AssertionError: assert ''
    FAILED .destdir/usr/pkg/lib/python3.11/site-packages/numpy/distutils/tests/test_log.py::test_log_prefix[debug] - AssertionError: assert ''
    29 failed, 26625 passed, 1481 skipped, 1307 deselected, 35 xfailed, 2 xpassed, 40 warnings in 237.85s (0:03:57)
    
  2. changed the title [-]BUG: NetBSD: fails due to missing log2l()[/-] [+]BUG: NetBSD: fails due to missing log2l(), log1pl(), and expm1l()[/+] on Mar 13, 2023
  3. mattip commented on Mar 13, 2023

    @mattip
    Member

    We made those functions mandatory since they are part of C99. The issue you pointed to is from 2018. Does NetBSD have a plan to become compliant? This is another example how the long double type causes more pain than gain...

  4. riastradh commented on Mar 14, 2023

    @riastradh

    We made those functions mandatory since they are part of C99. The issue you pointed to is from 2018. Does NetBSD have a plan to become compliant? This is another example how the long double type causes more pain than gain...

    We have added definitions wrapping the double versions for now until someone has the time to implement proper 80-bit and 128-bit algorithms. These definitions may appear in NetBSD 10, but not in NetBSD 9, which will remain supported for probably a couple more years before NetBSD 11. So we'll still need to work around these missing symbols for a while.

    I agree the noncompliance is bad, but long double has always been a bit of an inconsistent ugly duckling and not widely used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions