Skip to content

$CPP invocation in configure must use $CPPFLAGS #71640

Description

@yan12125
mannequin
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']

    Activity

    1. yan12125 commented on Jul 5, 2016

      yan12125mannequin
      MannequinAuthor

      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

    2. added
      buildThe build process and cross-build
      on Jul 5, 2016
    3. xdegaye commented on Jul 5, 2016

      xdegayemannequin
      Mannequin

      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.

    4. yan12125 commented on Jul 5, 2016

      yan12125mannequin
      MannequinAuthor

      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.

    5. changed the title [-]Fix cross-compilation with Android NDK and Clang[/-] [+]$CPP invocation in configure must use $CPPFLAGS[/+] on Jul 6, 2016
    6. vstinner commented on Jul 29, 2016

      @vstinner
      Member

      ndk-clang-preprocessor.patch LGTM.

    7. python-dev commented on Jul 30, 2016

      python-devmannequin
      Mannequin

      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

    8. xdegaye commented on Jul 30, 2016

      xdegayemannequin
      Mannequin

      Thanks for the patch Chi Hsuan Yen!

    9. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      buildThe build process and cross-build

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions