This fixes importing the _ctypes module, if a shared libffi doesn't
happen to exist on the host system with the right so version.
Since Python 3.12, such a build error ends up failing the build,
while it previously passed silently even if some parts of the build
had failed.
These modules were already manually stripped out from the install,
but we can also skip building them entirely - this gets rid of
30% of the number of lines of log output when building python
(reducing the number of lines from 21539 to 14653 lines, for the
whole of building python for both native and a cross target).
This version fixes a race condition in the build, which in most
cases was benign but in rare cases could successfully build a Python
that would crash at runtime.
While $HOST-clang is more specific for the use in llvm-mingw,
using the form $HOST-gcc would allow using the same script in
GCC based environments too.
This command isn't a standard tool; different distributions have
different implementations, and e.g. Fedora doesn't ship it by
default.
Settle on using "command -v $tool >/dev/null" for tests about whether
a tool is available. (We could also use "hash $tool 2>/dev/null" as we
already had in build-all.sh, but settling on using "command -v"
everywhere, for consistency and simplicity.)
Even if we don't patch cpython-mingw any longer, we still run
autoreconf on it (and libffi), which can cause changes to
committed files. If trying to check out a different version of
the source, this would fail unless the local changes have been
discarded.