vorner / signal-hook

Rust library allowing to register multiple handlers for the same signal
Apache License 2.0
705 stars 71 forks source link

Linking fails on some Android versions #118

Closed Hocuri closed 2 years ago

Hocuri commented 2 years ago

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 https://github.com/deltachat/deltachat-android/issues/2136. Summary:

Thanks in advance!

vorner commented 2 years ago

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:

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).

Hocuri commented 2 years ago

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

Android systems below API 21 are impacted, see https://github.com/deltachat/deltachat-android/issues/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 :)

vorner commented 2 years ago

It should be fixed in the just released 0.3.11.