Skip to content

Commit ac1a323

Browse files
committed
Merge #615: Build for arm64 on amd64
3d3c02d Improve (Kiminuo) ee3cf5f Add release instructions (Kiminuo) d93c8f7 Add support for arm64 (Kiminuo) Pull request description: 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: ```s sudo apt install qemu-user-static ``` ### Build for arm64 Use [docker buildx](https://docs.docker.com/buildx/working-with-buildx/) to replicate [deterministic build instructions](https://github.com/bitcoin-core/HWI/blob/master/docs/development/release-process.rst#deterministic-builds-with-docker) for the arm64 build: ```s 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: ```diff -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 * https://docs.docker.com/build/building/multi-platform/#building-multi-platform-images * https://medium.com/@artur.klauser/building-multi-architecture-docker-images-with-buildx-27d80f7e2408 ## 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`](https://github.com/kiminuo/HWI/blob/a025af3ee3fdf0bac8dbdbc51b9e82ab946660b4/contrib/build_bin.sh#L12) That's why I use `build_bin.sh --without-gui` (see #655) ACKs for top commit: achow101: ACK 3d3c02d Tree-SHA512: 3df877ec3da07997c8281722ea0ec4687d850f1fec33cb5664e3f03cd8854cb02a90ce799da2123a88058b681fbb2bad31bdacbb485474d19fa88b60a4b73d83
2 parents 5a1beaf + 3d3c02d commit ac1a323

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

contrib/build_bin.sh

+6-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
set -ex
66

7+
ARCH=$(uname -m | tr '[:upper:]' '[:lower:]')
8+
79
eval "$(pyenv init --path)"
810
eval "$(pyenv virtualenv-init -)"
911
pip install -U pip
@@ -12,7 +14,7 @@ pip install poetry
1214
gui_support="${1:---with-gui}";
1315

1416
# Setup poetry and install the dependencies
15-
if [[ $gui_support == "--with-gui" ]]; then
17+
if [[ $gui_support == "--with-gui" && $ARCH == "x86_64" ]]; then
1618
poetry install -E qt
1719
else
1820
poetry install
@@ -26,7 +28,7 @@ TZ=UTC find ${lib_dir} -name '*.py' -type f -execdir touch -t "201901010000.00"
2628
export PYTHONHASHSEED=42
2729
poetry run pyinstaller hwi.spec
2830

29-
if [[ $gui_support == "--with-gui" ]]; then
31+
if [[ $gui_support == "--with-gui" && $ARCH == "x86_64" ]]; then
3032
poetry run contrib/generate-ui.sh
3133
poetry run pyinstaller hwi-qt.spec
3234
fi
@@ -40,7 +42,7 @@ OS=`uname | tr '[:upper:]' '[:lower:]'`
4042
if [[ $OS == "darwin" ]]; then
4143
OS="mac"
4244
fi
43-
ARCH=$(uname -m | tr '[:upper:]' '[:lower:]')
45+
4446
target_tarfile="hwi-${VERSION}-${OS}-${ARCH}.tar.gz"
4547

4648
if [[ $gui_support == "--with-gui" ]]; then
@@ -54,7 +56,7 @@ target_dir="$target_tarfile.dir"
5456
mkdir $target_dir
5557
mv hwi $target_dir
5658

57-
if [[ $gui_support == "--with-gui" ]]; then
59+
if [[ $gui_support == "--with-gui" && $arch == "x86_64" ]]; then
5860
mv hwi-qt $target_dir
5961
fi
6062

docs/development/release-process.rst

+7
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,17 @@ Create the docker images::
1818
docker build --no-cache -t hwi-builder -f contrib/build.Dockerfile .
1919
docker build --no-cache -t hwi-wine-builder -f contrib/build-wine.Dockerfile .
2020

21+
# arm64
22+
sudo apt-get install qemu-user-static
23+
docker buildx build --no-cache --platform linux/arm64 -t hwi-builder-arm64 -f contrib/build.Dockerfile .
24+
2125
Build everything::
2226

2327
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"
2428
docker run -it --name hwi-wine-builder -v $PWD:/opt/hwi --rm --workdir /opt/hwi hwi-wine-builder /bin/bash -c "contrib/build_wine.sh"
29+
docker run --platform linux/arm64 -it --rm --name hwi-builder-arm64 -v $PWD:/opt/hwi --workdir /opt/hwi hwi-builder-arm64 /bin/bash -c "contrib/build_bin.sh --without-gui && contrib/build_dist.sh --without-gui"
30+
31+
i.e.
2532

2633
Building macOS binary
2734
=====================

hwi.spec

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def get_libusb_path():
1313
prefix = proc.communicate()[0].rstrip().decode()
1414
return os.path.join(prefix, "lib", "libusb-1.0.dylib")
1515
if platform.system() == "Linux":
16-
for lib_dir in ["/lib/x86_64-linux-gnu", "/usr/lib64", "/lib64" "/usr/lib", "/lib"]:
16+
for lib_dir in ["/lib/x86_64-linux-gnu", "/lib/aarch64-linux-gnu", "/usr/lib64", "/lib64" "/usr/lib", "/lib"]:
1717
libusb_path = os.path.join(lib_dir, "libusb-1.0.so.0")
1818
if os.path.exists(libusb_path):
1919
return libusb_path

0 commit comments

Comments
 (0)