-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should lapack/lapack-sys depend on lapack-src? #29
Comments
Hello, this is by design. The choice of the source is the end user’s responsibility: https://github.com/blas-lapack-rs/blas-lapack-rs.github.io/wiki |
@IvanUkhov I agree that the choice of a particular implementation should be end-user's responsibility. However, any library that uses LAPACK symbols should declare dependency on LAPACK, otherwise linking might happen in the wrong order. E.g., if I implement a library crate
in his Cargo.toml. As far as I understand https://github.com/blas-lapack-rs/blas-lapack-rs.github.io/wiki , the Please not that I believe you don't see more reports like this one thanks to the fact that all the functions in Further, in any case, I believe the current situation is quite confusing (at least to me), so I believe it would be best to make it simpler (such as: "implement a rust library -> depend on |
I should not have closed it without asking for more details. Sorry! I will keep it open to draw attention and get feedback. Let me check my understanding. The bottom line is that the linkage order is likely to be incorrect whenever a library depends on Here one can see all current dependents: https://crates.io/crates/blas/reverse_dependencies https://crates.io/crates/lapack/reverse_dependencies And here is a concrete example (/cc @termoshtt): https://github.com/rust-ndarray/ndarray-linalg/blob/master/lax/Cargo.toml And another one (/cc @sebcrozet): https://github.com/dimforge/nalgebra/blob/dev/nalgebra-lapack/Cargo.toml Again, why would it not be sufficient to depend on a |
Looking at the first (by download count) reverse dependencies of
As far as I understand:
Based on this, I draw two conclusions (this is just my opinion):
So, I would propose to
For the (*) point to work, I believe that it would suffice that So this spans more than only the For more context, I recently started to need linear algebra in my rust work (and went through quite a few hoops to get everything working). I am also investigating into the use of libflame as LAPACK implementation (I'll open-source a libflame-src crate if things work out), which explains my interest in the possibility of swapping providers. BTW, I would also be interested in clarifying/discussing the versioning policy for the |
It would be good to gather more feedback before we change anything. @bluss, you were quite active during the initial design phase. Do you have any thoughts on the above? |
I don't see a problem with adding this "link" between the crates. blas-src/blas-sys should preferably work together in the same way. I'm not really qualified to talk about lapack. If the user needs to pick lapack-src or blas-src (one excluding the other), then maybe this "link" is not a good choice(?). See our instructions for ndarray's blas integration - we have to remind about linking to blas-src (ndarray could link itself to blas-src, but with the current solution we don't have any strong coupling between ndarray and blas-src version, and we prefer that). Edit: Oh and my experience stretches only to the -src and -sys packages - never used lapack/blas crates. Maybe @termoshtt has some input? (For ndarray we don't use the |
As far as I understand, ndarray of the issue I'm describing (although with blas rather than lapack): when the blas feature of ndarray is enabled, and the user additionally depends on blas-src, there could be linking order issues (with static linking, and only if some function of ndarray that uses blas is not inlined). Strong version coupling is indeed problematic, but it doesn't seem to be unsolvable. It seems to me that the blas-src/lapack-src should have fairly stable APIs: the API surface is the BLAS/LAPACK interface, and the set of Cargo features. Future extensions seem to be limited to adding new Cargo features, which doesn't break the API. Therefore, blas-src/lapack-src could decide to do only non-major releases for the foreseeable future, and the ecosystem can stabilize around those. Your edit makes me thing that it would be better to add the dependency in the -sys crates, to cover such use-cases. This would also mirror the behavior of other -sys crates. E.g., openssl-sys takes care of linking to the system libraries, or, to compile openssl when its "vendored" feature is enabled. |
We haven't had any such bug report, but the current scheme is new (from 0.15.0), so it may take some time. |
Out of curiosity, I made a small test with ndarray:
This two-crate setup is motivated by the fact that At first sight, this work, and using If I put rlibs for libblas_src and openblas_src before As a conclusion, it seems like the issue is real but hard to trigger. |
I have the following dependencies in Cargo.toml
When I use functions from
lapack
in my crate, I get linker errors (undefined symbols). This can be solved by addingextern crate lapack_src as _;
to my crate, but this behavior is a footgun, as debugging it requires understanding rust linkage model (and its interaction with cargo). As far as I understand it, the issue would be solved if an upstream crate would depend onlapack-src
itself.Could this be done here ? Or would it be better to do it in
lapack-sys
?The text was updated successfully, but these errors were encountered: