JuliaLinearAlgebra / libblastrampoline

Using PLT trampolines to provide a BLAS and LAPACK demuxing library.
MIT License
66 stars 17 forks source link

Null pointers in LP64 on Windows #89

Closed ViralBShah closed 1 year ago

ViralBShah commented 2 years ago

Building Ipopt and MUMPS_seq with LBT using LP64 results in null pointer issues only on Windows (when using OpenBLAS32), both win64 and win32. Works fine on the other platforms.

Discussed in https://github.com/jump-dev/Ipopt.jl/pull/327

giordano commented 1 year ago

As far as I understand, the null pointer on Windows might be related to a mismatch between the name of the library used by Julia (libblastrampoline.dll: https://github.com/JuliaLang/julia/blob/67b8ac020833a14d98e8a147b8aae5caf2288a41/stdlib/libblastrampoline_jll/src/libblastrampoline_jll.jl#L22) and the library required by dependent libraries, which is set by the import library (libblastrampoline-5.dll as of #88, before that it'd be something like libblastrampoline-5-2-0.dll): when julia dlopens libblastrampoline.dll it also initialises that library, setting where to forward the blas/lapack calls, but then when the dynamic loader loads a dependent library it dlopens libblastrampoline-5.dll/libblastrampoline-5-2-0.dll separately, but this wouldn't have been initialised, causing forwarded calls to go into a void.

I believe the solution would be to have a single copy of libblastrampoline around on Windows, and make sure the import library is consistent with that only library available. Ideally that'd be libblastrampoline-5-.dll, but that wouldn't work with already released versions of Julia because they only use libblastrampoline.dll, so another option is to keep only libblastrampoline.dll, which is a blatant lie in terms of compatibility, but at least would make the transition smoother.

This was mostly debugged by @vchuravy

giordano commented 1 year ago

Should have been fixed by #97 (use a single library and live happy)