cc-rs icon indicating copy to clipboard operation
cc-rs copied to clipboard

Support linking modifiers

Open lf- opened this issue 3 years ago • 1 comments

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

lf- avatar Jun 16 '22 06:06 lf-

PR for this - https://github.com/rust-lang/cc-rs/pull/671. Workaround - https://github.com/rust-lang/cc-rs/pull/671#issuecomment-1150326799.

petrochenkov avatar Jun 16 '22 07:06 petrochenkov