-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cargo doesn't transiently pass undefined symbols #112446
Comments
I thought the Cargo command is Nonetheless, your problem is not exactly a rustc one, it is a cargo one: rustc is not responsible for how cargo drives it, and while it does invoke a compiler for performing linkage, Based on scanning that thread, it seems the intent is that you should define a way for dependents to deliberately opt-in, rather than allowing you to muck up the linkage of other crates at will. |
Thanks for getting back to me. This is definitely no fault of rust and its a rather peculiar situation, whereby microsoft decided to mandate that consumers of their static libraries produced through NativeAOT have a forced, undefined symbol to initialize statically. For some reason, Not really sure why there would be any different between the two only in the dependent crate? |
Mildly vexing but not too surprising! Closing this as there is effectively "nothing to do" here, if a further request is desired a new issue can be opened at rust-lang/cargo's issue tracker. |
Hey all,
I am compiling a fairly complex library from C# with NativeAOT into a statically linked binary. NativeAOT requires that at link time, a specific argument is included
_NativeAOT_StaticInitialization
. If I write a FFI crate to interop with this library, and add:println!("cargo:rustc-link-args=-Wl,-u,_NativeAOT_StaticInitialization");
It seems to work at first glance. I wrote some unit tests to verify this behavior, and the unit tests pass. The undefined symbol is correctly included in the final binary and the NativeAOT code runs as expected.
Unfortunately, this behavior is not consistent when the same exact unit test is copied into a dependent crate. Adding the original FFI crate as a dependency seems to cause a segmentation fault which is due to the undefined symbol no longer existing in the binary.
I am not entirely sure how I can help, if it would be of assistance I can provide the specific statically linked library in question for reproduction? I suspect what happens is that when rust compiles the internal unit test, it directly links against the static lib into a binary without an intermediate
rlib
.I was hoping someone could point me in the right direction towards a specific flag I can use here, or another tracking issue for a similar issue?
Any help or guidance on this matter would be much appreciated.
Thanks
The text was updated successfully, but these errors were encountered: