Skip to content

Add support for building aarch64 wheel #108

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

Merged
merged 7 commits into from
Jul 16, 2020

Conversation

jcfr
Copy link
Contributor

@jcfr jcfr commented Jun 17, 2020

No description provided.

@jcfr jcfr force-pushed the add-support-for-building-aarch64-wheel branch from 4508e1d to 6655a4a Compare June 17, 2020 05:01
scikit-ci.yml Outdated
@@ -26,6 +26,9 @@ before_install:
# SETUP_CMAKE_ARGS
if arch in ["x86", "x64"]:
os.environ["SETUP_CMAKE_ARGS"] = "-DOPENSSL_ROOT_DIR:PATH=/usr/local/ssl " + os.environ["SETUP_CMAKE_ARGS"]
# SETUP_BDIST_WHEEL_ARGS
if arch == "aarch64":
os.environ["SETUP_BDIST_WHEEL_ARGS"] = "--plat-name %s" % image_name
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once dockcross/dockcross#420 is integrated, this should be changed to:

os.environ["SETUP_BDIST_WHEEL_ARGS"] = "--plat-name %s" % os.environ["AUDITWHEEL_PLAT"]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcfr, dockcross/dockcross#420 PR is merged now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks for the follow up.

The next issue to address is having openssl libraries and header compiled for aarch64, this will address this error:

/work/src/Utilities/cmcurl/lib/md5.c:88:25: fatal error: openssl/md5.h: No such file or directory
 #include <openssl/md5.h>
                         ^                   

Since the dockcross image host is x86_64 and the toolchain aarch64, I do not think we can install aarch64 dependencies using the host the yum package manager, we have to compile them

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also wonder if we can download relevant openssl packages from http://mirror.centos.org/centos/8/BaseOS/aarch64/os/Packages/ and manually extract them ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For normal cross-compilation of openssl, I am using below code:

export CROSS_COMPILE=aarch64-linux-gnu- && \
export PATH=$PATH:/tmp/toolchain/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/bin && \
cd /tmp/ && \
git clone https://github.com/openssl/openssl && \
cd openssl && \
./Configure linux-aarch64 --cross-compile-prefix=${CROSS_COMPILE} --prefix=/tmp/openssl/build shared && \
make depend && \
make -j5 && \
make install && \
cp -r /tmp/openssl/build/include/* /tmp/toolchain/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/aarch64-linux-gnu/libc/usr/include/ && \
cp -r /tmp/openssl/build/lib/* /tmp/toolchain/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/8.3.0/

In dockcross, I think we need to update CROSS_COMPILE=aarch64-unknown-linux-gnueabi- and copy libraries to /usr/xcc/aarch64-unknown-linux-gnueabi/aarch64-unknown-linux-gnueabi/lib folder.

Maybe we can copy from http://mirror.centos.org/centos/8/BaseOS/aarch64/os/Packages , but need to check on what all packages are required.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the follow up 🙏

In dockcross, I think we need to update CROSS_COMPILE=aarch64-unknown-linux-gnueabi-

Could you check that OpenSSL can be compiled in dockcross ? Once we have the receipt, it will be easy to finalize this PR.

Copy link
Contributor

@odidev odidev Jul 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcfr ,
I am able to successfully build openssl in dockcross/manylinux2014-aarch64 docker container by following below steps:

yum install perl-IPC-Cmd.noarch perl-IPC-Run.noarch perl-IPC-Run3.noarch
git clone https://github.com/openssl/openssl && \
cd openssl
./Configure linux-aarch64 --cross-compile-prefix= --prefix=/tmp/openssl/build shared
make depend
make -j5
make install
cp -r /tmp/openssl/build/lib/* /usr/xcc/aarch64-unknown-linux-gnueabi/aarch64-unknown-linux-gnueabi/lib64/
cp -r /tmp/openssl/build/include/* /usr/xcc/aarch64-unknown-linux-gnueabi/aarch64-unknown-linux-gnueabi/include/

Please let me know if any more info is required.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update, looking at it now

@jcfr
Copy link
Contributor Author

jcfr commented Jul 15, 2020

Remaining error:

Traceback (most recent call last):
  File "/opt/python/cp37-cp37m/bin/auditwheel", line 8, in <module>
    sys.exit(main())
  File "/opt/_internal/cpython-3.7.7/lib/python3.7/site-packages/auditwheel/main.py", line 35, in main
    main_repair.configure_parser(sub_parsers)
  File "/opt/_internal/cpython-3.7.7/lib/python3.7/site-packages/auditwheel/main_repair.py", line 25, in configure_parser
    default=highest_policy)
  File "/opt/_internal/cpython-3.7.7/lib/python3.7/argparse.py", line 1359, in add_argument
    action = action_class(**kwargs)
  File "/opt/_internal/cpython-3.7.7/lib/python3.7/site-packages/auditwheel/tools.py", line 126, in __init__
    raise argparse.ArgumentError(self, msg % args)
argparse.ArgumentError: argument --plat: invalid choice: 'manylinux2014_aarch64' from environment variable 'AUDITWHEEL_PLAT' (choose from 'linux_x86_64', 'manylinux1_x86_64', 'manylinux2010_x86_64', 'manylinux2014_x86_64')

Issue has been discussed in pypa/auditwheel#244 (comment)

Summary is:

You can only repair wheels on a host with matching architecture.

For the sake of building the cmake wheel, I will implement a workaround.

That said, we should look into addressing this and ensure architecture and processor associated with platform module are the expected one.

@jcfr jcfr force-pushed the add-support-for-building-aarch64-wheel branch from 3996f94 to f8b2d6e Compare July 15, 2020 23:41
jcfr and others added 6 commits July 15, 2020 20:18
This commit explicit sets the path to the strip executable to ensure
the cmake aarch64 executable can be stripped.

See #96

Co-authored-by: odidev <[email protected]>
This commit allows the build to progress using images missing:
- fix for sudo (see dockcross/dockcross#421)
- auditwheel environment variables (see dockcross/dockcross#420)
Since the wheel is properly named by default and CMake doesn't have
any external dependencies beside of openssl, this commit skips the
repair.
@jcfr jcfr force-pushed the add-support-for-building-aarch64-wheel branch from 1ecd483 to 59e9f9d Compare July 16, 2020 00:33
@jcfr jcfr merged commit cae80bc into master Jul 16, 2020
@jcfr jcfr deleted the add-support-for-building-aarch64-wheel branch July 16, 2020 01:28
@jcfr
Copy link
Contributor Author

jcfr commented Jul 16, 2020

@odidev Et voila, wheel for aarch64 is now available on pypi:

image

@odidev
Copy link
Contributor

odidev commented Jul 16, 2020

@jcfr ,

Thanks for uploading cmake aarch64 wheel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants