-
Notifications
You must be signed in to change notification settings - Fork 75
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
NDK version compatibility #105
Comments
Hi @HonzaR, I have limited time to help with this but I'll suggest where I would start. I wonder if you somehow have different symbol exports in your If you can point me at a CI build with APKs for the different architectures, I could perhaps take this line of inquiry one step further. Good luck! |
Hi @ncalexan, thank you for your quick response. As for your questions:
Yes, that is something which we suspect to be the problem.
Several other symbols seem to work as expected. I can confirm that I can surely reproduce the problem with these methods:
No, I think there are some previous JNI calls to our SDK Rust code.
That would be really great, as I have no experience with the mentioned llvm-objdump tool. This link leads the Thank you very much for your time! |
I can confirm that the libraries in your archive have no symbols exported; that's never going to succeed:
As an experiment, could you add However, we don't want to disable stripping; we want to control that process. And that I don't really know how to do, either at the native toolchain level (with Rust, LLVM, etc) or at the Android toolchain level (with Gradle). Reading about this, it rather looks like the right approach will be to disable Android-level stripping entirely and then manage stripping (really, LTO and symbol exposure) at the Rust level. And that seems to be possible with linker scripts, etc. So: first, verify that it's symbol export causing this issue. Assuming it is, I would figure out how to use In any case, let me know if this is symbol visibility or something else. Good luck! |
Oh -- can you also verify that some JNI natives are being invoked? That doesn't make sense to me, but here we are. If that is happening, then all of this symbol visibility is not the issue, and perhaps there's some wrinkle about |
Hi @ncalexan, Thank you for your very valuable thoughts. I've tested the not stripping command and, unfortunately, no luck there. The failure is still the same:
I've tested it with Here I linked the debug APK, which contains the binaries above, if that can be useful too. The important thing is that, when I broader analysed the JNI calls, it showed up that we're not able to call any of our JNI methods from DerivationTool.kt, nor from RustBackend.kt. It also showed up that we have a problem with loading the library according to this message, which appears before the one above:
What do you think about it? Thank you very much! |
Fascinating. It sure looks like you're getting bitten by this NDK bug. The linked discussion, in particular this comment suggests that you're seeing something rather like #75. In that ticket, we started to rewrite |
It's great to have some guidelines to solve this problem. Thank you very much! We'll check it out and let you know. |
Hi @ncalexan, we've been talking about this in our team. And this is just a thought, but can this problem be solved by the rust-android plugin. It there a change to have the problem covered by this plugin, so other developers won't face it too? Thank you for your thoughts. |
If you can identify and explain to me what the problem actually is, I'm definitely open to solving this at the plugin level. That's what I was suggesting in #105 (comment), specifically: "Arranging for |
Note for self: Mozilla uses JNA, so this exact symbol approach won't work for our internal uses. But generally, this approach makes some sense to me. |
As to why others might not be reporting it: It only impacts developers with Intel machines using AVDs. I use an M1 Mac, so I didn't see it. Firebase Test Lab doesn't support API 31, so CI didn't pick it up. Even people on Intel machines often test on physical ARM devices. So the team didn't catch this until several weeks after it was merged to our main branch. |
If I'm reading correctly, the root cause is (from #75 (comment)):
We can statically link libgcc I guess, but seriously, who at Google thought it was a good idea to stop distributing one of the essential runtime libraries in the NDK? It's absolutely guaranteed to cause breakage. This is why we originally decided to link to libgcc dynamically, despite linking the C++ standard library statically: zcash/zcash#2513 (comment) |
Yes, I think this is the root cause. To paper over issues with Rust and the NDK, however, this plugin transparently rewrites I will note that a Firefox engineer recommended Rust 1.68 as a work-around: see https://bugzilla.mozilla.org/show_bug.cgi?id=1820876#c4. I don't know if this addresses the issue, but it might. If it does I'd appreciate an update saying as much! |
It's very likely that rewriting |
I think the
I think this is the same issue that Mozilla is now running into (mozilla/application-services#5436). That issue currently points the finger at |
Okay, so I think the core issue here is that
Android removed
termux/termux-packages#14576 has what appears to be an identical problem to us: using EDIT: It's not clear whether the |
This lines up with mozilla/application-services#5436 (comment), which says that the |
Aaand I now see that the Mozilla issue points to Rust as the other culprit here: |
SQLite defines a
The C language only requires |
Possibly relevent SQLite forum discussions: |
I've opened zcash/librustzcash#800 because I think this problem is not a bug with |
Thanks for all of the investigation here (and sorry to be late to this party). |
Hi. I'm currently facing this issue on my project. I read through this thread and the various linked threads, and don't really have a clear picture of where this issue is coming from or how to work around it (other than using the x86 emulator). Is this something that the plugin can ultimately take care of by linking to appropriate libraries as needed, or this needs to be solved in some other repo - NDK, rust, rusqlite, or...? Is there a workaround for the time being? I did not understand the workaround in the Firefox repo, or how I would apply that to my project. For now I'm just using the x86 emulator on Windows, or an arm64 emulator on Mac, but I'd like to be able to use the usual x86_64 emulator if possible. |
@aiongg Try this to see if it can solve your problem |
Prompted by the above, I ended up solving this in our stack by writing a build script that leverages the environment variables set by the |
Hi everyone,
We've been facing a new runtime issue on one of our open source projects, when we switched from NDK version
22.1.7171670
to a newer version23.1.7779620
. Only emulatorx86_64
devices suffer from this failure. I've tried to reproduce the failure on your sample app project, but I wasn't able to make the project be built, as there is some problem with Android Studio run configurations. So I better ask here for help. Thank you in advance. Any help is really appreciated. Below is a list of next information, which can be useful:23.1.7779620
. The latest 23 version23.2.8568313
suffers from this failure too.24.0.8215888
and latest 25 version25.0.8528842
, which unfortunately finished its build phase with a failure - there are probably other changes in the NDK, which we need to adopt firstx86_64
architecture, we can be sure, because emulators with SDK API 30 withx86
work well, but thex86_64
suffer with the crash.0.9.3
. Its version is not important.22.1.7171670
Thank you for your thoughts on this.
The text was updated successfully, but these errors were encountered: