diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 48cb6a3076..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 @@ -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/publish.yml b/.github/workflows/publish.yml index a0d1a39067..a4a6d56a83 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 @@ -93,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 @@ -151,7 +166,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 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/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. 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/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, 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" 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..a069549e02 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": "0571dbfa9e857aa19c4181654ddd84de25b9409163587a2c64730795dbb7cd05", + "version": "0.14.13" + }, + "pocket-ic": { + "url": "https://download.dfinity.systems/ic/e915efecc8af90993ccfc499721ebe826aadba60/binaries/arm64-linux/pocket-ic-server-arm64-linux", + "sha256": "10a7cf4366bc1704a8eccde96c53e4cbdbc51ddd455427fb04d675b4c7f6fe37", + "rev": "e915efecc8af90993ccfc499721ebe826aadba60" + } + }, "common": { "motoko-base": { "url": "https://github.com/dfinity/motoko/releases/download/0.14.13/motoko-base-library.tar.gz",