finagolfin / swift-android-sdk

Android SDKs for Swift
Apache License 2.0
129 stars 13 forks source link

"dlopen failed: empty/missing DT_HASH/DT_GNU_HASH" crash in runtime #59

Closed neekeetab closed 2 years ago

neekeetab commented 2 years ago

Hey! Thanks for doing this!

So I built a swift lib by using your guide, but I'm getting "dlopen failed: empty/missing DT_HASH/DT_GNU_HASH" on android just when the lib is loaded to the memory. Did you encounter smth similar by chance?

Build command: /toolchain/swift-5.6-RELEASE-ubuntu20.04/usr/bin/swift build -v -c release --destination /toolchain/swift-android-sdk/android-aarch64.json -Xlinker -rpath -Xlinker /toolchain/swift-5.6-android-aarch64-24-sdk/usr/lib/swift/android

I found this question with a possible fix for c++. Maybe there's a swift compiler setting like this? Couldn't find one. https://stackoverflow.com/questions/28638809/android-ndk-unsatisfiedlinkerror-dlopen-failed-empty-missing-dt-hash

neekeetab commented 2 years ago

Nevermind, we had to remove all occurances of lib dispatch and lib concurrency in this SDK (along with corresponding .swiftmodule files) and it worked

We also had do build in docker ubuntu x86_64 container on an intel machine (possibly works on m1 as well), because it fails on ubuntu aarch64 on m1 macs

finagolfin commented 2 years ago

Hey @neekeetab, I didn't even see this issue when you opened it, because you closed it so fast. You may want to try this recent solution for libdispatch on Android instead (see the next comment too), otherwise you will not be able to use structured concurrency.