windows-drivers-rs icon indicating copy to clipboard operation
windows-drivers-rs copied to clipboard

`wdk-sys` export `_fltused` and `__CxxFrameHandler3`

Open rich-ayr opened this issue 1 year ago • 0 comments

This does match the behavior of WDK on the C/C++ side. To my knowledge there is currently no very good way to fix this purely from Rust. I'm not sure which compilers/os this project wants to support but instead of using #[no_mangle] it's also possible to invoke cc::Build and compile these functions from C. The alternative I have found for myself is:

let out_path = env::var("OUT_DIR").unwrap();
let def_file_path = format!("{out_path}/{}-wdk-sys-stub.def", env::var("CARGO_PKG_NAME").unwrap());
fs::write(&def_file_path, "EXPORTS").expect("Unable to write DEF file");
println!("cargo:rustc-link-arg=/DEF:{def_file_path}");

Handing the linker an empty EXPORT section via a .def file gets rid of any unwanted exports; not sure if this is suitable for library use, this might be global.

rich-ayr avatar Feb 13 '25 00:02 rich-ayr