taka-no-me / android-cmake

CMake toolchain file and other scripts for the Android NDK
1.22k stars 438 forks source link

-fsigned-char breaks binary compatibility on ARM #74

Open stefand opened 8 years ago

stefand commented 8 years ago

android.toolchain.cmake adds -fsigned-char to the build options (line 1237), but ARM is using unsigned chars by default. This breaks library calls, e.g. as described here:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47275

I am running into exactly the problem described in the above bug report with Apitrace on ARM Android. I'll report the issue to Apitrace too, but I don't think it can do much when the build tool unconditionally sets an incompatible ABI.

stefand commented 8 years ago

char.txt

This test program shows the issue. Compile it with -fsigned-char and -funsigned-char (or no option at all) and compare the output. The exact symptom of the wrong setting depends on various factors like the selected C++ runtime library implementation and program behavior. My test program happens to work with gnustl with both char versions, but apitrace writes a bad stream. My test program doesn't write the 255 char with -fsigned-char with the default C++ library (libstdc++ I think).