I am working on generating a C dynamic library using Rust and have encountered an issue related to symbol exporting. In my build.rs, I link a C static library where all the symbols are of type 'T'. However, after building the project, the symbols from the static library in the final Rust-generated dynamic library change to 't', indicating they are no longer exported.
Here is how I am linking the libraries in build.rs:
Rust
深色版本
println!("cargo:rustc-link-search=native=./target/lib");
println!("cargo:rustc-link-arg=-Wl,--whole-archive");
println!("cargo:rustc-link-arg=-lclntcfg_static");
// println!("cargo:rustc-link-lib=static=clntcfg_static"); // Alternative approach, commented out
println!("cargo:rustc-link-arg=-Wl,--no-whole-archive");
The compilation command used is:
深色版本
RUSTFLAGS="-C link-dead-code" cargo build
Is there a way to retain the imported functions from the C static library as exported (i.e., keep their 'T' attribute instead of defaulting to 't') during the Rust build process without modifying the C library code? Any suggestions or pointers would be greatly appreciated.
This is from an unrelated bug I had in past. Maybe you get lucky and it also solves what you want.
To get some code working correctly I had to change the archiver used, to one supplied by the tool. Alternative is change the linker.
Too long ago to remember the details. Was patching the make file to get the change.
For creating static library ar but there are multiple from different projects. (Even version bumps have potential to cause breakage.)
Note I am only suggesting to look to see if relevant; I don't know the details of what your trying.