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

$CPP invocation in configure must use $CPPFLAGS #71640

Closed
yan12125 mannequin opened this issue Jul 5, 2016 · 6 comments
Closed

$CPP invocation in configure must use $CPPFLAGS #71640

yan12125 mannequin opened this issue Jul 5, 2016 · 6 comments
Labels
build The build process and cross-build

Comments

@yan12125
Copy link
Mannequin

yan12125 mannequin commented Jul 5, 2016

BPO 27453
Nosy @doko42, @vstinner, @xdegaye, @tpetazzoni, @moreati, @yan12125
Files
  • ndk-clang-preprocessor.patch
  • 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 = None
    closed_at = <Date 2016-07-30.09:43:22.360>
    created_at = <Date 2016-07-05.11:18:43.224>
    labels = ['build']
    title = '$CPP invocation in configure must use $CPPFLAGS'
    updated_at = <Date 2016-07-30.09:43:22.359>
    user = 'https://github.com/yan12125'

    bugs.python.org fields:

    activity = <Date 2016-07-30.09:43:22.359>
    actor = 'xdegaye'
    assignee = 'none'
    closed = True
    closed_date = <Date 2016-07-30.09:43:22.360>
    closer = 'xdegaye'
    components = ['Cross-Build']
    creation = <Date 2016-07-05.11:18:43.224>
    creator = 'yan12125'
    dependencies = []
    files = ['43625']
    hgrepos = []
    issue_num = 27453
    keywords = ['patch']
    message_count = 6.0
    messages = ['269816', '269824', '269827', '271637', '271670', '271671']
    nosy_count = 7.0
    nosy_names = ['doko', 'vstinner', 'xdegaye', 'python-dev', 'thomas-petazzoni', 'Alex.Willmer', 'yan12125']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'compile error'
    url = 'https://bugs.python.org/issue27453'
    versions = ['Python 3.5', 'Python 3.6']

    @yan12125
    Copy link
    Mannequin Author

    yan12125 mannequin commented 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

    @yan12125 yan12125 mannequin added build The build process and cross-build labels Jul 5, 2016
    @xdegaye
    Copy link
    Mannequin

    xdegaye mannequin commented Jul 5, 2016

    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
    Copy link
    Mannequin Author

    yan12125 mannequin commented Jul 5, 2016

    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.

    @xdegaye xdegaye mannequin changed the title Fix cross-compilation with Android NDK and Clang $CPP invocation in configure must use $CPPFLAGS Jul 6, 2016
    @vstinner
    Copy link
    Member

    ndk-clang-preprocessor.patch LGTM.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented 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
    Copy link
    Mannequin

    xdegaye mannequin commented Jul 30, 2016

    Thanks for the patch Chi Hsuan Yen!

    @xdegaye xdegaye mannequin closed this as completed Jul 30, 2016
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    build The build process and cross-build
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant