linker: Preserve relative order of -l
options, including dynamic libs
#104406
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Dynamic native libraries pulled through dependency crates are no longer linked last, they are now linked immediately after their corresponding crates, like other libraries.
The change is a part of RFC 2951 "Linking modifiers for native libraries" (https://github.com/rust-lang/rfcs/blob/master/text/2951-native-link-modifiers.md#relative-order-of--l-and--clink-args-options, #99427).
Crater run with this change found some regressions, their analysis can be found in #102832 (comment).
There are 3 root regressions, in all cases crates depend on some native libraries, but do not declare that dependency.
This is a continuation of #103311 and the second part of #102832.
r? @bjorn3
TODO:
Create issues/PRs for the affected crateshttps://gitlab.com/taricorp/llvm-sys.rs/-/issues/41 Discuss external linking and linking order blas-lapack-rs/lapacke-sys#2 This crate depends on libc, but doesn't declare that dependency purpleprotocol/mimalloc_rust#85