New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crosscompile python aarch64 wheels with dockcross #25418
Crosscompile python aarch64 wheels with dockcross #25418
Conversation
73d4c2e
to
8d4038c
Compare
@lidizheng @gnossen this is not ready for merge yet, but good enough for first review pass. |
@janaknat please review as well. |
"${PYTHON}" -m pip install virtualenv | ||
"${PYTHON}" -m virtualenv venv || { "${PYTHON}" -m pip install virtualenv==16.7.9 && "${PYTHON}" -m virtualenv venv; } | ||
venv/bin/python -m pip install "twine<=2.0" | ||
venv/bin/python -m twine check dist/* tools/distrib/python/grpcio_tools/dist/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason for skipping twine checks? We are following manylinux2014, should be supported by PyPI official packages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to skip auditwheel and twine check for now, since when crosscompiling we're running on x64 image, but we got aarch64 wheel. To perform checks, you'd likely need to run the check under qemu (available in the docker image), but also on aarch64 version of python etc.
The plan is to first test the aarch64 wheels manually. It should be possible to add back twine and auditwheel checks, but more work is needed.
Artifact build results (for aarch64)
built wheels can be downloaded here: |
Manual run of auditwheel show on arm64 machine:
So looks like some work is still needed. Not sure if the problem could be the too-new version of gcc being used (we do use 4.9.4 instead of the default 4.8 because gRPC doesn't compile under gcc 4.8 - see the dockerfile) |
An attempt to auditwheel repair:
|
The python3.7 failure seems to be caused by a typo that's now fixed. |
FROM dockcross/manylinux2014-aarch64:20200929-608e6ac | ||
|
||
# Update the package manager | ||
RUN yum update -y && yum install -y curl-devel expat-devel gettext-devel openssl-devel zlib-devel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these installing the aarch64 dev libs? When I tried it, it pulled in the x86 version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope, this is installing x86 libs. I guess the reason why this doesn't matter is that they are actually not strictly required for a successful build (I copied the line from x64 dockerfile and didn't investigate whether they are really needed).
RUN /opt/python/cp36-cp36m/bin/pip install --upgrade cython | ||
RUN /opt/python/cp37-cp37m/bin/pip install --upgrade cython | ||
RUN /opt/python/cp38-cp38/bin/pip install --upgrade cython | ||
RUN /opt/python/cp39-cp39/bin/pip install --upgrade cython |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question as above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a x64 cython, but that doesn't really matter it seems. Even the python itself is a x64 python. That seems correct as we're crosscompiling and we need to run the build on a x64 machine (and cython is what invokes the build commands).
@@ -57,6 +58,7 @@ ${SETARCH_CMD} "${PYTHON}" setup.py sdist | |||
|
|||
# Wheel has a bug where directories don't get excluded. | |||
# https://bitbucket.org/pypa/wheel/issues/99/cannot-exclude-directory | |||
# shellcheck disable=SC2086 | |||
${SETARCH_CMD} "${PYTHON}" setup.py bdist_wheel $WHEEL_PLAT_NAME_FLAG |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double quote (SC2086) seems applicable to this shell command. Quoting variables should fix the shellcheck complain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That wouldn't work. WHEEL_PLAT_NAME_FLAG can be empty and in that case "$WHEEL_PLAT_NAME_FLAG"
becomes ""
and an empty arg will be forcibly passed to the command (which does break it).
|
||
# Set to empty string to disable the option (see https://github.com/grpc/grpc/issues/24498) | ||
# TODO: enable ASM optimizations for crosscompiled wheels | ||
export GRPC_BUILD_WITH_BORING_SSL_ASM="" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe link to the PR changing the BoringSSL ASM enable flag? #25444
Looks like the only problematic symbol is |
8a2ba29
to
5849d85
Compare
So far I haven't figured out how to make sure that the GCC 4.9 crosscompiler in the dockcross image uses symbols that are compliant with manylinux2014 (as discussed in #25418 (comment)), but I used a workaround instead:
@lidizheng @gnossen I think this PR is now ready to merge. PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice investigation!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for digging this!
known failures: |
Enables building of aarch64 wheels via crosscompilation.
Uses similar tricks (overriding plat-name and EXT_SUFFIX) as protocolbuffers/protobuf#8280.
Some limitations:
The nice thing is that crosscompilation isn't slower than the regular build (unlike building under emulation).
FTR a very similar technique could be used to crosscompile the armv7 and armv6 (currently under "linux_extra" and being built under an emulator which takes ages).