-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Linker error when calling inline extern "C" function #61820
Comments
This is not a bug, I think. The catch here is that There are ways to ensure that a symbol ends up being present in an executable, regardless of whether |
@nagisa appreciate the suggestions. A couple of thoughts:
|
You would usually use the However, in your specific case it also matters how the compiler distributes code between multiple codegen units. As the compiler has no reason to know about the relationship between To elaborate on what the semantics are:
The correct way to handle this would be to modify the auto-generated code to refer to the function via the usual rust syntax (i.e. in Alternatively you can hack around the issue with a |
It appears that we are able to work around this issue by adding Also, it turns out that |
Minimized example (problem discovered when translating bzip2 to Rust with C2Rust).
main.rs:
caller.rs
NOTE: the problem has to do with the inline attribute; linking succeeds when removed.
whereas the following works (on stable and nightly):
Maybe this is not expected to work since
ext_fn
isn't defined in a foreign library? On the other hand, it seems like a bug since using the inline attribute shouldn't prevent linking.The text was updated successfully, but these errors were encountered: