The RFC for rust-lang/rust#81490 says that the default mode for linking static libs is "--no-whole-archive". However, when linking static libraries from build scripts, all links are done as follows:
"-Wl,-Bstatic" "-Wl,--whole-archive" "-lmystatic" "-Wl,--no-whole-archive"
There is no way to opt out of this behavior as far as I can tell.
- Clone this repo
- Run
RUSTC_LOG=rustc_codegen_ssa::back::link=info cargo build
- Notice the part of the linker line:
"-Wl,-Bstatic" "-Wl,--whole-archive" "-lmystatic" "-Wl,--no-whole-archive"
I think the RFC is incorrect in that the default behavior is to link static libs as whole archives. I'm currently looking for a way to opt out on a library-by-library basis.