Need to be able to explicitly set --whole-archive linker flag when building a binary #56306
Labels
A-linkage
Area: linking into static, shared libraries and binaries
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I'm using
1.32.0-nightly (6bfb46e4a 2018-11-26)
but it likely applies to all rust versions. The default behaviour when building a binary is to include only static/shared libraries which are actually referenced from the code. There is a legitimate use case when you want to include everything from a native library regardless if it appears to be used or not. Native library can contain functions marked as__attribute__((constructor, used))
which are executed at the time when the library is loaded and can influence behaviour of other libraries which are explicitly referenced. One such example is DPDK library. Currently there does not seem to be a way to instruct explicitly rustc to include the lib even if not used.Using .cargo/config to override rustc flags looks more like a workaround than a proper solution. Or maybe I missed some other way how to accomplish the same without hacking the code? I will be thankful for any advice. Thanks!
For more in-depth discussion about the particular case of DPDK/SPDK see:
jkozlowski/starfish#6 or spdk/spdk#518 or a PR jkozlowski/starfish#8 .
The text was updated successfully, but these errors were encountered: