sincos should not be used with Android's Bionic.

Bug #908125 reported by Ray Donnelly
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Linaro Android
Fix Released
Undecided
Bernhard Rosenkraenzer

Bug Description

Early versions of Android's bionic (which are the only ones that can be used due to binary compatibility) do not contain sincos.

Even though it was later added, the implementation simply calls sin and cos [1], so calling it is a pessimization, not an optimization:

[1] https://github.com/android/platform_bionic/blob/master/libm/sincos.c

Here is a patch to fix this (please let me know if this isn't the best way to submit patches):

diff -burN a/gcc-4.6-linaro-2011.12/gcc/config/linux.h b/gcc-gcc-4.6-linaro-2011.12/gcc/config/linux.h
--- a/gcc-4.6-linaro-2011.12/gcc/config/linux.h 2011-10-23 11:27:57.746527669 +0100
+++ b/gcc-4.6-linaro-2011.12/gcc/config/linux.h 2011-10-23 11:33:22.256626063 +0100
@@ -95,5 +95,9 @@
    is present in the runtime library. */
 #define TARGET_C99_FUNCTIONS (OPTION_GLIBC)

-/* Whether we have sincos that follows the GNU extension. */
-#define TARGET_HAS_SINCOS (OPTION_GLIBC || OPTION_BIONIC)
+/* Whether we have sincos that follows the GNU extension.
+ Linaro set this for OPTION_BIONIC. However, on arm, libm
+ is from Android-3 which doesn't provide sincos and on x86
+ sincos calls sin and cos internally anyway, so this
+ optimization becomes a pessimization. */
+#define TARGET_HAS_SINCOS (OPTION_GLIBC)

Revision history for this message
Bernhard Rosenkraenzer (berolinux) wrote :

I think the better thing to do is add a proper sincos() implementation to bionic, allowing us to take advantage of the optimization instead of turning it off to avoid the pessimization. I just did that:

http://review.android.git.linaro.org/#change,1319

Of course, this doesn't help with prehistoric builds (android-3), but I doubt those still have any relevance...

Changed in linaro-android:
assignee: nobody → Bernhard Rosenkraenzer (berolinux)
status: New → Triaged
tags: added: linaro-android
Changed in linaro-android:
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.