kivy / kivy/python-for-android

Prepending CC with ccache confuses some build systems

Open
#2,622 1 comment 0 reactions 0 assignees View on GitHub
feature-request
Dominant language
Python
Stars
8.9k
Forks
2k
Avg merge
12h 20m
Merged PRs (30d)
9

Description

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:

- We have ccache installed on the host.
- In python-for-android, if `ccache` is available (and not disabled), it is prepended to `CC`: https://github.com/kivy/python-for-android/blob/develop/pythonforandroid/archs.py#L158-L195. This results in something like `CC="ccache gcc"`.
- In python-zstandard's build system, it assumes the first item in `CC` is the _compiler_, and uses that on its own, adding a new set of parameters: https://github.com/indygreg/python-zstandard/blob/main/make_cffi.py#L31-L66. This is frustrating, [but not an uncommon assumption](https://codesearch.debian.net/search?q=compiler.compiler[0]&literal=1).

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.

Contributor guide

Open the contributing guide

Research direction

Start with pythonforandroid/archs.py at lines 158-195, then review the linked #1398 discussion and the ccache usage guidance. Determine whether the project should change its CC handling or recommend host-side ccache setup; done when the chosen approach is clearly documented or implemented and its build impact is verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, python
Domain
build-system, mobile-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.