Message 310952 - Python tracker (original) (raw)
Here are some ideas after testing:
- Testing environment:
- My building scripts at https://github.com/yan12125/python3-android/
- Android NDK r16b
- Google's emulator image 'system-images;android-19;default;x86'
- Ideas/findings:
- Locale emulation for setlocale() no longer works as _locale builds fine.
locale.setlocale(locale.LC_ALL, None) Traceback (most recent call last): File "", line 1, in File "/data/local/tmp/python3/usr/lib/python3.7/locale.py", line 608, in setlocale return _setlocale(category, locale) locale.Error: locale query failed
- Declarations for mmap/sendfile shouldn't be necessary. In Android NDK r16b, sendfile() is defined if __USE_FILE_OFFSET64 is not defined: (from $ANDROID_NDK/sysroot/usr/include/sys/sendfile.h)
#if defined(__USE_FILE_OFFSET64)
#if ANDROID_API >= 21 ssize_t sendfile(int __out_fd, int __in_fd, off_t* __offset, size_t __count) __RENAME(sendfile64) __INTRODUCED_IN(21); #endif /* ANDROID_API >= 21 */
#else ssize_t sendfile(int __out_fd, int __in_fd, off_t* __offset, size_t __count); #endif
#if ANDROID_API >= 21 ssize_t sendfile64(int __out_fd, int __in_fd, off64_t* __offset, size_t __count) __INTRODUCED_IN(21); #endif /* ANDROID_API >= 21 */
__USE_FILE_OFFSET64 is defined as _FILE_OFFSET_BITS is defined to 64 in pyconfig.h. An NDK developer suggest "stop defining _FILE_OFFSET_BITS=64 on 32-bit Android." (https://github.com/android-ndk/ndk/issues/536#issuecomment-333197557) Either disabling large file support on Android or simply don't define _FILE_OFFSET_BITS on Android should work. (Android does not use _LARGEFILE_SOURCE)
- SIGRTMIN/SIGRTMAX: This is a bug on older NDK. r15 has fixed it (https://github.com/android-ndk/ndk/issues/352). I propose to wait until CPython builds with NDK r15+. I don't like adding patches for a known bug in older toolchains and revert them later.