-
Notifications
You must be signed in to change notification settings - Fork 15
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
UnsatisfiedLinkError: empty/missing DT_HASH/DT_GNU_HASH #67
Comments
I patch all the Swift libraries to change their ELF runpath, there's nothing specific to libdispatch. What version of Android are you testing on? My SDK only supports Android 7 or later. |
Android 12 Here is my minimal reproducible example:
|
I don't know why it says the hash is empty or missing, I see it for all the Swift libraries with I have not tried using this Swift SDK with a GUI apk yet, only on the command-line, but others say they got it working with some modifications, #53. I have never used Kotlin or Android Studio, would be easier if you let me know what you find. |
Thanks, that was the hint I needed. It appears that the .so are being stripped during the build process. To have it not do that, I added this to the build.gradle:
Once I get minimal code of mine working, I'll reduce that to just not strip the .so's it has trouble with. |
In conclusion, I only need to flag libdispatch as do not strip. I was able to get some swift code compiling and some kotlin code calling it without any trouble after that. Thanks! |
new information on this topic: Stripping the .so's which are generated by swift package manager also exhibit this behaviour, so I had them all disabled in the gradle. Yesterday I tried to reduce the file size of the .so's and I discovered that if I strip them myself PRIOR to running ANY patch elf on them this issue goes away. If they are stripped AFTER the patching then the error exists. This explains why only libdispatch in the base set of .so provided by this SDK fails in this manner, as libdispatch appears to be the only one NOT stripped already:
while the others are
which effectively skips the gradle stripping process as they won't be stripped twice. @buttaface i dunno if you can adjust your build process to strip libdispatch prior to patching it but it might fix this error for the included .so's without needing the gradle workaround. [edit]
[/edit] |
I'll take a look, thanks for the info. |
I just looked and
I'm not sure why you're seeing anything different with my SDK libraries. |
Thanks! I will dig deeper and report back. [edit] Correct ofc that the ones in the SDK are not stripped, my bad. I have also now confirmed that gradle will strip an already stripped .so (which loaded correctly before the second strip), corrupting it in the process. I can still confirm that if I do the following (have gradle stripping disabled in both scenarios):
I suspect there is some incompatibility with stripping the .so after patchelf is run. A quick look at their repo shows a number of past issues like this, so I suspect similar but one which is specific to the android System.loadLibrary(). It might also have to do with what specific type of patchelf is happening, because the above doesn't explain why the other swift core libs load correctly when I manually stripped them (which would be after you've already performed the patchelf to them). [/edit] |
I am attempting to use this toolchain to build a barebones SPM as a dynamic library and load it into an Android studio app. I have been able to set things up such that the SPM project builds + tests succeed + .so files are emitted in a Docker container. I then take the .so's out of the container (including all the dependent ones like libdispatch.so, libc++_shared.so etc) and drop them in a simple Android studio project and attempt to load at runtime using System.loadLibrary("Foundation"). I am using the prebuilts ( https://github.com/buttaface/swift-android-sdk/releases/tag/5.6 )
If I try and load just a single dependent .so (say just swiftCore) it loads fine.
I tried swapping out all of the .so with the toolchain built over at https://github.com/readdle/swift-android-toolchain, and System.loadLibrary("Foundation") loads fine.
I suspect its something just with libdispatch, but am unsure where to look further. Any advice on where I can look to see what might be up?
[edit]fwiw, i reproduce with just libdispatch.so and libBlocksRuntime.so and nothing else[/edit]
[edit2]If i use your 5.4 release and swap out the other projects libdispath.so, then libdispatch and libBlockRuntime load successfully. I suspect the step mentioned in the readme where you manually do something to libdispatch may be the reason[/edit2]
The text was updated successfully, but these errors were encountered: