Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android NDK build fail #93

Closed
stari4ek opened this issue Feb 4, 2015 · 3 comments
Closed

Android NDK build fail #93

stari4ek opened this issue Feb 4, 2015 · 3 comments

Comments

@stari4ek
Copy link

stari4ek commented Feb 4, 2015

$ ndk-which gcc
/Users/sotnikm/NVPACK/android-ndk-r10d/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc

$ ndk-build V=1

[armeabi] Compile++ thumb: cppformat_static <= format.cc
/Users/sotnikm/NVPACK/android-ndk-r10d/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-g++ -MMD -MP -MF ./obj/local/armeabi/objs/cppformat_static/cppformat/format.o.d -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv5te -mtune=xscale -msoft-float -fno-exceptions -fno-rtti -mthumb -Os -g -DNDEBUG -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -I/Users/sotnikm/NVPACK/android-ndk-r10d/sources/cxx-stl/gnu-libstdc++/4.8/include -I/Users/sotnikm/NVPACK/android-ndk-r10d/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi/include -I/Users/sotnikm/NVPACK/android-ndk-r10d/sources/cxx-stl/gnu-libstdc++/4.8/include/backward -Ijni/../../Libs/3rdParty/cocos2d/external/../../cppformat/project.android/../src -DANDROID  -Wa,--noexecstack -Wformat -Werror=format-security    -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char -DNDEBUG  -I/Users/sotnikm/NVPACK/android-ndk-r10d/platforms/android-15/arch-arm/usr/include -c  jni/../../Libs/3rdParty/cocos2d/external/../../cppformat/project.android/../src/cppformat/format.cc -o ./obj/local/armeabi/objs/cppformat_static/cppformat/format.o 
jni/../../Libs/3rdParty/cocos2d/external/../../cppformat/project.android/../src/cppformat/format.cc: In function 'int {anonymous}::safe_strerror(int, char*&, std::size_t)':
jni/../../Libs/3rdParty/cocos2d/external/../../cppformat/project.android/../src/cppformat/format.cc:138:61: error: invalid conversion from 'int' to 'char*' [-fpermissive]
   char *message = strerror_r(error_code, buffer, buffer_size);
                                                             ^
make: *** [obj/local/armeabi/objs/cppformat_static/cppformat/format.o] Error 1

it uses android-ndk-r10d/platforms/android-15/arch-arm/usr/include/string.h where

extern char*  strerror(int);
extern int    strerror_r(int errnum, char *buf, size_t n);
@vitaut
Copy link
Contributor

vitaut commented Feb 4, 2015

Thanks for reporting, I'll look into it.

@stari4ek
Copy link
Author

stari4ek commented Feb 5, 2015

I've updated it with

-#ifdef _GNU_SOURCE
+#if defined(GNU_SOURCE) && (_POSIX_C_SOURCE < 200112L) && (_XOPEN_SOURCE < 600)

but I'm not totally sure that it's really valid for all kind of platforms.
According to http://linux.die.net/man/3/strerror_r XSI-compatible is preferable (with int)

@vitaut
Copy link
Contributor

vitaut commented Feb 5, 2015

Should be fixed in bdeffc3. Unfortunately Android doesn't seem to follow the docs in http://linux.die.net/man/3/strerror_r so I had to check for __ANDROID__. Thanks again!

@vitaut vitaut closed this as completed Feb 5, 2015
shdown added a commit to shdown/luastatus that referenced this issue Jun 27, 2019
See: http://man7.org/linux/man-pages/man3/strerror_r.3.html

1. That "(_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !
   _GNU_SOURCE" check is glibc-specific.

2. It is simply wrong. We used "defined(_GNU_SOURCE)" instead of
   "_GNU_SOURCE", as the latter resulted in a compilation error in (the
   most common?) case of "-D_GNU_SOURCE", with all the header files just
   checking for "defined(_GNU_SOURCE)". Like, really, what the fuck?
   They have a totally broken check in the man page.

   Turns out, even that way it was slightly wrong: see, for example,
   fmtlib/fmt#93.

3. We *can* ensure that `libls/cstring_utils.c` file is compiled with
   the feature test macros that result in the XSI-compliant version of
   strerror_r().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants