vorner/signal-hook

Linking fails on some Android versions

Hocuri opened this issue · 3 comments

When compiling on some Android versions, we get the following error:

[x86] SharedLibrary  : libnative-utils.so
jni/x86/libdeltachat.a(signal_hook-2530526319fba6eb.signal_hook.br2krarz-cgu.6.rcgu.o):signal_hook.br2krarz-cgu.6:function signal_hook::low_level::signal_details::emulate_default_handler::h0c9c85f8b16d90b7: error: undefined reference to 'sigemptyset'
jni/x86/libdeltachat.a(signal_hook-2530526319fba6eb.signal_hook.br2krarz-cgu.6.rcgu.o):signal_hook.br2krarz-cgu.6:function signal_hook::low_level::signal_details::emulate_default_handler::h0c9c85f8b16d90b7: error: undefined reference to 'sigaddset'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [obj/local/x86/libnative-utils.so] Error 1

See deltachat/deltachat-android#2136. Summary:

  • Looks like it is broken since b46473f
  • For us, compilation is only failing when compiling for 32Bit, i.e. armeabi-v7a and x86, in debug mode. See the linked issue for thoughts on why it's failing specifically then.
  • Probably you should exclude the code somehow for Android (possibly only exclude it for Android versions older than Android-5.0=API21 or only exclude it for 32bit-Android; both should already help in our issue), like you do for Windows

Thanks in advance!

I'm probably OK with disabling it on the platforms that don't have it. But I don't have such system, so I'd ask you to:

  • Track down which systems are impacted by this and which ones aren't (I do believe there are some androids this compiles for and I suspect they are even part of CI).
  • Create a pull request. If you can also add such platform to the CI, it would be great.

The fact that the libc crate provides the function but it doesn't link seems to suggest a bug there (it probably should fail during compilation, not link time). Would you mind taking it to them too, please? (Disabling here still makes sense, either way it wouldn't be available).

Track down which systems are impacted by this and which ones aren't

Android systems below API 21 are impacted, see deltachat/deltachat-android#2136.

However, there seems to be no way to do conditional compilation depending on the targeted Android version (reference].

What we could do is something like #[cfg(not(all(target_os = "android", any(target_pointer_width = "32", target_pointer_width = "16"))))] to only disable the code for 32-Bit-Androids (and 16-Bit, i don't know if that's a thing). Because, as far as I know it's not possible anyway to run 64-Bit native code below Android-21 - @link2xt is this true?

The fact that the libc crate provides the function but it doesn't link seems to suggest a bug there

Not sure if they can do anything about it, because they too will have the problem that they can't do conditional compilation depending on the Android version. But ping @link2xt again :)

It should be fixed in the just released 0.3.11.