Repository navigation
Add linker_static_archive_order lint for -Clink-arg archives placed before referenced dynamic libs - #160201
Add linker_static_archive_order lint for -Clink-arg archives placed before referenced dynamic libs#160201cezarbbb wants to merge 1 commit into
linker_static_archive_order lint for -Clink-arg archives placed before referenced dynamic libs#160201Conversation
|
I think we should only point to |
That makes sense. I'll do it. |
d73f481 to
e5596e2
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
e5596e2 to
e723d7a
Compare
This comment has been minimized.
This comment has been minimized.
e723d7a to
f25daf3
Compare
This comment has been minimized.
This comment has been minimized.
…ed before referenced dynamic libs
f25daf3 to
c2aee12
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
Hi @bjorn3, I wanted to ask if you have any further concerns regarding this PR? I will actively follow up on it. |
See issue #154975
When a static archive is passed via
-Clink-arg, rustc appends it after its own native libraries. With--as-needed, strict left-to-right linkers like GNUld.bfd(unlikelld, which tolerates back-references) can then drop a dynamic library that only that archive references, leaving unresolved symbols.rustc can't tell whether the back-reference actually exists without resolving the archive's symbols, so this is a heuristic lint rather than a fix to the ordering itself. It's Allow by default and carries
ignore_deny_warnings, so it stays silent unless explicitly requested with-Wlinker-static-archive-order, and-D warningswon't promote a possible false positive into an error — only-Dlinker-static-archive-orderwill.The lint fires for GNU
ld-family linkers that don't uselld(bareldorcc-driven), excluding Windows and Darwin where the--as-neededmodel doesn't apply. The diagnostic points at three workarounds:-l static=,-Zpre-link-arg=, and wrapping the dynamic library in--no-as-needed/--as-needed.r? @bjorn3