-
Notifications
You must be signed in to change notification settings - Fork 0
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
Discuss external linking and linking order #2
Comments
This is correct. The crate is not doing any linkage. Please refer to the architecture. |
That architecture worked largely by luck so far. |
There might be some misunderstanding on my side. The linking happens when one chooses a source. In the case of the Netlib source, for instance, the corresponding instructions are given here: https://github.com/blas-lapack-rs/netlib-src/blob/master/build.rs Are you referring to this or something else? |
It looks like you've got the same problem as llvm-sys, where the set of linked libraries cannot be known until build-time. It seems like we'd need Cargo to support emitting an equivalent of |
Yes, this is accurate. Thank you for looking into this! |
I'll also look in more detail how this crate and llvm-sys setup things later this week.
I guess the main source of misunderstanding may come from the fact that it's not enough to link to the necessary library somewhere on the command line, it needs to be linked after it's used due to the order-dependent way in which unix-style linkers work (and the order is inferred from "crate -> crate" and "crate -> native lib" dependencies in rustc using topological sorting). |
Thank you. Let us add the following to the list:
|
liblapacke
, but doesn't declare that dependency
So you get linking errors when using
lapacke-sys
without some other crate linking toliblapacke
.This was found when testing some linking order changes in
rustc
in rust-lang/rust#102832 (comment) (build failure - https://crater-reports.s3.amazonaws.com/pr-102832-1/try%230c94de7c1a8f4b82b92d562847c35f513f520c7a/gh/lopez86.rust-mlearn/log.txt).The dependency on
liblapacke
should be declared using a#[link]
attribute or a build script withcargo:rustc-link-lib
.The text was updated successfully, but these errors were encountered: