kivy / python-for-android

Turn your Python application into an Android APK
https://python-for-android.readthedocs.io
MIT License
8.33k stars 1.84k forks source link

Prepending CC with ccache confuses some build systems #2622

Open dylanmccall opened 2 years ago

dylanmccall commented 2 years ago

I recently created a recipe to build python-zstandard, a Python module with a native component. I encountered an issue where the build script was attempting to run ccache on its own with some compiler flags, similar to #1398. This happened because:

Since I have the luxury of a project that only needs to build one way, this is how I worked around it on my end:

https://github.com/endlessm/kolibri-installer-android/commit/7e4eab72da2e888d59fc058f9c36ad636a64e3b8

So, instead of patching the module or changing the environment variable, I told P4A to stop thinking about ccache, and enabled it on the host by setting PATH="/usr/lib/ccache:$PATH". This works because /usr/lib/ccache is a directory full of look-alikes for different compilers, all of which point to ccache. It is one of two recommended ways to use ccache: https://manpages.ubuntu.com/manpages/jammy/man1/ccache.1.html.

My suggestion here is that the current approach is problematic, and perhaps dealing with ccache on the host instead of in P4A would be a good practice to recommend in general.

mzakharo commented 2 years ago

If a build system uses just the first term of CC , then it is going to be missing some other (important) flags set by p4a build system as well. Maybe the preferred solution here is to patch the source code of the module to allow it to use the entire CC. It is not uncommon, but many build scripts just don't care about/support proper cross-compilation.