You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BUG: meson detection of openblas builds an executable without using pkg-config --static --libs #24827
libdir=/tmp/venv3/lib/python3.10/site-packages/scipy_openblas64/lib
includedir=/tmp/venv3/lib/python3.10/site-packages/scipy_openblas64/include
openblas_config= OpenBLAS 0.3.23.dev USE64BITINT DYNAMIC_ARCH NO_AFFINITY Zen MAX_THREADS=64
version=0.3.23.dev
extralib=-lm -lpthread -lgfortran -lm -lpthread -lgfortran
Name: openblas
Description: OpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 BSD version
Version: ${version}
URL: https://github.com/xianyi/OpenBLAS
Libs:
Libs.private: ${extralib} -L${libdir} -llibopenblas_python
Cflags: -I${includedir} -DBLAS_SYMBOL_SUFFIX=64_ -DBLAS_SYMBOL_SUFFIX=64_ -DHAVE_BLAS_ILP64
So when running non-static compilation, pkg-config openblas --libs will return an empty string (which is what I want, I will inject libopenblas_python into the executable's namespace by loading the DLL/SO before loading numpy), but when compiling the test code, meson should get the link arguments via pkg-config openblas --static --libs which will return the needed -L/tmp/venv3/lib/python3.10/site-packages/scipy_openblas64/lib -lm -lpthread -lgfortran -lm -lpthread -lgfortran -llibopenblas_python
The problematic compilation comes from numpy/meson.buildhere. How can that cc.links call be told "use static linking" ?
We never use static linking for BLAS/LAPACK, so this diff can't be right I think.
The problematic compilation comes from numpy/meson.buildhere. How can that cc.links call be told "use static linking"
If that's the actual problem, that cc.links call will disappear completely soon enough - we'll be asking Meson for "BLAS with CBLAS" and checks will happen under the hood.
I hope the meson checks under the hood know to differentiate between building an executable (like in the cc.links call) and the normal build of a shared library
I don't think this has anything to do with static linking. It's a normal check for whether a piece of code with a header links. The problem you're having is the use of dependencies: blas inside that cc.links call I think - that seems to do something unwanted for your use case.
It's a normal check for whether a piece of code with a header links.
The cc.link call tries to make an executable, which will want to resolve all the symbols at link time, which means it must use the full set of link libraries. But using the scipy-openblas wheels does a trick: it does not link to any openblas library. Instead, it loads the symbols at runtime globally so the executable can resolve them. Note how the patch changes the dependencies: blas to dependencies: blas_static in order to work around this.
Then the rest of the code continues as normal, throwing away the blas_static dependency and continuing with blas
So when running non-static compilation, pkg-config openblas --libs will return an empty string (which is what I want, I will inject libopenblas_python into the executable's namespace by loading the DLL/SO before loading numpy),
This is going to cause Meson to be confused, so the simpler solution is to simply not try to detect blas/lapack and cblas. If we specify scipy-openblas*, we already know it exists and that it was built with CBLAS. No need to try to confirm that.
Activity
mattip commentedon Sep 28, 2023
This diff solves the problem for the openblas-wheels #24749 build
mattip commentedon Sep 28, 2023
Will wait a bit for comments and corrections, feel free to close if this looks OK
rgommers commentedon Sep 28, 2023
We never use static linking for BLAS/LAPACK, so this diff can't be right I think.
If that's the actual problem, that
cc.linkscall will disappear completely soon enough - we'll be asking Meson for "BLAS with CBLAS" and checks will happen under the hood.mattip commentedon Sep 28, 2023
I hope the meson checks under the hood know to differentiate between building an executable (like in the
cc.linkscall) and the normal build of a shared libraryrgommers commentedon Sep 28, 2023
I don't think this has anything to do with static linking. It's a normal check for whether a piece of code with a header links. The problem you're having is the use of
dependencies: blasinside thatcc.linkscall I think - that seems to do something unwanted for your use case.mattip commentedon Sep 28, 2023
The
cc.linkcall tries to make an executable, which will want to resolve all the symbols at link time, which means it must use the full set of link libraries. But using the scipy-openblas wheels does a trick: it does not link to any openblas library. Instead, it loads the symbols at runtime globally so the executable can resolve them. Note how the patch changes thedependencies: blastodependencies: blas_staticin order to work around this.Then the rest of the code continues as normal, throwing away the
blas_staticdependency and continuing withblasrgommers commentedon Sep 28, 2023
This is going to cause Meson to be confused, so the simpler solution is to simply not try to detect blas/lapack and cblas. If we specify
scipy-openblas*, we already know it exists and that it was built with CBLAS. No need to try to confirm that.mattip commentedon Sep 29, 2023
That does sound simpler. Thanks.