Static library linkage error

4ff2597
Opened by Overmind Jiang at 2023-10-13 04:22:53

This issue was previously submitted to https://github.com/rust-lang/cargo/issues/4351, which contains the description and the reproduction steps.

Basically I suspect that rustc is not passing the static libraries in the correct order to the linker.

  1. Ping @alexcrichton

    I've been busy moving myself across the earth recently and haven't got a chance to search for the cause of this problem in rustc. Would appreciate any pointers.

    Overmind Jiang at 2017-08-28 00:00:13

  2. All the relevant code here I believe is around src/librustc_trans/back/link.rs, although that file's pretty hairy :(

    Alex Crichton at 2017-08-28 14:24:59

  3. Has any progress been made on this issue recently? I think I'm running into a similar problem:

    • I have a C++ library, libfoo.a
    • I have a C wrapper library libbar.a, which statically links libfoo.a
    • I have a Rust library (say) libbar-sys.rlib that statically links libbar.a, and
    • I have a Rust executable that staticallly links the Rust library.

    At compile time I get linker errors that suggest that symbols from libfoo.a are not making their way to the final executable. I can verify (using strings) that the symbols persist all the way from libfoo.a -> libbar.a -> libbar-sys.rlib.

    I can try and create a proof-of-concept when I have time, but it feels like it might be the same issue...

    Adam Brouwers-Harries at 2018-09-19 21:08:35

  4. Triage: Is this still a problem? Wanted to check since 5 years has passed and circumstances might have changed.

    Martin Nordholts at 2023-10-13 04:22:53