Issue 32059: detect_modules() in setup.py must also search the sysroot paths (original) (raw)
When cross-compiling, the gcc and clang --sysroot=
compiler option may be used to change the logical path of the system headers and libraries to a path located within the install path of the cross-compiler tool chain.
Android is a special case:
With Unified Headers [1], the most recent versions of the Android NDK add an additional constraint: the root paths of usr/include and usr/lib are distinct. For example when cross-compiling for API 24 and the x86_64 architecture the full paths are:
- headers: ANDROID_NDK_ROOT/sysroot/usr/include
- libraries: ANDROID_NDK_ROOT/platforms/android-24/arch-x86_64/usr/lib64
To use sysroot in this example one needs to set sysroot to ANDROID_NDK_ROOT/sysroot in CFLAGS or CPPFLAGS and to set sysroot to ANDROID_NDK_ROOT/platforms/android-24/arch-x86_64 in LDFLAGS, while on a standard platform where the root path of usr/include and usr/lib is common, one would only need to set sysroot to this root path in CFLAGS.
[1] https://android.googlesource.com/platform/ndk.git/+/master/docs/UnifiedHeaders.md