Skip to content
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

Build for arm64 on amd64 #615

Merged
merged 3 commits into from
Jan 30, 2024

Conversation

kiminuo
Copy link
Contributor

@kiminuo kiminuo commented Jun 16, 2022

Related to #345
Related to WalletWasabi/WalletWasabi#4051 (comment)
Discussion: Some discussion here: kiminuo#1

This PR just shows how to do a deterministic build for arm64 architecture. The hope is HWI's support for arm64 will improve a bit.

Setup

To set up your environment, install:

sudo apt install qemu-user-static 

Build for arm64

Use docker buildx to replicate deterministic build instructions for the arm64 build:

docker buildx build --no-cache --platform linux/arm64 -t hwi-builder -f contrib/build.Dockerfile .

# Note the use of "--without-gui".
docker run --platform linux/arm64 -it --rm --name hwi-builder -v $PWD:/opt/hwi  --workdir /opt/hwi hwi-builder /bin/bash -c "contrib/build_bin.sh --without-gui && contrib/build_dist.sh --without-gui"

i.e. the change is:

-docker build --no-cache -t hwi-builder -f contrib/build.Dockerfile .
-docker run -it --name hwi-builder -v $PWD:/opt/hwi --rm  --workdir /opt/hwi hwi-builder /bin/bash -c "contrib/build_bin.sh && contrib/build_dist.sh && contrib/build_wine.sh"
+docker buildx build --no-cache --platform linux/arm64 -t hwi-builder -f contrib/build.Dockerfile .
+docker run --platform linux/arm64 -it --rm --name hwi-builder -v $PWD:/opt/hwi  --workdir /opt/hwi hwi-builder /bin/bash -c "contrib/build_bin.sh --without-gui && contrib/build_dist.sh --without-gui"

Resources

Limitations

No GUI support

So far I had no luck with building hwi-qt because I get the following error

Installing dependencies from lock file

Package operations: 14 installs, 0 updates, 0 removals

  • Installing shiboken2 (5.15.2): Failed

  RuntimeError

  Unable to find installation candidates for shiboken2 (5.15.2)

  at ~/.pyenv/versions/3.9.7/lib/python3.9/site-packages/poetry/installation/chooser.py:72 in choose_for
       68│ 
       69│             links.append(link)
       70│ 
       71│         if not links:
    →  72│             raise RuntimeError(
       73│                 "Unable to find installation candidates for {}".format(package)
       74│             )
       75│ 
       76│         # Get the best link

during execution of poetry install -E qt

That's why I use build_bin.sh --without-gui (see #655)

@kiminuo kiminuo force-pushed the feature/2022-06-16-HWI-arm64 branch from 6854f65 to 4f44d39 Compare June 16, 2022 09:49
@kiminuo kiminuo force-pushed the feature/2022-06-16-HWI-arm64 branch 3 times, most recently from bfd92b2 to fc5bc9d Compare January 7, 2023 21:31
@kiminuo kiminuo force-pushed the feature/2022-06-16-HWI-arm64 branch from fc5bc9d to 44c15fd Compare February 27, 2023 21:20
@kiminuo kiminuo marked this pull request as ready for review February 27, 2023 21:30
@kiminuo
Copy link
Contributor Author

kiminuo commented Feb 27, 2023

@achow101 Would you have a moment to review this PR please?

@achow101
Copy link
Member

I've started doing arm64 builds on a raspi 4 that I have. Is this still relevant?

@kiminuo
Copy link
Contributor Author

kiminuo commented Jan 17, 2024

I've started doing arm64 builds on a raspi 4 that I have. Is this still relevant?

I believe so. But I can see there are some conflicts now.

# Conflicts:
#	contrib/build.Dockerfile
#	contrib/build_bin.sh
@kiminuo kiminuo force-pushed the feature/2022-06-16-HWI-arm64 branch from 44c15fd to d93c8f7 Compare January 18, 2024 19:24
@@ -12,7 +14,7 @@ pip install poetry
gui_support="${1:---with-gui}";

# Setup poetry and install the dependencies
if [[ $gui_support == "--with-gui" ]]; then
if [[ $gui_support == "--with-gui" && $ARCH == "x86_64" ]]; then
Copy link
Contributor Author

Choose a reason for hiding this comment

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

PySide2 was not ready for arm64, I had issues with shiboken2 package (see). With #691, it might be fixed.

@@ -40,7 +42,7 @@ OS=`uname | tr '[:upper:]' '[:lower:]'`
if [[ $OS == "darwin" ]]; then
OS="mac"
fi
ARCH=$(uname -m | tr '[:upper:]' '[:lower:]')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just moved up in this file.

@@ -26,7 +28,7 @@ TZ=UTC find ${lib_dir} -name '*.py' -type f -execdir touch -t "201901010000.00"
export PYTHONHASHSEED=42
poetry run pyinstaller hwi.spec

if [[ $gui_support == "--with-gui" ]]; then
if [[ $gui_support == "--with-gui" && $ARCH == "x86_64" ]]; then
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do not run for arm64.

@kiminuo
Copy link
Contributor Author

kiminuo commented Jan 18, 2024

@achow101 It seems I succeeded in building an arm64 build using the instructions above - i.e.

docker buildx build --no-cache --platform linux/arm64 -t hwi-builder -f contrib/build.Dockerfile .

# Note the use of "--without-gui".
docker run --platform linux/arm64 -it --rm --name hwi-builder -v $PWD:/opt/hwi  --workdir /opt/hwi hwi-builder /bin/bash -c "contrib/build_bin.sh --without-gui && contrib/build_dist.sh --without-gui"

WDYT?

@achow101
Copy link
Member

Can you update docs/development/release-process.rst with the instructions?

@@ -17,11 +17,15 @@ Create the docker images::

docker build --no-cache -t hwi-builder -f contrib/build.Dockerfile .
docker build --no-cache -t hwi-wine-builder -f contrib/build-wine.Dockerfile .
docker buildx build --no-cache --platform linux/arm64 -t hwi-builder-arm64 -f contrib/build.Dockerfile .
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems like one can simplify it nowadays to:

Suggested change
docker buildx build --no-cache --platform linux/arm64 -t hwi-builder-arm64 -f contrib/build.Dockerfile .
docker build --no-cache --platform linux/arm64 -t hwi-builder-arm64 -f contrib/build.Dockerfile .

based on https://docs.docker.com/build/guide/multi-platform/. It should be available from API 1.38 (the latest is 1.43):

image

@kiminuo
Copy link
Contributor Author

kiminuo commented Jan 19, 2024

Can you update docs/development/release-process.rst with the instructions?

Updated. I added what I find to be safest but I can only test on Ubuntu 23.04. Maybe your system differs. So it would be great if you could try the instructions and pick what works for you.

@achow101
Copy link
Member

ACK 3d3c02d

@achow101 achow101 merged commit ac1a323 into bitcoin-core:master Jan 30, 2024
180 of 255 checks passed
@kiminuo kiminuo deleted the feature/2022-06-16-HWI-arm64 branch January 30, 2024 18:40
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