Repository: kivy/python-for-android

Issue:
ifaddrs compilation error
<!--
The issue tracker is a tool to address bugs.
Please use the Disord community or Stack Overflow for support questions,
more information at https://github.com/kivy/python-for-android#support

Before opening a new issue, make sure you do the following:
    * check that your issue isn't already filed: https://github.com/kivy/python-for-android/issues
    * prepare a short, runnable example that reproduces the issue
    * make sure to have `log_level = 2` in your `buildozer.spec`
    * reproduce the problem with the latest development version (`p4a.branch = master`)
    * double-check that the issue is indeed a bug and not a support request
    * please use backticks to format code or logs
-->

### Versions

* Python: Python 2.7 (host), Python 3.6 (target)
* OS: Ubuntu 18.04
* Kivy: N/A
* Cython: 0.21

### Description

Compiling `ifaddrs` recipe fails when it should not.

### buildozer.spec

Command:
```sh
python setup_testapp_python3.py apk --sdk-dir /home/andre/.buildozer/android/platform/android-sdk-20 --ndk-dir /home/andre/.buildozer/crystax-ndk --bootstrap sdl2 --requirements python3crystax,ifaddrs
```

Environment:
```
export ANDROID_SDK_HOME=/home/andre/.buildozer/android/platform/android-sdk-20 ANDROID_NDK_HOME=/home/andre/.buildozer/android/platform/android-ndk-r9c CRYSTAX_NDK_HOME=/home/andre/.buildozer/crystax-ndk
```

### Logs

```
python setup_testapp_python3.py apk --sdk-dir /home/andre/.buildozer/android/platform/android-sdk-20 --ndk-dir /home/andre/.buildozer/crystax-ndk --bootstrap sdl2 --requirements python
3crystax,ifaddrs                                                                                                                                                                          
('packages are', [])                                                                                                                
running apk                                                                                                                                                                               
WARNING: You did not supply an Android package identifier, trying org.test.testapp_python3 instead.
         This may fail if this is not a valid identifier
Including testapp/main.py                                                           
Including testapp/colours.png                                                                                                                                                                                                                                                            [INFO]:    Will compile for the following archs: armeabi-v7a                                                                                                                                                                                                                             
[INFO]:    Getting Android API version from user argument
[INFO]:    Available Android APIs are (19)                                       
[INFO]:    Requested API target 19 is available, continuing.                          
[INFO]:    Getting NDK dir from from user argument             
[INFO]:    Got NDK version from from user argument                                                                                                                                                                       
[INFO]:    Using Crystax NDK 10.3.2                                                                                          
[INFO]:    Found virtualenv at /home/andre/.local/bin/virtualenv                 
[INFO]:    Found the following toolchain versions: ['4.9', '5', 'clang3.6', 'clang3.7']              
[INFO]:    Picking the latest gcc toolchain, here 5                
[INFO]:    No existing dists meet the given requirements!
[INFO]:    No dist exists that meets your requirements, so one will be built.                  
/home/andre/workspace/python-for-android/pythonforandroid/recipes/python3crystax/__init__.py:2: RuntimeWarning: Parent module 'pythonforandroid.recipes' not found while handling absolute import
  from pythonforandroid.recipe import TargetPythonRecipe                               
/home/andre/workspace/python-for-android/pythonforandroid/recipes/python3crystax/__init__.py:3: RuntimeWarning: Parent module 'pythonforandroid.recipes' not found while handling absolute import
  from pythonforandroid.toolchain import shprint                                                                              
/home/andre/workspace/python-for-android/pythonforandroid/recipes/python3crystax/__init__.py:4: RuntimeWarning: Parent module 'pythonforandroid.recipes' not found while handling absolute import
  from pythonforandroid.logger import info, error                                
/home/andre/workspace/python-for-android/pythonforandroid/recipes/python3crystax/__init__.py:5: RuntimeWarning: Parent module 'pythonforandroid.recipes' not found while handling absolute import
  from pythonforandroid.util import ensure_dir, temp_directory                                                                                   
/home/andre/workspace/python-for-android/pythonforandroid/recipes/python3crystax/__init__.py:6: RuntimeWarning: Parent module 'pythonforandroid.recipes' not found while handling absolute import
  from os.path import exists, join                                                                 
/home/andre/workspace/python-for-android/pythonforandroid/recipes/python3crystax/__init__.py:7: RuntimeWarning: Parent module 'pythonforandroid.recipes' not found while handling absolute import
  import sh                                                                                                                                          
/home/andre/workspace/python-for-android/pythonforandroid/recipes/hostpython3crystax/__init__.py:1: RuntimeWarning: Parent module 'pythonforandroid.recipes' not found while handling absolute import                                                                                    
  from pythonforandroid.toolchain import Recipe, shprint                                                                                                                                                                                                                                 
/home/andre/workspace/python-for-android/pythonforandroid/recipes/hostpython3crystax/__init__.py:2: RuntimeWarning: Parent module 'pythonforandroid.recipes' not found while handling absolute import
  from os.path import join                                                       
/home/andre/workspace/python-for-android/pythonforandroid/recipes/hostpython3crystax/__init__.py:3: RuntimeWarning: Parent module 'pythonforandroid.recipes' not found while handling absolute import
  import sh                                                                                
/home/andre/workspace/python-for-android/pythonforandroid/recipes/ifaddrs/__init__.py:3: RuntimeWarning: Parent module 'pythonforandroid.recipes' not found while handling absolute import
  from os.path import join, exists                                                                   
/home/andre/workspace/python-for-android/pythonforandroid/recipes/ifaddrs/__init__.py:4: RuntimeWarning: Parent module 'pythonforandroid.recipes' not found while handling absolute import
  import sh                                                                                         
/home/andre/workspace/python-for-android/pythonforandroid/recipes/ifaddrs/__init__.py:5: RuntimeWarning: Parent module 'pythonforandroid.recipes' not found while handling absolute import
  from pythonforandroid.logger import info, shprint                                             
/home/andre/workspace/python-for-android/pythonforandroid/recipes/ifaddrs/__init__.py:6: RuntimeWarning: Parent module 'pythonforandroid.recipes' not found while handling absolute import
  from pythonforandroid.recipe import CompiledComponentsPythonRecipe                            
/home/andre/workspace/python-for-android/pythonforandroid/recipes/ifaddrs/__init__.py:7: RuntimeWarning: Parent module 'pythonforandroid.recipes' not found while handling absolute import
  from pythonforandroid.toolchain import current_directory                                          
/home/andre/workspace/python-for-android/pythonforandroid/recipes/hostpython2/__init__.py:2: RuntimeWarning: Parent module 'pythonforandroid.recipes' not found while handling absolute import
  from pythonforandroid.toolchain import Recipe, shprint, current_directory, info, warning      
/home/andre/workspace/python-for-android/pythonforandroid/recipes/hostpython2/__init__.py:3: RuntimeWarning: Parent module 'pythonforandroid.recipes' not found while handling absolute import
  from os.path import join, exists
/home/andre/workspace/python-for-android/pythonforandroid/recipes/hostpython2/__init__.py:4: RuntimeWarning: Parent module 'pythonforandroid.recipes' not found while handling absolute import
  import os
/home/andre/workspace/python-for-android/pythonforandroid/recipes/hostpython2/__init__.py:5: RuntimeWarning: Parent module 'pythonforandroid.recipes' not found while handling absolute import
  import sh
/home/andre/workspace/python-for-android/pythonforandroid/recipes/python2/__init__.py:1: RuntimeWarning: Parent module 'pythonforandroid.recipes' not found while handling absolute import
  from pythonforandroid.recipe import TargetPythonRecipe, Recipe
/home/andre/workspace/python-for-android/pythonforandroid/recipes/python2/__init__.py:2: RuntimeWarning: Parent module 'pythonforandroid.recipes' not found while handling absolute import
  from pythonforandroid.toolchain import shprint, current_directory, info
/home/andre/workspace/python-for-android/pythonforandroid/recipes/python2/__init__.py:3: RuntimeWarning: Parent module 'pythonforandroid.recipes' not found while handling absolute import
  from pythonforandroid.patching import (is_darwin, is_api_gt,
/home/andre/workspace/python-for-android/pythonforandroid/recipes/python2/__init__.py:5: RuntimeWarning: Parent module 'pythonforandroid.recipes' not found while handling absolute import
  from os.path import exists, join, realpath
/home/andre/workspace/python-for-android/pythonforandroid/recipes/python2/__init__.py:6: RuntimeWarning: Parent module 'pythonforandroid.recipes' not found while handling absolute import
  import sh
[INFO]:    Found multiple valid dependency orders:
[INFO]:        ['hostpython2', 'hostpython3crystax', u'python3crystax', u'ifaddrs']
[INFO]:        ['hostpython3', 'hostpython3crystax', u'python3crystax', u'ifaddrs']
[INFO]:    Using the first of these: ['hostpython2', 'hostpython3crystax', u'python3crystax', u'ifaddrs']
[INFO]:    The selected bootstrap is sdl2_gradle
[INFO]:    # Creating dist with sdl2_gradle bootstrap
[INFO]:    Dist will have name bdisttest_python3 and recipes (python3crystax, ifaddrs)
[INFO]:    Dist will also contain modules () installed from pip
[DEBUG]:   -> running cp -r /home/andre/workspace/python-for-android/pythonforandroid/bootstraps/sdl2/build /home/andre/.local/share/python-for-android/build/bootstrap_builds/sdl2_gradle-python3crystax
[INFO]:    -> directory context /home/andre/.local/share/python-for-android/build/bootstrap_builds/sdl2_gradle-python3crystax
[INFO]:    <- directory context /home/andre/workspace/python-for-android/testapps
[INFO]:    Recipe build order is ['hostpython2', 'hostpython3crystax', u'python3crystax', u'ifaddrs']
[INFO]:    # Downloading recipes 
[INFO]:    Downloading hostpython2
[DEBUG]:   -> running mkdir -p /home/andre/.local/share/python-for-android/packages/hostpython2
[INFO]:    -> directory context /home/andre/.local/share/python-for-android/packages/hostpython2
[DEBUG]:   -> running basename https://python.org/ftp/python/2.7.2/Python-2.7.2.tar.bz2
[DEBUG]:        Python-2.7.2.tar.bz2
[INFO]:    hostpython2 download already cached, skipping
[INFO]:    <- directory context /home/andre/workspace/python-for-android/testapps
[INFO]:    Downloading hostpython3crystax
[INFO]:    Skipping hostpython3crystax download as no URL is set
[INFO]:    Downloading python3crystax
[DEBUG]:   -> running mkdir -p /home/andre/.local/share/python-for-android/packages/python3crystax
[INFO]:    -> directory context /home/andre/.local/share/python-for-android/packages/python3crystax
[DEBUG]:   -> running basename
[DEBUG]:
[DEBUG]:   Downloading python3crystax from
[DEBUG]:   -> running rm -f .mark-
[DEBUG]:   -> running touch .mark-
[INFO]:    <- directory context /home/andre/workspace/python-for-android/testapps
[INFO]:    Downloading ifaddrs
[DEBUG]:   -> running mkdir -p /home/andre/.local/share/python-for-android/packages/ifaddrs
[INFO]:    -> directory context /home/andre/.local/share/python-for-android/packages/ifaddrs
[DEBUG]:   -> running basename git+https://github.com/morristech/android-ifaddrs.git
[DEBUG]:        android-ifaddrs.git
[DEBUG]:   Downloading ifaddrs from git+https://github.com/morristech/android-ifaddrs.git
[DEBUG]:   -> running rm -f .mark-android-ifaddrs.git
[INFO]:    Downloading ifaddrs from git+https://github.com/morristech/android-ifaddrs.git
[INFO]:    -> directory context android-ifaddrs.git
[DEBUG]:   -> running git fetch --tags
[DEBUG]:   -> running git checkout master
[DEBUG]:        Already on 'master'
[DEBUG]:        Your branch is up to date with 'origin/master'.
[DEBUG]:   -> running git pull
[DEBUG]:        Already up to date.
[DEBUG]:   -> running git pull --recurse-submodules
[DEBUG]:        Already up to date.
[DEBUG]:   -> running git submodule update --recursive
[INFO]:    <- directory context /home/andre/.local/share/python-for-android/packages/ifaddrs
[DEBUG]:   -> running touch .mark-android-ifaddrs.git
[INFO]:    <- directory context /home/andre/workspace/python-for-android/testapps
[INFO]:    # Building all recipes for arch armeabi-v7a
[INFO]:    # Unpacking recipes
[INFO]:    Unpacking hostpython2 for armeabi-v7a
[DEBUG]:   -> running basename https://python.org/ftp/python/2.7.2/Python-2.7.2.tar.bz2
[DEBUG]:        Python-2.7.2.tar.bz2
[INFO]:    -> directory context /home/andre/.local/share/python-for-android/build/other_builds/hostpython2/desktop
[INFO]:    hostpython2 is already unpacked, skipping
[INFO]:    <- directory context /home/andre/workspace/python-for-android/testapps
[INFO]:    Unpacking hostpython3crystax for armeabi-v7a
[INFO]:    Skipping hostpython3crystax unpack as no URL is set
[INFO]:    Unpacking python3crystax for armeabi-v7a
[DEBUG]:   -> running basename
[DEBUG]:
[INFO]:    -> directory context /home/andre/.local/share/python-for-android/build/other_builds/python3crystax-version3.6/armeabi-v7a
[INFO]:    python3crystax is already unpacked, skipping                                                                                                                                                                                                                         [113/265]
[INFO]:    <- directory context /home/andre/workspace/python-for-android/testapps
[INFO]:    Unpacking ifaddrs for armeabi-v7a
[DEBUG]:   -> running basename git+https://github.com/morristech/android-ifaddrs.git
[DEBUG]:        android-ifaddrs.git
[INFO]:    -> directory context /home/andre/.local/share/python-for-android/build/other_builds/ifaddrs-hostpython2-python3crystax/armeabi-v7a
[INFO]:    ifaddrs is already unpacked, skipping
[INFO]:    <- directory context /home/andre/workspace/python-for-android/testapps
[INFO]:    # Prebuilding recipes
[INFO]:    Prebuilding hostpython2 for armeabi-v7a
[DEBUG]:   -> running cp /home/andre/workspace/python-for-android/pythonforandroid/recipes/hostpython2/Setup /home/andre/.local/share/python-for-android/build/other_builds/hostpython2/desktop/hostpython2/Modules/Setup
[INFO]:    Applying patches for hostpython2[armeabi-v7a]
[INFO]:    hostpython2 already patched, skipping
[INFO]:    Prebuilding hostpython3crystax for armeabi-v7a
[INFO]:    hostpython3crystax has no prebuild_armeabi_v7a, skipping
[INFO]:    Prebuilding python3crystax for armeabi-v7a
[INFO]:    python3crystax has no prebuild_armeabi_v7a, skipping
[INFO]:    Prebuilding ifaddrs for armeabi-v7a
[INFO]:    # Building recipes
[INFO]:    Building hostpython2 for armeabi-v7a
[INFO]:    -> directory context /home/andre/.local/share/python-for-android/build/other_builds/hostpython2/desktop/hostpython2
[INFO]:    hostpython already exists, skipping build
[INFO]:    <- directory context /home/andre/workspace/python-for-android/testapps
[INFO]:    Building hostpython3crystax for armeabi-v7a
[DEBUG]:   -> running mkdir -p /home/andre/.local/share/python-for-android/build/other_builds/hostpython3crystax/desktop/hostpython3crystax/build
[DEBUG]:   -> running ln -sf /usr/bin/python3.6 /home/andre/.local/share/python-for-android/build/other_builds/hostpython3crystax/desktop/hostpython3crystax/hostpython
[INFO]:    Building python3crystax for armeabi-v7a
[INFO]:    Building ifaddrs for armeabi-v7a
[INFO]:    -> directory context /home/andre/.local/share/python-for-android/build/other_builds/ifaddrs-hostpython2-python3crystax/armeabi-v7a/ifaddrs
[DEBUG]:   -> running ccache -DANDROID -mandroid -fomit-frame-pointer -D__ANDROID_API__=19 -I/home/andre/.buildozer/crystax-ndk-10.3.2/platforms/android-19/arch-arm -isysroot /home/andre/.buildozer/crystax-ndk-10.3.2/platforms/android-19/arch-arm -I/home/andre/.local/share/python-
for-android/build/python-installs/bdisttest_python3/include/python3.6 -I/home/andre/.buildozer/crystax-ndk-10.3.2/sources/python/3.6/include/python/ -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -mthumb -I/home/andre/.buildozer/crystax-ndk-10.3.2/sources/python/3.6/include/python -I
. -c -l. ifaddrs.c -I.
[DEBUG]:        /usr/bin/ccache: invalid option -- 'D'
[DEBUG]:        Usage:
[DEBUG]:            ccache [options]
[DEBUG]:            ccache compiler [compiler options]
[DEBUG]:            compiler [compiler options]          (via symbolic link)
[DEBUG]:
[DEBUG]:        Options:
[DEBUG]:            -c, --cleanup         delete old files and recalculate size counters
[DEBUG]:                                  (normally not needed as this is done automatically)
[DEBUG]:            -C, --clear           clear the cache completely (except configuration)
[DEBUG]:            -F, --max-files=N     set maximum number of files in cache to N (use 0 for
[DEBUG]:                                  no limit)
[DEBUG]:            -M, --max-size=SIZE   set maximum size of cache to SIZE (use 0 for no
[DEBUG]:                                  limit); available suffixes: k, M, G, T (decimal) and
[DEBUG]:                                  Ki, Mi, Gi, Ti (binary); default suffix: G
[DEBUG]:            -o, --set-config=K=V  set configuration key K to value V
[DEBUG]:            -p, --print-config    print current configuration options
[DEBUG]:            -s, --show-stats      show statistics summary
[DEBUG]:            -z, --zero-stats      zero statistics counters
[DEBUG]:
[DEBUG]:            -h, --help            print this help text
[DEBUG]:            -V, --version         print version and copyright information
[DEBUG]:
[DEBUG]:        See also <https://ccache.samba.org>.
Exception in thread background thread for pid 9345:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/home/andre/workspace/python-for-android/venv/local/lib/python2.7/site-packages/sh.py", line 1540, in wrap
    fn(*args, **kwargs)
  File "/home/andre/workspace/python-for-android/venv/local/lib/python2.7/site-packages/sh.py", line 2459, in background_thread
    handle_exit_code(exit_code)
  File "/home/andre/workspace/python-for-android/venv/local/lib/python2.7/site-packages/sh.py", line 2157, in fn
    return self.command.handle_command_exit_code(exit_code)
  File "/home/andre/workspace/python-for-android/venv/local/lib/python2.7/site-packages/sh.py", line 815, in handle_command_exit_code
    raise exc
ErrorReturnCode_1:

  RAN: /usr/bin/ccache -DANDROID -mandroid -fomit-frame-pointer -D__ANDROID_API__=19 -I/home/andre/.buildozer/crystax-ndk-10.3.2/platforms/android-19/arch-arm -isysroot /home/andre/.buildozer/crystax-ndk-10.3.2/platforms/android-19/arch-arm -I/home/andre/.local/share/python-for-an
droid/build/python-installs/bdisttest_python3/include/python3.6 -I/home/andre/.buildozer/crystax-ndk-10.3.2/sources/python/3.6/include/python/ -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -mthumb -I/home/andre/.buildozer/crystax-ndk-10.3.2/sources/python/3.6/include/python -I. -c -
l. ifaddrs.c -I.

  STDOUT:
/usr/bin/ccache: invalid option -- 'D'
Usage:
    ccache [options]
    ccache compiler [compiler options]
    compiler [compiler options]          (via symbolic link)

Options:
    -c, --cleanup         delete old files and recalculate size counters
                          (normally not needed as this is done automatically)
    -C, --clear           clear the cache completely (except configuration)
    -F, --max-files=N     set maximum number of files in cache to N (use 0 for
                          no limit)
    -M, --max-size=SIZE   set maximum size of cache to SIZE (use 0 for no
                          limit); available suffixes: k, M, G, T (decimal) and
                          Ki, Mi, Gi, Ti (binary); default suffix: G
    -o, --set-config=K=V  set configuration key K to value V
    -p, --print-config    print current configuration options
    -s, --show-stats      show statistics summary
    -z, --zero-stats      zero statistics counters

    -h, --help            print this help text
    -V, --version         print version and copyright information

See also <https://ccache.samba.org>.


  STDERR:


Traceback (most recent call last):
  File "setup_testapp_python3.py", line 30, in <module>
    package_data={'testapp': ['*.py', '*.png']}
  File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/home/andre/workspace/python-for-android/pythonforandroid/bdistapk.py", line 81, in run
    main()
  File "/home/andre/workspace/python-for-android/pythonforandroid/toolchain.py", line 999, in main
    ToolchainCL()
  File "/home/andre/workspace/python-for-android/pythonforandroid/toolchain.py", line 532, in __init__
    getattr(self, args.subparser_name.replace('-', '_'))(args)
  File "/home/andre/workspace/python-for-android/pythonforandroid/toolchain.py", line 145, in wrapper_func
    build_dist_from_args(ctx, dist, args)
  File "/home/andre/workspace/python-for-android/pythonforandroid/toolchain.py", line 189, in build_dist_from_args
    build_recipes(build_order, python_modules, ctx)
  File "/home/andre/workspace/python-for-android/pythonforandroid/build.py", line 580, in build_recipes
    recipe.build_arch(arch)
  File "/home/andre/workspace/python-for-android/pythonforandroid/recipes/ifaddrs/__init__.py", line 48, in build_arch
    shprint(cc, *cflags, _env=env)
  File "/home/andre/workspace/python-for-android/pythonforandroid/logger.py", line 176, in shprint
    for line in output:
  File "/home/andre/workspace/python-for-android/venv/local/lib/python2.7/site-packages/sh.py", line 863, in next
    self.wait()
  File "/home/andre/workspace/python-for-android/venv/local/lib/python2.7/site-packages/sh.py", line 792, in wait
    self.handle_command_exit_code(exit_code)
  File "/home/andre/workspace/python-for-android/venv/local/lib/python2.7/site-packages/sh.py", line 815, in handle_command_exit_code
    raise exc
sh.ErrorReturnCode_1:

  RAN: /usr/bin/ccache -DANDROID -mandroid -fomit-frame-pointer -D__ANDROID_API__=19 -I/home/andre/.buildozer/crystax-ndk-10.3.2/platforms/android-19/arch-arm -isysroot /home/andre/.buildozer/crystax-ndk-10.3.2/platforms/android-19/arch-arm -I/home/andre/.local/share/python-for-an
droid/build/python-installs/bdisttest_python3/include/python3.6 -I/home/andre/.buildozer/crystax-ndk-10.3.2/sources/python/3.6/include/python/ -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -mthumb -I/home/andre/.buildozer/crystax-ndk-10.3.2/sources/python/3.6/include/python -I. -c -
l. ifaddrs.c -I.

  STDOUT:
/usr/bin/ccache: invalid option -- 'D'
Usage:
    ccache [options]
    ccache compiler [compiler options]
    compiler [compiler options]          (via symbolic link)

Options:
    -c, --cleanup         delete old files and recalculate size counters
                          (normally not needed as this is done automatically)
    -C, --clear           clear the cache completely (except configuration)
    -F, --max-files=N     set maximum number of files in cache to N (use 0 for
                          no limit)
    -M, --max-size=SIZE   set maximum size of cache to SIZE (use 0 for no
                          limit); available suffixes: k, M, G, T (decimal) and
                          Ki, Mi, Gi, Ti (binary); default suffix: G
    -o, --set-config=K=V  set configuration key K to value V
    -p, --print-config    print current configuration options
    -s, --show-stats      show statistics summary
    -z, --zero-stats      zero statistics counters

    -h, --help            print this help text
    -V, --version         print version and copyright information

See also <https://ccache.samba.org>.


  STDERR:
```

The relevant part of the error is:
```
  RAN: /usr/bin/ccache -DANDROID -mandroid -fomit-frame-pointer -D__ANDROID_API__=19 -I/home/andre/.buildozer/crystax-ndk-10.3.2/platforms/android-19/arch-arm -isysroot /home/andre/.buildozer/crystax-ndk-10.3.2/platforms/android-19/arch-arm -I/home/andre/.local/share/python-for-an
droid/build/python-installs/bdisttest_python3/include/python3.6 -I/home/andre/.buildozer/crystax-ndk-10.3.2/sources/python/3.6/include/python/ -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -mthumb -I/home/andre/.buildozer/crystax-ndk-10.3.2/sources/python/3.6/include/python -I. -c -
l. ifaddrs.c -I.

  STDOUT:
/usr/bin/ccache: invalid option -- 'D'
```

### Cause

This is because [ifaddrs recipe](https://github.com/kivy/python-for-android/blob/839342fa339546d4af7468f501ee308e6542bc27/pythonforandroid/recipes/ifaddrs/__init__.py) is splitting/cutting the `CC` environment and keeping only the first part which is ccache rather than the actual compiler, see [line 43](https://github.com/kivy/python-for-android/blob/839342fa339546d4af7468f501ee308e6542bc27/pythonforandroid/recipes/ifaddrs/__init__.py#L43).


Discussion:
@om26er I remember you said you fixed it earlier https://github.com/kivy/python-for-android/pull/1298#issuecomment-396761506.
Would you like to pull request your fix for that one?

Resolving patch:
diff --git a/ci/constants.py b/ci/constants.py
--- a/ci/constants.py
+++ b/ci/constants.py
@@ -23,8 +23,6 @@ class TargetPython(Enum):
     'flask',
     'groestlcoin_hash',
     'hostpython3crystax',
-    # https://github.com/kivy/python-for-android/issues/1398
-    'ifaddrs',
     # https://github.com/kivy/python-for-android/issues/1354
     'kivent_core', 'kivent_cymunk', 'kivent_particles', 'kivent_polygen',
     'kiwisolver',
@@ -68,8 +66,6 @@ class TargetPython(Enum):
     # enum34 is not compatible with Python 3.6 standard library
     # https://stackoverflow.com/a/45716067/185510
     'enum34',
-    # https://github.com/kivy/python-for-android/issues/1398
-    'ifaddrs',
     # https://github.com/kivy/python-for-android/issues/1399
     'libglob',
     # cannot find -lcrystax
diff --git a/pythonforandroid/recipes/ifaddrs/__init__.py b/pythonforandroid/recipes/ifaddrs/__init__.py
--- a/pythonforandroid/recipes/ifaddrs/__init__.py
+++ b/pythonforandroid/recipes/ifaddrs/__init__.py
@@ -8,20 +8,14 @@
 
 
 class IFAddrRecipe(CompiledComponentsPythonRecipe):
-    version = 'master'
-    url = 'git+https://github.com/morristech/android-ifaddrs.git'
+    version = '8f9a87c'
+    url = 'https://github.com/morristech/android-ifaddrs/archive/{version}.zip'
     depends = [('hostpython2', 'hostpython3')]
 
     call_hostpython_via_targetpython = False
     site_packages_name = 'ifaddrs'
     generated_libraries = ['libifaddrs.so']
 
-    def should_build(self, arch):
-        """It's faster to build than check"""
-        return not (
-            exists(join(self.ctx.libs_dir, arch.arch, 'libifaddrs.so'))
-            and exists(join(self.ctx.get_python_install_dir(), 'lib' "libifaddrs.so")))
-
     def prebuild_arch(self, arch):
         """Make the build and target directories"""
         path = self.get_build_dir(arch.arch)
@@ -39,30 +33,22 @@ def build_arch(self, arch):
             if not exists(path):
                 info("creating {}".format(path))
                 shprint(sh.mkdir, '-p', path)
-        cli = env['CC'].split()
-        cc = sh.Command(cli[0])
+        cli = env['CC'].split()[0]
+        # makes sure first CC command is the compiler rather than ccache, refs:
+        # https://github.com/kivy/python-for-android/issues/1398
+        if 'ccache' in cli:
+            cli = env['CC'].split()[1]
+        cc = sh.Command(cli)
 
         with current_directory(self.get_build_dir(arch.arch)):
             cflags = env['CFLAGS'].split()
             cflags.extend(['-I.', '-c', '-l.', 'ifaddrs.c', '-I.'])
             shprint(cc, *cflags, _env=env)
-
             cflags = env['CFLAGS'].split()
             cflags.extend(['-shared', '-I.', 'ifaddrs.o', '-o', 'libifaddrs.so'])
             cflags.extend(env['LDFLAGS'].split())
             shprint(cc, *cflags, _env=env)
-
             shprint(sh.cp, 'libifaddrs.so', self.ctx.get_libs_dir(arch.arch))
-            shprint(sh.cp, "libifaddrs.so", join(self.ctx.get_python_install_dir(), 'lib'))
-            # drop header in to the Python include directory
-            python_version = self.ctx.python_recipe.version[0:3]
-            shprint(sh.cp, "ifaddrs.h",
-                    join(
-                        self.ctx.get_python_install_dir(),
-                        'include/python{}'.format(python_version))
-           )
-            include_path = join(self.ctx.python_recipe.get_build_dir(arch.arch), 'Include')
-            shprint(sh.cp, "ifaddrs.h", include_path)
 
 
 recipe = IFAddrRecipe()


Test patch: