-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Link error when using native_link_modifiers_bundle and ld.bfd #87541
Comments
cc #85805 I don't think this is a bug. We should support specifying all dependencies explicitly (similarly to how Rust crates form a dependency tree with Cargo) instead of making everything automatically depend on everything by using mechanisms like groups (which lld does by default). |
…rochenkov Adjust linking order of static nobundle libraries Link the static libraries with "-bundle" modifier from upstream rust crate right after linking this rust crate. Some linker such as GNU linker `ld.bdf` treat order of linking as order of dependency. After this change, static libraries with "-bundle" modifier is linked in the same order as "+bundle" modifier. So we can change the value of "bundle" modifier without causing linking error. fix: rust-lang#87541 r? `@petrochenkov`
…rochenkov Adjust linking order of static nobundle libraries Link the static libraries with "-bundle" modifier from upstream rust crate right after linking this rust crate. Some linker such as GNU linker `ld.bdf` treat order of linking as order of dependency. After this change, static libraries with "-bundle" modifier is linked in the same order as "+bundle" modifier. So we can change the value of "bundle" modifier without causing linking error. fix: rust-lang#87541 r? ``@petrochenkov``
This is found in #85600 (comment)
code: https://github.com/12101111/native_link_modifiers_bundle
This is the part of link command line:
libfoo.a
need symbols from libc, but libc is include inliblibc-*.rlib
, which appear in the command line beforelibfoo.a
. ld.lld is "smart" enough to find those symbols fromliblibc-*.rlib
, but ld.bfd use the traditional unix linker behavior.The logic of assemble linker command line is at
rust/compiler/rustc_codegen_ssa/src/back/link.rs
Lines 1797 to 1814 in aea2e44
Currently
libfoo.a
is added to linker command line byadd_upstream_native_libraries
Possible solution:
NativeLibKind::Static { bundle: Some(false), .. }
from upstream rlib crate to linker command line right after that crate is added inadd_upstream_rust_crates
.kind = "static", modifiers = "-bundle"
: Use link modifiers -bundle on musl and wasi target libc#2272Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: