You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
$CPP invocation in configure must use $CPPFLAGS #71640
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2016-07-30.09:43:22.360>created_at=<Date2016-07-05.11:18:43.224>labels= ['build']
title='$CPP invocation in configure must use $CPPFLAGS'updated_at=<Date2016-07-30.09:43:22.359>user='https://github.com/yan12125'
Motivation: Android NDK is deprecating GCC and moving ot Clang/LLVM. From [1]:
We strongly recommend switching to Clang.
GCC in the NDK is now deprecated in favor of Clang.
This patch fixes the only one problem when migrating GCC to Clang.
In my build script, $CPP is set to "${ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -E" and $CPPFLAGS is set to "-target armv7-none-linux-androideabi -gcc-toolchain ${ANDROID_NDK}/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 --sysroot ${ANDROID_NDK}/platforms/android-21/arch-arm/usr -I${PREFIX}/include -DANDROID". I'm not sure whether it's the correct usage of clang, but at least it works.
With such a configuration, most Python parts builds well. Just something wrong - extensions as built as xyz.cpython-36m-x86_64-linux-gnu.so. My patch just fixes $(PLATFORM_TRIPLET) detection.
With configure run as './configure CC="$(CC)" ...' and when CC is set to:
CC = clang --sysroot=$(SYSROOT) -target $(TARGET) -gcc-toolchain $(GCC_TOOLCHAIN)
and building for armv7 on android-21, then configure runs $CPP as:
checking for CPP... clang --sysroot=/opt/android-ndk/platforms/android-21/arch-arm -target armv7-none-linux-androideabi -gcc-toolchain /opt/android-ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 -E
as can be seen by inserting in configure.ac:
AC_MSG_CHECKING([for CPP])
AC_MSG_RESULT([$CPP])
and the shared libraries are named 'module_name.cpython-36m-arm-linux-gnueabi.so'.
OTOH, the 'configure' script runs its own preprocessings with the following idiom:
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then :
where 'ac_cpp' is set to ac_cpp='$CPP $CPPFLAGS'.
So the proposed patch LGTM.
PLATFORM_TRIPLETs are specific to multiarch systems such as debian and should not be relied upon on Android, but they should not be entirely wrong of course.
yan12125 commented on Jul 5, 2016
yan12125mannequin
MannequinAuthor
More actions
Several days ago I have once tried to set
CC="clang -target $(TARGET) -gcc-toolchain $(GCC_TOOLCHAIN)", and it failed to build some dependency of Python (I can't remember). Just tried and everything is OK. Dunno what's changed. Anyway both approaches (-target in $CC/$CXX/$CPP and -target in $CFLAGS/$CXXFLAGS/$CPPFLAGS) should be supported.
Activity
yan12125 commentedon Jul 5, 2016
Motivation: Android NDK is deprecating GCC and moving ot Clang/LLVM. From [1]:
We strongly recommend switching to Clang.
GCC in the NDK is now deprecated in favor of Clang.
This patch fixes the only one problem when migrating GCC to Clang.
In my build script,$CPP is set to "$ {ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -E" and $CPPFLAGS is set to "-target armv7-none-linux-androideabi -gcc-toolchain $ {ANDROID_NDK}/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 --sysroot ${ANDROID_NDK}/platforms/android-21/arch-arm/usr -I${PREFIX}/include -DANDROID". I'm not sure whether it's the correct usage of clang, but at least it works.
With such a configuration, most Python parts builds well. Just something wrong - extensions as built as xyz.cpython-36m-x86_64-linux-gnu.so. My patch just fixes $(PLATFORM_TRIPLET) detection.
[1] https://developer.android.com/ndk/downloads/revision_history.html
xdegaye commentedon Jul 5, 2016
With configure run as './configure CC="$(CC)" ...' and when CC is set to:$(TARGET) -gcc-toolchain $ (GCC_TOOLCHAIN)
CC = clang --sysroot=$(SYSROOT) -target
and building for armv7 on android-21, then configure runs $CPP as:
checking for CPP... clang --sysroot=/opt/android-ndk/platforms/android-21/arch-arm -target armv7-none-linux-androideabi -gcc-toolchain /opt/android-ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 -E
as can be seen by inserting in configure.ac:
AC_MSG_CHECKING([for CPP])
AC_MSG_RESULT([$CPP])
and the shared libraries are named 'module_name.cpython-36m-arm-linux-gnueabi.so'.
OTOH, the 'configure' script runs its own preprocessings with the following idiom:
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then :
where 'ac_cpp' is set to ac_cpp='$CPP $CPPFLAGS'.
So the proposed patch LGTM.
PLATFORM_TRIPLETs are specific to multiarch systems such as debian and should not be relied upon on Android, but they should not be entirely wrong of course.
yan12125 commentedon Jul 5, 2016
Several days ago I have once tried to set$(TARGET) -gcc-toolchain $ (GCC_TOOLCHAIN)", and it failed to build some dependency of Python (I can't remember). Just tried and everything is OK. Dunno what's changed. Anyway both approaches (-target in $CC/$CXX/$CPP and -target in $CFLAGS/$CXXFLAGS/$CPPFLAGS) should be supported.
CC="clang -target
[-]Fix cross-compilation with Android NDK and Clang[/-][+]$CPP invocation in configure must use $CPPFLAGS[/+]vstinner commentedon Jul 29, 2016
ndk-clang-preprocessor.patch LGTM.
python-dev commentedon Jul 30, 2016
New changeset 4cb94e561e2d by Xavier de Gaye in branch '3.5':
Issue bpo-27453: CPP invocation in configure must use CPPFLAGS.
https://hg.python.org/cpython/rev/4cb94e561e2d
New changeset 92b3ce7ca95c by Xavier de Gaye in branch 'default':
(merge from 3.5) Issue bpo-27453: CPP invocation in configure must use CPPFLAGS.
https://hg.python.org/cpython/rev/92b3ce7ca95c
xdegaye commentedon Jul 30, 2016
Thanks for the patch Chi Hsuan Yen!