After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 766235 - undefined reference to 'bsd_signal' in Android Studio 2.1
undefined reference to 'bsd_signal' in Android Studio 2.1
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: cerbero
1.8.1
Other Linux
: Normal blocker
: 1.8.2
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-05-10 16:59 UTC by Diane
Modified: 2016-06-07 07:04 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Image showing error and NDK version (254.72 KB, image/png)
2016-05-10 17:03 UTC, Diane
  Details
Patch for reproducing error (2.11 KB, patch)
2016-05-10 17:13 UTC, Diane
rejected Details | Review
Android NDK v12 download (261.82 KB, image/png)
2016-05-10 18:39 UTC, Diane
  Details
android: Work around NDK ABI incompatibility around bsd_signal/signal in a different way (2.23 KB, patch)
2016-06-06 13:48 UTC, Sebastian Dröge (slomo)
committed Details | Review

Description Diane 2016-05-10 16:59:50 UTC
Using NDK build on GStreamer version 1.8.1 causes the error below:


/home/slomo/cerbero/android-ndk-r11/platforms/android-9/arch-arm/usr/include/signal.h:113: error: undefined reference to 'bsd_signal'


I am using Android Studio 2.1 with Android NDK v.12.
Comment 1 Diane 2016-05-10 17:03:24 UTC
Created attachment 327601 [details]
Image showing error and NDK version
Comment 2 Diane 2016-05-10 17:13:33 UTC
Created attachment 327603 [details] [review]
Patch for reproducing error

Patch is based off of project listed here:

  https://github.com/sdroege/gst-player/tree/master/android
Comment 3 Sebastian Dröge (slomo) 2016-05-10 17:38:23 UTC
Review of attachment 327603 [details] [review]:

::: android/app/src/main/jni/Application.mk
@@ +1,1 @@
+APP_PLATFORM = 21

Ah I assume it works if you select 15 or 9 here, independent of the other changes?
Comment 4 Diane 2016-05-10 17:46:57 UTC
(In reply to Sebastian Dröge (slomo) from comment #3)

> Ah I assume it works if you select 15 or 9 here, independent of the other
> changes?

Neither API 15 or 9 fixes the problem. I get the same error.
Comment 5 Sebastian Dröge (slomo) 2016-05-10 17:55:58 UTC
Ok, so it fails to build for you even without any changes then? Good :)

Not sure what this NDK 12 is, the latest still seems to be r11c: https://developer.android.com/ndk/downloads/index.html
Comment 6 Diane 2016-05-10 18:30:40 UTC
(In reply to Sebastian Dröge (slomo) from comment #5)

> Not sure what this NDK 12 is, the latest still seems to be r11c:
> https://developer.android.com/ndk/downloads/index.html

Hmm, I'm guessing the website has not been updated yet. If you download Android Studio 2.1 from the stable channel, I'm sure you'll be able to download it. 

Here is a link to the copy of the NDK I am using:
https://www.dropbox.com/s/la88jgjzwnj6ilz/ndk-bundle.tar.gz?dl=0
Comment 7 Diane 2016-05-10 18:39:39 UTC
Created attachment 327607 [details]
Android NDK v12 download

Turns out NDK v12 is a beta build.
Comment 8 Sebastian Dröge (slomo) 2016-05-10 19:11:13 UTC
I can't reproduce this here with your ndk-bundle. Can you reproduce it with r11c?
Comment 9 Sebastian Dröge (slomo) 2016-05-10 19:13:28 UTC
Also please try with latest gst-player (I just updated something) without any changes to the build system.
Comment 10 Diane 2016-05-10 21:48:47 UTC
I am still getting the same error:



sbis-android@ubuntu:~/Android/Projects/gst-player-new/android/app$ /home/sbis-android/Android/Sdk/android-ndk-r11c/ndk-build NDK_PROJECT_PATH=build APP_BUILD_SCRIPT=src/main/jni/Android.mk NDK_APPLICATION_MK=src/main/jni/Application.mk GSTREAMER_JAVA_SRC_DIR=src/main/java GSTREAMER_ROOT_ANDROID=/home/sbis-android/Android/Installation/gstreamer-1.0-android-armv7-1.8.1 all

[armeabi] Compile thumb  : gstplayer <= player.c
GStreamer      : [GEN] => gst-build-armeabi/gstreamer_android.c
GStreamer      : [COMPILE] => gst-build-armeabi/gstreamer_android.c
GStreamer      : [LINK] => gst-build-armeabi/libgstreamer_android.so
/home/slomo/cerbero/android-ndk-r11/platforms/android-9/arch-arm/usr/include/signal.h:113: error: undefined reference to 'bsd_signal'
/home/slomo/cerbero/android-ndk-r11/platforms/android-9/arch-arm/usr/include/signal.h:113: error: undefined reference to 'bsd_signal'
/home/slomo/cerbero/android-ndk-r11/platforms/android-9/arch-arm/usr/include/signal.h:113: error: undefined reference to 'bsd_signal'
/home/slomo/cerbero/android-ndk-r11/platforms/android-9/arch-arm/usr/include/signal.h:113: error: undefined reference to 'bsd_signal'
collect2: error: ld returned 1 exit status
/home/sbis-android/Android/Installation/gstreamer-1.0-android-armv7-1.8.1/share/gst-android/ndk-build//gstreamer-1.0.mk:229: recipe for target 'buildsharedlibrary_armeabi' failed
make: *** [buildsharedlibrary_armeabi] Error 1
Comment 11 Sebastian Dröge (slomo) 2016-05-11 05:40:51 UTC
Do you run ndk-build manually there, or just run ./gradlew assemble ?
Comment 12 Diane 2016-05-11 16:54:55 UTC
I run it manually. Here is the full command from the app folder of the gst-player project:

/home/sbis-android/Android/Sdk/android-ndk-r11c/ndk-build NDK_PROJECT_PATH=build APP_BUILD_SCRIPT=src/main/jni/Android.mk NDK_APPLICATION_MK=src/main/jni/Application.mk GSTREAMER_JAVA_SRC_DIR=src/main/java GSTREAMER_ROOT_ANDROID=/home/sbis-android/Android/Installation/gstreamer-1.0-android-armv7-1.8.1 all
Comment 13 Diane 2016-05-12 17:39:13 UTC
Is there any other information I can give you? This has become a blocker in my project.
Comment 14 Sebastian Dröge (slomo) 2016-05-13 09:35:24 UTC
I can finally reproduce it, on my laptop. It works well on my desktop though.
Comment 15 Sebastian Dröge (slomo) 2016-05-13 09:50:22 UTC
Apparently ABI breakage in the NDK:
https://github.com/rust-lang/libc/issues/236#issuecomment-198774409

If we compile with pre-21, our binaries won't work with 21 or newer. If we compile with 21 or newer it won't work with pre-21. Good job Google!
Comment 16 Sebastian Dröge (slomo) 2016-05-13 09:52:41 UTC
https://github.com/android-ndk/ndk/issues/48
Comment 17 Sebastian Dröge (slomo) 2016-05-13 09:57:21 UTC
We could maybe detect it at link time or so, and inject a bsd_signal() wrapper if needed. Ugly though. Someone will have to implement that though.
Comment 18 Jan Schmidt 2016-05-13 13:04:49 UTC
It might be possible to declare bsd_signal() locally as a weak alias for 'signal'. If the NDK one is present, it shouldn't conflict and the NDK version will take precedence.

__sighandler_t bsd_signal(int, __sighandler_t) __attribute__((weak, alias ("signal")));
Comment 19 Sebastian Dröge (slomo) 2016-05-14 06:02:03 UTC
Main question (if that works at all) is where to put that code then :) I assume gstreamer_android-1.0.c.in is a good place. I'll test this later.
Comment 20 Sebastian Dröge (slomo) 2016-05-14 07:36:21 UTC
commit 056dc09609fae74d94899ed8d5ff71832d73a0a0
Author: Sebastian Dröge <sebastian@centricular.com>
Date:   Sat May 14 10:35:22 2016 +0300

    android: Work around NDK ABI incompatibility
    
    Workaround for Android <21 making signal() an inline function
    around bsd_signal(), and Android >= 21 not having any bsd_signal()
    symbol but only signal()
    
    https://bugzilla.gnome.org/show_bug.cgi?id=766235
Comment 21 Gregoire 2016-05-29 22:53:06 UTC
See https://bugzilla.gnome.org/show_bug.cgi?id=766998
Comment 22 Sebastian Dröge (slomo) 2016-06-06 07:43:33 UTC
This seems to sometimes create an infinite recursion, where bsd_signal() calls bsd_signal() calls bsd_signal() calls ...
Comment 23 Sebastian Dröge (slomo) 2016-06-06 13:48:37 UTC
Created attachment 329192 [details] [review]
android: Work around NDK ABI incompatibility around bsd_signal/signal in a different way

Get the correct symbol via dlsym() instead of letting the linker figure it
out. Letting the linker do it can bring us into infinite recursion calling
into our very own weak symbol.
Comment 24 Sebastian Dröge (slomo) 2016-06-06 13:49:41 UTC
Can you check if this also works well for you, Diane and Gregoire?
Comment 25 Matthew Waters (ystreet00) 2016-06-06 14:39:24 UTC
I had an undefined symbol of signal from the linker without the aforementioned patch.
Comment 26 Gregoire 2016-06-07 05:00:56 UTC
On gstreamer very latest 1.9.x (git clone on June 6 morning), I'm seeing the compilation problem again, aka. it doesn't find the signal symbol.

In manifest, I have:
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="22" />

In Application.mk, I have:
APP_ABI := armeabi-v7a

Also, I'm using /opt/google/android/ndk-r10e/ndk-build


If I apply the patch marked "2016-06-06 13:48 UTC, Sebastian Dröge (slomo)", the compilation problem disappears.
Comment 27 Sebastian Dröge (slomo) 2016-06-07 07:03:59 UTC
Attachment 329192 [details] pushed as 577f883 - android: Work around NDK ABI incompatibility around bsd_signal/signal in a different way
Comment 28 Sebastian Dröge (slomo) 2016-06-07 07:04:55 UTC
Thanks for testing!