Skip to content
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

Some libraries built for x86_64 fail at runtime lacking __extenddftf2 symbol #94

Closed
jmartinesp opened this issue Apr 15, 2023 · 6 comments

Comments

@jmartinesp
Copy link

jmartinesp commented Apr 15, 2023

While building with the latest cargo-ndk version and NDK r25, libs for all architectures build fine, but on our x86_64 emulators our Android app crashes instantly when started because it can't find the __extenddftf2 symbol:

04-12 21:45:22.118 E/AndroidRuntime( 9230): Process: io.element.android.x.debug, PID: 9230
04-12 21:45:22.118 E/AndroidRuntime( 9230): java.lang.RuntimeException: Unable to create application io.element.android.x.ElementXApplication: androidx.startup.StartupException: java.lang.UnsatisfiedLinkError: Unable to load library 'matrix_sdk_ffi':
04-12 21:45:22.118 E/AndroidRuntime( 9230): dlopen failed: cannot locate symbol "__extenddftf2" referenced by "/data/app/~~_fl7RirpC9FRkAXTX8yEeA==/io.element.android.x.debug-o6Z0kMjlRtOv9LzqMyA3Tg==/base.apk!/lib/x86_64/libmatrix_sdk_ffi.so"...
04-12 21:45:22.118 E/AndroidRuntime( 9230): dlopen failed: cannot locate symbol "__extenddftf2" referenced by "/data/app/~~_fl7RirpC9FRkAXTX8yEeA==/io.element.android.x.debug-o6Z0kMjlRtOv9LzqMyA3Tg==/base.apk!/lib/x86_64/libmatrix_sdk_ffi.so"...
04-12 21:45:22.118 E/AndroidRuntime( 9230): dlopen failed: cannot locate symbol "__extenddftf2" referenced by "/data/app/~~_fl7RirpC9FRkAXTX8yEeA==/io.element.android.x.debug-o6Z0kMjlRtOv9LzqMyA3Tg==/base.apk!/lib/x86_64/libmatrix_sdk_ffi.so"...
04-12 21:45:22.118 E/AndroidRuntime( 9230): Native library (android-x86-64/libmatrix_sdk_ffi.so) not found in resource path (.)

This seems quite similar to what was fixed in this Mozilla repo, although if I'm not mistaken you took a different approach that was later removed here (maybe this workaround was for a whole different issue though).

Would it be possible to either restore this workaround or find another way to fix this issue? It's preventing us from running UI tests on our apps since all our CI emulators are x86_64 and the apps won't even start, but it will also mean our app will be broken in x86_64 devices (although hopefully there won't be many of those).

Thank you, and sorry if I'm lacking some details or maybe I misunderstood something about this issue: I'm more of an Android-only developer and I don't have much experience with Rust and the NDK.

@jmartinesp
Copy link
Author

As linked above, I was able to find a workaround by using an old version of cargo-ndk and NDK r22b. It's not ideal, but it might be enough until the root issue is fixed in case no one has time to implement a better workaround.

@ganfra

This comment was marked as off-topic.

@bbqsrc

This comment was marked as off-topic.

@bbqsrc
Copy link
Owner

bbqsrc commented Apr 17, 2023

@jmartinesp the Mozilla solution can work here, and would be happy to have a PR implementing it.

Alternatively, throw a sponsorship my way and I can prioritise it within this week.

@jmartinesp
Copy link
Author

@jmartinesp the Mozilla solution can work here, and would be happy to have a PR implementing it.

I'd love to, but I have very limited knowledge of the cargo tooling, so don't know how to do that 😅 . We ended up implementing it in our codebase, as that's quite simpler, we just need to follow the same workaround added above in our build.rs file.

Anyway, thanks for your work in this tool, it's been really useful to us so far! Feel free to close the issue if you think it's not something worth working on, as it might get fixed in the Rust compiler, which seems to be the root cause of the issue.

@bbqsrc
Copy link
Owner

bbqsrc commented May 14, 2023

While linking to the builtins may be required by a decent number of crates (sqlite comes to mind for handling weird float sizes, unless that crate is updated with Android-specific handling), it's not something I think I want to integrate into cargo-ndk by default.

If somebody wants to add this, introducing a --link-builtins flag to do so would be my suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants