8000 BLD: Remove use of `libnpymath` and `libnpyrandom` · Issue #17498 · scipy/scipy · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
BLD: Remove use of libnpymath and libnpyrandom #17498
@rgommers

Description

@rgommers

We should get this done for 1.11.0. Using static libraries from numpy is unhealthy. Let me summarize the main problems and link some related issues.

From #17481 (comment):
The main issue is using a static library at all. This is bad, mainly for these two reasons:

  1. It is not guaranteed that numpy and scipy are built with the same compilers. And that leads to potential issues that are hard to predict, as we've experienced multiple times already. Especially on Windows, where we build scipy with mingw and numpy with MSVC. That was the reason why using the vc142 instead of the vc141 toolchain in numpy 1.21.5-1.22.1 led to complex issues and that change had to be reverted.
  2. Cross-compiling tends to break. We haven't officially supported that in the past, but even in the one case where we do it (macOS x64-64 to arm64) it goes pretty horribly wrong: we stuff the x86-64 libnpymath.a into the macOS scipy wheel. This silently worked, because the required symbols were already loaded by numpy itself. Now that they're being removed from numpy, we're all of a sudden loading them from libnpymath.a and they have the wrong architecture.

For more details, see numpy/numpy#20880.

Here are some related issues where the use of libnpmath showed up as a problem:

What we should do is described in numpy/numpy#20880 (comment). Basically, vendor the sources for the functions/typedefs we still need, and rebuild them as part of the SciPy build. This is probably best done by refactoring the numpy sources a bit so there's a standalone C99 compat library with only the complex typedefs, complex functions from C99 that MSVC doesn't provide, and the blocklisted functions. And then add a command-line switch to the numpy meson build to only build that library (use a meson disabler object for that). And include numpy as a meson subproject in the scipy source tree - this is kinda like a git submodule - so we can build it as needed, and don't actually need to vendor anything.

I don't have the bandwidth to push this forward now, but should be able to do so in Q1'23.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Build issuesIssues with building from source, including different choices of architecture, compilers and OStaskA straightforward change, verification or fix.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0