From ce44f55377993380c1f23b98ea168765e9716574 Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Sun, 13 Jul 2025 20:32:52 +0800 Subject: [PATCH 1/8] Add 'aarch64-linux' support in build.rs. --- src/dfx/assets/build.rs | 3 +++ src/dfx/assets/dfx-asset-sources.json | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/dfx/assets/build.rs b/src/dfx/assets/build.rs index b320df95ea..b8e7f28bdf 100644 --- a/src/dfx/assets/build.rs +++ b/src/dfx/assets/build.rs @@ -62,6 +62,8 @@ impl Source { struct Sources { #[serde(rename = "x86_64-linux")] x86_64_linux: HashMap, + #[serde(rename = "arm64-linux")] + aarch64_linux: HashMap, #[serde(rename = "x86_64-darwin")] x86_64_darwin: HashMap, #[serde(rename = "arm64-darwin")] @@ -104,6 +106,7 @@ fn find_assets(sources: Sources) -> PathBuf { ("x86_64", "macos") => sources.x86_64_darwin, // rosetta ("aarch64", "macos") => sources.aarch64_darwin, // aarch64 ("x86_64", "linux" | "windows") => sources.x86_64_linux, + ("aarch64", "linux") => sources.aarch64_linux, (arch, os) => panic!("Unsupported OS type {arch}-{os}"), }; source_set.extend(sources.common); diff --git a/src/dfx/assets/dfx-asset-sources.json b/src/dfx/assets/dfx-asset-sources.json index cc7bc711d2..6537b54a07 100644 --- a/src/dfx/assets/dfx-asset-sources.json +++ b/src/dfx/assets/dfx-asset-sources.json @@ -36,6 +36,18 @@ "rev": "e915efecc8af90993ccfc499721ebe826aadba60" } }, + "arm64-linux": { + "motoko": { + "url": "https://github.com/dfinity/motoko/releases/download/0.14.13/motoko-Linux-aarch64-0.14.13.tar.gz", + "sha256": "ae5bfa782bc4edd3dad9291a579e33634b5f4bbbc5f22e318fe5a61caf233c16", + "version": "0.14.13" + }, + "pocket-ic": { + "url": "https://download.dfinity.systems/ic/e915efecc8af90993ccfc499721ebe826aadba60/binaries/arm64-darwin/pocket-ic-server-arm64-darwin", + "sha256": "5bcc6196e7766f3d0f4226558a9a4e92e8e8eb5c63864c25fe76985d016f6572", + "rev": "e915efecc8af90993ccfc499721ebe826aadba60" + } + }, "common": { "motoko-base": { "url": "https://github.com/dfinity/motoko/releases/download/0.14.13/motoko-base-library.tar.gz", From a4424ac1f739d51e3c9b0649b607be033f7d4a6b Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Mon, 14 Jul 2025 12:04:14 +0800 Subject: [PATCH 2/8] Update scripts to cover aarch64 linux. --- scripts/update-motoko.sh | 2 +- scripts/update-replica.sh | 2 +- src/dfx/assets/dfx-asset-sources.json | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/update-motoko.sh b/scripts/update-motoko.sh index cb59c4d3f7..780d6116d0 100755 --- a/scripts/update-motoko.sh +++ b/scripts/update-motoko.sh @@ -29,7 +29,7 @@ motoko_base_sha=$(curl --proto '=https' --tlsv1.2 -sSfL "$motoko_base_url" | sha jq '.common."motoko-base" = {url: $url, sha256: $sha256, version: $version}' --arg version "$version" \ --arg url "$motoko_base_url" --arg sha256 "$motoko_base_sha" "$sources" | sponge "$sources" -declare -A variants=([x86_64-darwin]=Darwin-x86_64 [x86_64-linux]=Linux-x86_64 [arm64-darwin]=Darwin-arm64) +declare -A variants=([x86_64-darwin]=Darwin-x86_64 [x86_64-linux]=Linux-x86_64 [arm64-darwin]=Darwin-arm64 [arm64-linux]=Linux-aarch64) for platform in "${!variants[@]}"; do motoko_url=$(printf 'https://github.com/dfinity/motoko/releases/download/%s/motoko-%s-%s.tar.gz' \ "$(urlencode "$version")" "$(urlencode "${variants[$platform]}")" "$(urlencode "$version")") diff --git a/scripts/update-replica.sh b/scripts/update-replica.sh index 7a6a9c9abc..99fc8c959a 100755 --- a/scripts/update-replica.sh +++ b/scripts/update-replica.sh @@ -22,7 +22,7 @@ rev=$1 echo "Updating sources to rev ${rev}" jq '."replica-rev" = $rev' --arg rev "$rev" "$sources" | sponge "$sources" -declare -A variants=([x86_64-darwin]=pocket-ic.gz [x86_64-linux]=pocket-ic.gz [arm64-darwin]=pocket-ic-server-arm64-darwin) +declare -A variants=([x86_64-darwin]=pocket-ic.gz [x86_64-linux]=pocket-ic.gz [arm64-darwin]=pocket-ic-server-arm64-darwin [arm64-linux]=pocket-ic-server-arm64-linux) for platform in "${!variants[@]}"; do pocketic_url=$(printf 'https://download.dfinity.systems/ic/%s/binaries/%s/%s' "$rev" "$platform" "${variants[$platform]}") pocketic_sha=$(curl --proto '=https' --tlsv1.2 -sSfL "$pocketic_url" | sha256sum | head -c 64) diff --git a/src/dfx/assets/dfx-asset-sources.json b/src/dfx/assets/dfx-asset-sources.json index 6537b54a07..a069549e02 100644 --- a/src/dfx/assets/dfx-asset-sources.json +++ b/src/dfx/assets/dfx-asset-sources.json @@ -39,12 +39,12 @@ "arm64-linux": { "motoko": { "url": "https://github.com/dfinity/motoko/releases/download/0.14.13/motoko-Linux-aarch64-0.14.13.tar.gz", - "sha256": "ae5bfa782bc4edd3dad9291a579e33634b5f4bbbc5f22e318fe5a61caf233c16", + "sha256": "0571dbfa9e857aa19c4181654ddd84de25b9409163587a2c64730795dbb7cd05", "version": "0.14.13" }, "pocket-ic": { - "url": "https://download.dfinity.systems/ic/e915efecc8af90993ccfc499721ebe826aadba60/binaries/arm64-darwin/pocket-ic-server-arm64-darwin", - "sha256": "5bcc6196e7766f3d0f4226558a9a4e92e8e8eb5c63864c25fe76985d016f6572", + "url": "https://download.dfinity.systems/ic/e915efecc8af90993ccfc499721ebe826aadba60/binaries/arm64-linux/pocket-ic-server-arm64-linux", + "sha256": "10a7cf4366bc1704a8eccde96c53e4cbdbc51ddd455427fb04d675b4c7f6fe37", "rev": "e915efecc8af90993ccfc499721ebe826aadba60" } }, From b27938dec9759d857c51d7a0e27e3fdea2ef4536 Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Mon, 14 Jul 2025 21:11:50 +0800 Subject: [PATCH 3/8] Updated publish.yml. --- .github/workflows/publish.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index a0d1a39067..20e3866ea1 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -31,7 +31,7 @@ jobs: matrix: # We build a dynamic-linked linux binary because otherwise HSM support fails with: # Error: IO: Dynamic loading not supported - target: [ x86_64-apple-darwin, aarch64-apple-darwin, x86_64-unknown-linux-gnu ] + target: [ x86_64-apple-darwin, aarch64-apple-darwin, x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu ] include: - os: macos-13-large target: x86_64-apple-darwin @@ -48,6 +48,11 @@ jobs: binary_path: target/x86_64-unknown-linux-gnu/release name: x86_64-linux tar: tar + - os: ubuntu-22.04-arm + target: aarch64-unknown-linux-gnu + binary_path: target/aarch64-unknown-linux-gnu/release + name: aarch64-linux + tar: tar steps: - uses: actions/checkout@v4 @@ -151,7 +156,7 @@ jobs: strategy: fail-fast: false matrix: - name: [ 'x86_64-darwin', 'aarch64-darwin', 'x86_64-linux' ] + name: [ 'x86_64-darwin', 'aarch64-darwin', 'x86_64-linux', 'aarch64-linux' ] steps: - uses: actions/checkout@v4 From 306a0adcd2c1503aa6d4d91aa77f0cb0f96eee59 Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Mon, 14 Jul 2025 21:45:16 +0800 Subject: [PATCH 4/8] Updated publish.yml to check dlls according to the target. --- .github/workflows/publish.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 20e3866ea1..a4a6d56a83 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -98,8 +98,18 @@ jobs: - name: Check dynamically-linked libraries (ubuntu) run: | ACTUAL="$(ldd ${{ matrix.binary_path }}/dfx | awk '{ print $1 }' | sort | awk -v d=" " '{s=(NR==1?s:s d)$0}END{printf "%s",s}')" - EXPECTED="/lib64/ld-linux-x86-64.so.2 libc.so.6 libgcc_s.so.1 libm.so.6 libstdc++.so.6 linux-vdso.so.1" + + if [[ "${{ matrix.target }}" == "x86_64-unknown-linux-gnu" ]]; then + EXPECTED="/lib64/ld-linux-x86-64.so.2 libc.so.6 libgcc_s.so.1 libm.so.6 libstdc++.so.6 linux-vdso.so.1" + elif [[ "${{ matrix.target }}" == "aarch64-unknown-linux-gnu" ]]; then + EXPECTED="/lib/ld-linux-aarch64.so.1 libc.so.6 libgcc_s.so.1 libm.so.6 libstdc++.so.6 linux-vdso.so.1" + else + echo "Unsupported target: ${{ matrix.target }}" + exit 1 + fi + echo "Dynamically-linked libraries:" + echo " Target: ${{ matrix.target }}" echo " Actual: $ACTUAL" echo " Expected: $EXPECTED" if [ "$ACTUAL" != "$EXPECTED" ]; then From c0c396906ee7419c66c23dc52bbb1af68cc80417 Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Mon, 14 Jul 2025 23:03:51 +0800 Subject: [PATCH 5/8] Updated workflows to run checks on ubuntu-arm64. --- .github/workflows/e2e.yml | 10 ++++++++-- .github/workflows/lint.yml | 2 +- .github/workflows/prepare-dfx-assets.yml | 2 +- .github/workflows/unit.yml | 2 +- scripts/workflows/e2e-matrix.py | 13 +++++++++---- 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 48cb6a3076..754d4838c4 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -66,9 +66,15 @@ jobs: - os: ubuntu-22.04 target: x86_64-unknown-linux-gnu binary_path: target/x86_64-unknown-linux-gnu/release/dfx + - os: ubuntu-22.04-arm + target: aarch64-unknown-linux-gnu + binary_path: target/aarch64-unknown-linux-gnu/release/dfx - os: ubuntu-24.04 target: x86_64-unknown-linux-gnu binary_path: target/x86_64-unknown-linux-gnu/release/dfx + - os: ubuntu-24.04-arm + target: aarch64-unknown-linux-gnu + binary_path: target/aarch64-unknown-linux-gnu/release/dfx - os: windows-2022 target: x86_64-pc-windows-msvc binary_path: target\x86_64-pc-windows-msvc\release\dfx.exe @@ -114,7 +120,7 @@ jobs: strategy: fail-fast: false matrix: - os: [macos-13, macos-13-xlarge, ubuntu-22.04, ubuntu-24.04] + os: [macos-13, macos-13-xlarge, ubuntu-22.04, ubuntu-22.04-arm, ubuntu-24.04, ubuntu-24.04-arm] steps: - uses: actions/checkout@v4 - name: Download dfx binary @@ -184,7 +190,7 @@ jobs: strategy: fail-fast: false matrix: - os: [macos-13, macos-13-xlarge, ubuntu-22.04, ubuntu-24.04] + os: [macos-13, macos-13-xlarge, ubuntu-22.04, ubuntu-22.04-arm, ubuntu-24.04, ubuntu-24.04-arm] steps: - name: Checking out repo uses: actions/checkout@v4 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 324ae38863..cbe9db149b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -43,7 +43,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ ubuntu-latest, macos-13-large, macos-13-xlarge, windows-latest ] + os: [ ubuntu-latest, ubuntu-24.04-arm, macos-13-large, macos-13-xlarge, windows-latest ] steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/prepare-dfx-assets.yml b/.github/workflows/prepare-dfx-assets.yml index 4fe951b813..e37dda659e 100644 --- a/.github/workflows/prepare-dfx-assets.yml +++ b/.github/workflows/prepare-dfx-assets.yml @@ -26,7 +26,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ ubuntu-latest, macos-13-large, macos-13-xlarge ] + os: [ ubuntu-latest, ubuntu-24.04-arm, macos-13-large, macos-13-xlarge ] steps: - uses: actions/checkout@v4 - uses: actions/cache@v4 diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml index 843b3b88dd..544c9ff395 100644 --- a/.github/workflows/unit.yml +++ b/.github/workflows/unit.yml @@ -45,7 +45,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ ubuntu-latest, macos-13-large, macos-13-xlarge ] + os: [ ubuntu-latest, ubuntu-24.04-arm, macos-13-large, macos-13-xlarge ] steps: - uses: actions/checkout@v4 - uses: actions/cache@v4 diff --git a/scripts/workflows/e2e-matrix.py b/scripts/workflows/e2e-matrix.py index 92a20eab99..84b1b92e3d 100755 --- a/scripts/workflows/e2e-matrix.py +++ b/scripts/workflows/e2e-matrix.py @@ -3,8 +3,8 @@ import json import os -# Only run these tests on macOS -MACOS_TESTS = ["dfx/bitcoin", "dfx/canister_http_adapter", "dfx/start"] +# Only run these tests on macOS and Ubuntu-arm64 +SELECTED_TESTS = ["dfx/bitcoin", "dfx/canister_http_adapter", "dfx/start"] # Run these tests in serial SERIAL_TESTS = ["dfx/start", "dfx/bitcoin", "dfx/cycles-ledger", "dfx/ledger", "dfx/serial_misc"] @@ -31,8 +31,8 @@ def test_scripts(prefix): "serial": serial, }) - # macOS: only run selected tests - if test in MACOS_TESTS: + # macOS and Ubuntu-arm64: only run selected tests + if test in SELECTED_TESTS: include.append({ "test": test, "os": "macos-13", @@ -43,6 +43,11 @@ def test_scripts(prefix): "os": "macos-13-xlarge", "serial": serial, }) + include.append({ + "test": test, + "os": "ubuntu-22.04-arm", + "serial": serial, + }) matrix = { "include": include, From 7f7210f946cbc98fcc98548c0c962d3f619bc0f0 Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Mon, 14 Jul 2025 23:12:19 +0800 Subject: [PATCH 6/8] Add missing os... --- .github/workflows/e2e.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 754d4838c4..b62fd33ce6 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -55,7 +55,7 @@ jobs: matrix: # We build a dynamic-linked linux binary because otherwise HSM support fails with: # Error: IO: Dynamic loading not supported - os: [macos-13, macos-13-xlarge, ubuntu-22.04, ubuntu-24.04, windows-2022] + os: [macos-13, macos-13-xlarge, ubuntu-22.04, ubuntu-22.04-arm, ubuntu-24.04, ubuntu-24.04-arm, windows-2022] include: - os: macos-13 target: x86_64-apple-darwin From f5ebd5217a28dde6bba634e9710fe94ece6c94f7 Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Tue, 15 Jul 2025 11:10:18 +0800 Subject: [PATCH 7/8] Choose the right bitcoin version according to the architecture. --- scripts/workflows/provision-linux.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/scripts/workflows/provision-linux.sh b/scripts/workflows/provision-linux.sh index 4b1e5b6cc6..286c27d720 100755 --- a/scripts/workflows/provision-linux.sh +++ b/scripts/workflows/provision-linux.sh @@ -13,8 +13,20 @@ sudo apt-get install --yes bats parallel moreutils # Modifications needed for some tests if [ "$E2E_TEST" = "tests-dfx/bitcoin.bash" ]; then BITCOIN_CORE_VERSION=22.0 - BITCOIN_CORE_FILENAME="bitcoin-$BITCOIN_CORE_VERSION-x86_64-linux-gnu.tar.gz" - BITCOIN_CORE_TARBALL_SHA="59ebd25dd82a51638b7a6bb914586201e67db67b919b2a1ff08925a7936d1b16" + + # Check architecture and set filename and sha + ARCH=$(uname -m) + if [ "$ARCH" = "x86_64" ]; then + BITCOIN_CORE_FILENAME="bitcoin-$BITCOIN_CORE_VERSION-x86_64-linux-gnu.tar.gz" + BITCOIN_CORE_TARBALL_SHA="59ebd25dd82a51638b7a6bb914586201e67db67b919b2a1ff08925a7936d1b16" + elif [ "$ARCH" = "aarch64" ]; then + BITCOIN_CORE_FILENAME="bitcoin-$BITCOIN_CORE_VERSION-aarch64-linux-gnu.tar.gz" + BITCOIN_CORE_TARBALL_SHA="ac718fed08570a81b3587587872ad85a25173afa5f9fbbd0c03ba4d1714cfa3e" + else + echo "Unsupported architecture: $ARCH" + exit 1 + fi + ( cd "$(mktemp -d)" wget "https://bitcoin.org/bin/bitcoin-core-$BITCOIN_CORE_VERSION/$BITCOIN_CORE_FILENAME" From 8bf5d1e88b4771678cc831adff34c3c8215248e6 Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Tue, 15 Jul 2025 14:07:26 +0800 Subject: [PATCH 8/8] Update changelog. --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 39541c7631..6d91817654 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ # UNRELEASED +### feat: add dfx native support for aarch64-Linux + +Add dfx native support for aarch64-Linux. + ### feat: support canister snapshot download and upload. Added `dfx canister snapshot download` and `dfx canister snapshot upload` commands to download and upload the canister snapshot.