strict_linking_rs
Enforces the requirement that all functions defined inside your crate's extern "C" blocks must be resolved in the final executable.
To use
In your build.rs file add this line to your main() function
init;
And then in your Cargo.toml file add this
[]
= "0.1"
How does it work?
First, we use cargo +nightly rustc --profile=check -- -Zunpretty-expanded to expand macros inside the code for your crate.
Then we parse that with the syn crate, and walk down the syntax tree recursively, looking for
extern "C" blocks. When we find them, we emit cargo:rustc-link-arg
instructions in a platform specific manner to use flags like /INCLUDE
and --undefined so that the linker will not link successfully if one of those symbols is missing.