cc-rs
cc-rs copied to clipboard
Support linking modifiers
Since a recent stabilization, rustc supports modifiers such as whole-archive for doing linking (https://github.com/rust-lang/rust/pull/93901#issuecomment-1041325522). whole-archive is useful for cdylib crates that do their main initialization with ctors and thus are liable to have the C components be garbage collected by the linker to confusing results.
Currently it seems that cc emits the rustc-link-lib directive to cargo in such a way that it isn't possible to specify modifiers: https://docs.rs/cc/latest/src/cc/lib.rs.html#1017
It would be great if these modifiers could be specified in the Build builder.
docs on rustc side: https://doc.rust-lang.org/rustc/command-line-arguments.html#-l-link-the-generated-crate-to-a-native-library
PR for this - https://github.com/rust-lang/cc-rs/pull/671. Workaround - https://github.com/rust-lang/cc-rs/pull/671#issuecomment-1150326799.