You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Suppose having a project setup similiar to this one (replace _ in filenames with path separators).
The following conditions are met:
A static library, that I'll call A, has a public module in it
There's a dynamic library named B that has A as a Cargo dependency
B links to A with a extern crate A; statement, and exports some of A's modules with pub use A::module; in B's lib.rs
A binary/other library named C links to B and tries to use one of B's modules that are just a reexport of A modules
The linking of C with the default linker, fails with the following output:
error: linking with `cc` failed: exit code: 1
note: cc '-m64' '-L' '/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib' '-o' '/home/paolo/rust-bugs/C/target/C' '/home/paolo/rust-bugs/C/target/C.o' '-Wl,--whole-archive' '-lmorestack' '-Wl,--no-whole-archive'
'-nodefaultlibs' '-fno-lto' '-Wl,--gc-sections' '-pie' '-Wl,--as-needed' '-L' '/home/paolo/rust-bugs/C/target/deps' '-lB-7ff4c82ee0366c0f' '-L' '/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-lnative-4e7c5e5c' '-L' '/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib'
'-lstd-4e7c5e5c' '-L' '/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-lsync-4e7c5e5c' '-L' '/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-lrustrt-4e7c5e5c' '-L' '/home/paolo/rust-bugs/C/target' '-L' '/home/paolo/rust-bugs/C/target/deps'
'-L' '/home/paolo/rust-bugs/C/.rust' '-L' '/home/paolo/rust-bugs/C' '-Wl,--whole-archive' '-Wl,-Bstatic' '-Wl,--no-whole-archive' '-Wl,-Bdynamic' '-ldl' '-lpthread' '-lgcc_s' '-lpthread' '-lc' '-lm' '-lcompiler-rt'
note: /home/paolo/rust-bugs/C/target/C.o: in function "C::main":
/home/paolo/rust-bugs/C/src/main.rs:6: undefined reference to "amod::Test::new::hbd984620e5bd9235oaa"
collect2: error: ld returned 1 exit status
error: aborting due to previous error
Could not compile `C`.
If C links directly to A, whilst still linking to B, and tries to use A::amod instead of B::amod, the problem persists. Discarding B completely (e.g. without extern crate B in C's root) fixes it.
The text was updated successfully, but these errors were encountered:
Suppose having a project setup similiar to this one (replace
_
in filenames with path separators).The following conditions are met:
A
, has a public module in itB
that hasA
as a Cargo dependencyB
links toA
with aextern crate A;
statement, and exports some ofA
's modules withpub use A::module;
inB
'slib.rs
C
links toB
and tries to use one ofB
's modules that are just a reexport ofA
modulesThe linking of
C
with the default linker, fails with the following output:If
C
links directly toA
, whilst still linking toB
, and tries touse A::amod
instead ofB::amod
, the problem persists. DiscardingB
completely (e.g. withoutextern crate B
inC
's root) fixes it.The text was updated successfully, but these errors were encountered: