cibuildwheel icon indicating copy to clipboard operation
cibuildwheel copied to clipboard

[draft] Sketched out an explicit QEMU mode

Open jonded94 opened this issue 2 years ago • 2 comments

This is a very primitive sketch of forcing cibuildwheel to execute a given docker build container in the platform mode that corresponds to the wanted wheel architecture. This should only have an effect when doing non-native platform wheel builds through QEMU.

Possibly interesting since I noticed that all build containers run commands are given no further platform information, even if an image could not be executed natively and has to be run through QEMU. This should work because of the binfmt_misc feature of the linux kernel, but for some reason I saw this crash catastrophically in this issue in a Github Action: https://github.com/pypa/cibuildwheel/issues/1771.

This would also remove these warning messages that docker prints out:

WARNING: The requested image's platform (linux/arm64) does not match the detected host platform (linux/amd64/v3) and no specific platform was requested

Note that this is just a sketch and not intended to be merged. Let me know what you think about this in general.

jonded94 avatar Mar 02 '24 16:03 jonded94

Implemented your suggested changes. Unfortunately I'm getting failed tests in CircleCI when setting --platform everywhere:

"--platform" is only supported on a Docker daemon with experimental features enabled

Also, this is failing: https://dev.azure.com/joerick0429/cibuildwheel/_build/results?buildId=5690&view=logs&j=65f37ddb-1a35-539a-d91f-4ab7f01a34d0&t=677308e5-f586-5eb1-7f4b-3c9712904030&l=1767. Seems like a i686 image is actually built in amd64 mode?

image with reference quay.io/pypa/manylinux1_i686:2024-02-17-6f383ed was found but does not match the specified platform: wanted linux/386, actual: linux/amd64
Error: Command ['docker', 'create', '--platform=linux/386', '--env=CIBUILDWHEEL', '--env=SOURCE_DATE_EPOCH', '--name=cibuildwheel-dae485b4-0570-47a4-a254-296030275f4a', '--interactive', '--volume=/:/host', 'quay.io/pypa/manylinux1_i686:2024-02-17-6f383ed', '/bin/bash'] failed with code 1. None

I wonder if we can be more vague and leave out the variant here and just say e.g. linux/arm64

Since arm64/v8 seems to be the first ARM platform iteration to be 64-bit, I think leaving the version number out is perfectly possible since aarch64 obviously means 64-bit anyways.

jonded94 avatar Mar 03 '24 21:03 jonded94

Also, this is failing: https://dev.azure.com/joerick0429/cibuildwheel/_build/results?buildId=5690&view=logs&j=65f37ddb-1a35-539a-d91f-4ab7f01a34d0&t=677308e5-f586-5eb1-7f4b-3c9712904030&l=1767. Seems like a i686 image is actually built in amd64 mode?

Hmm. this kind of detail makes me less sure that manually specifying the platform is the right approach.

"--platform" is only supported on a Docker daemon with experimental features enabled

It's not experimental since Docker API v1.32, guess Circle are lagging pretty bad there. But given this route is still in the process of rolling out, I think a better option would be for you to use create_args on container-engine for this. I can make a change to container-engine so it's overridable per-platform, which should make it easy to specify the right flags using overrides. It could be a useful feature for other use-cases too.

joerick avatar Mar 15 '24 11:03 joerick

It's now possible since #1792 to use create_args in container-engine for this, so I'll close this out for now. I'd like to add --platform across the board one day, but it would be better to wait until it's out of experimental status with all CI providers first.

joerick avatar Jul 02 '24 17:07 joerick