BUG: SciPy linalg.logm
function signature mismatch with NumPy >=2.1.0rc1 due to hidden visibility for API tables
#27865
Labels
Uh oh!
There was an error while loading. Please reload this page.
Describe the issue:
Hi there, we've been facing an issue wherein we have a mismatch in the function signature for the
scipy.linalg.logm
function (internally, this is coming from the Schur decomposition and, in turn, from thedgees
LAPACK routine) for WASM/Pyodide in pyodide/pyodide#4925 when NumPy is compiled with the Emscripten toolchain.It is to be noted that Meson sets
-fvisibility=hidden
by default, thus overriding whatemcc
sets by default (which is-fvisibility=default
, confirmed usingemcc --flags
) – so this is the same issue as pyodide/pyodide#4310 that has been previously reported: the_npy_f2py_ARRAY_API
symbol is not exposed anymore (which it shouldn't be in a normal scenario, though).Compiling against NumPy >=1.26.4,<=2.0.2 works fine; @rgommers has pointed out that this has been coming from the changes introduced via gh-26103 or gh-26286 that first appeared in NumPy versions 2.1.0rc1 and later—which I agree are good in principle—but we have been overriding the symbol visibility anyway post the introduction of pyodide/pyodide#4313, which is something that we ought to fix, hence while this issue may inspect on a problem with
numpy.f2py
, it's also centred on guidance how to proceed with compiling SciPy to work correctly going forward against changes in NumPy and whether we should retain a patch that undoes such changes.More specifically, in the WASM code,
logm
is defined in the relevant memory addresscall_indirect (param i32) (result i32)
– but the value in the WASM table returnsnull
. For versions of NumPy that work, this symbol shows up with the namendarray_from_pyobj
.cc: @rgommers, @ryanking13, @hoodmane
For a reproducer, it is currently required to compile SciPy in-tree, since we don't build NumPy v2 and dependent packages with it yet (hence the PR to update it). Here are all the prerequisites (some system-level packages might still be required via apt/yum/dnf/Homebrew):
Once OpenBLAS and other libraries + Emscripten wheels for NumPy and SciPy get compiled, we can use them:
In this activated Python/Pyodide interpreter, please run the following code to
Reproduce the code example:
Error message:
Python and NumPy Versions:
Runtime Environment:
Context for the issue:
This affects pyodide/pyodide#4925, where we are trying to upgrade NumPy to version >=2, along with all its dependents.
We have some notes on debugging a function signature mismatch in Pyodide, which is where this bug report has originated from: https://pyodide.org/en/stable/development/debugging.html#debugging-runtimeerror-function-signature-mismatch
There are probably some useful insights from here onwards, too: pyodide/pyodide#4925 (comment)
The text was updated successfully, but these errors were encountered: