From 71331a3e6ce1ae0da294b38d07b1f96d26929115 Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Tue, 15 Jul 2025 20:30:08 +0800 Subject: [PATCH 1/7] Support aarch64-linux. --- src/dfxvm/install.rs | 5 ++++- src/dfxvm/self_update.rs | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/dfxvm/install.rs b/src/dfxvm/install.rs index bdaf924..f4e2b76 100644 --- a/src/dfxvm/install.rs +++ b/src/dfxvm/install.rs @@ -101,8 +101,11 @@ async fn download_verified_tarball( #[allow(unused_variables)] fn format_tarball_basename(version: &Version) -> &'static str { - #[cfg(target_os = "linux")] + #[cfg(all(target_os = "linux", target_arch = "x86_64"))] return "dfx-x86_64-unknown-linux-gnu"; + #[cfg(all(target_os = "linux", target_arch = "aarch64"))] + // TODO: Check dfx version to see if it supports aarch64-unknown-linux-gnu. + return "dfx-aarch64-unknown-linux-gnu"; #[cfg(all(target_os = "macos", target_arch = "x86_64"))] return "dfx-x86_64-apple-darwin"; #[cfg(all(target_os = "macos", target_arch = "aarch64"))] diff --git a/src/dfxvm/self_update.rs b/src/dfxvm/self_update.rs index bf84721..32b9eab 100644 --- a/src/dfxvm/self_update.rs +++ b/src/dfxvm/self_update.rs @@ -65,11 +65,13 @@ pub fn cleanup_self_updater(locations: &Locations) -> Result<(), CleanupSelfUpda } fn format_tarball_url(settings: &Settings) -> Result { - #[cfg(target_arch = "aarch64")] + #[cfg(all(target_os = "macos", target_arch = "aarch64"))] let architecture = "aarch64-apple-darwin"; #[cfg(all(target_os = "macos", target_arch = "x86_64"))] let architecture = "x86_64-apple-darwin"; - #[cfg(target_os = "linux")] + #[cfg(all(target_os = "linux", target_arch = "aarch64"))] + let architecture = "aarch64-unknown-linux-gnu"; + #[cfg(all(target_os = "linux", target_arch = "x86_64"))] let architecture = "x86_64-unknown-linux-gnu"; let basename = format!("dfxvm-{}", architecture); From e384a54d1c39e83f4add7a65fe2cba6605eef213 Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Thu, 17 Jul 2025 16:52:23 +0800 Subject: [PATCH 2/7] Add build target for aarch64-linux. --- dist-workspace.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dist-workspace.toml b/dist-workspace.toml index e16cf89..5b19c0d 100644 --- a/dist-workspace.toml +++ b/dist-workspace.toml @@ -10,7 +10,7 @@ ci = "github" # The installers to generate for each app installers = [] # Target platforms to build apps for (Rust target-triple syntax) -targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu"] +targets = ["aarch64-apple-darwin", "aarch64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu"] # Which actions to run on pull requests pr-run-mode = "plan" # The archive format to use for non-windows builds (defaults .tar.xz) @@ -21,5 +21,6 @@ dist = true [dist.github-custom-runners] global = "ubuntu-22.04" x86_64-unknown-linux-gnu = "ubuntu-22.04" +aarch64-unknown-linux-gnu = "ubuntu-22.04-arm" x86_64-apple-darwin = "macos-13" aarch64-apple-darwin = "macos-15" From 84d8e80141df3af6c97429e693c1ffcd417b2db3 Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Thu, 17 Jul 2025 16:57:28 +0800 Subject: [PATCH 3/7] Run tests on all the platforms. --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 62a2011..ccc4afd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest-large, macos-latest] steps: - uses: actions/checkout@v4 From dd998c8d61e1ad302cf61af4a5bdb86839929554 Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Tue, 5 Aug 2025 20:52:48 +0800 Subject: [PATCH 4/7] Fixed tests. --- src/dfxvm/install.rs | 1 - tests/suite/common/release_asset.rs | 11 +++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/dfxvm/install.rs b/src/dfxvm/install.rs index f4e2b76..4043985 100644 --- a/src/dfxvm/install.rs +++ b/src/dfxvm/install.rs @@ -104,7 +104,6 @@ fn format_tarball_basename(version: &Version) -> &'static str { #[cfg(all(target_os = "linux", target_arch = "x86_64"))] return "dfx-x86_64-unknown-linux-gnu"; #[cfg(all(target_os = "linux", target_arch = "aarch64"))] - // TODO: Check dfx version to see if it supports aarch64-unknown-linux-gnu. return "dfx-aarch64-unknown-linux-gnu"; #[cfg(all(target_os = "macos", target_arch = "x86_64"))] return "dfx-x86_64-apple-darwin"; diff --git a/tests/suite/common/release_asset.rs b/tests/suite/common/release_asset.rs index 74e66b5..9259012 100644 --- a/tests/suite/common/release_asset.rs +++ b/tests/suite/common/release_asset.rs @@ -66,13 +66,16 @@ impl ReleaseAsset { format!("{basename}.{archive_format}") } + #[allow(unused_variables)] pub fn dfxvm_tarball_basename() -> String { - #[cfg(target_arch = "aarch64")] - let arch_and_os = "aarch64-apple-darwin"; + #[cfg(all(target_os = "linux", target_arch = "x86_64"))] + return "x86_64-unknown-linux-gnu"; + #[cfg(all(target_os = "linux", target_arch = "aarch64"))] + return "aarch64-unknown-linux-gnu"; #[cfg(all(target_os = "macos", target_arch = "x86_64"))] let arch_and_os = "x86_64-apple-darwin"; - #[cfg(target_os = "linux")] - let arch_and_os = "x86_64-unknown-linux-gnu"; + #[cfg(all(target_os = "macos", target_arch = "aarch64"))] + let arch_and_os = "aarch64-apple-darwin"; format!("dfxvm-{}", arch_and_os) } From 22e047c1c90823e0e2462895c310d06de76e326e Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Tue, 5 Aug 2025 20:55:41 +0800 Subject: [PATCH 5/7] Fixed build. --- tests/suite/common/release_asset.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/suite/common/release_asset.rs b/tests/suite/common/release_asset.rs index 9259012..a8a89cd 100644 --- a/tests/suite/common/release_asset.rs +++ b/tests/suite/common/release_asset.rs @@ -69,9 +69,9 @@ impl ReleaseAsset { #[allow(unused_variables)] pub fn dfxvm_tarball_basename() -> String { #[cfg(all(target_os = "linux", target_arch = "x86_64"))] - return "x86_64-unknown-linux-gnu"; + let arch_and_os = "x86_64-unknown-linux-gnu"; #[cfg(all(target_os = "linux", target_arch = "aarch64"))] - return "aarch64-unknown-linux-gnu"; + let arch_and_os = "aarch64-unknown-linux-gnu"; #[cfg(all(target_os = "macos", target_arch = "x86_64"))] let arch_and_os = "x86_64-apple-darwin"; #[cfg(all(target_os = "macos", target_arch = "aarch64"))] From fdd00192dc7af7330d8e6a32c683474887cfedf4 Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Tue, 5 Aug 2025 21:35:44 +0800 Subject: [PATCH 6/7] Fixed the tests again. --- tests/suite/common/file_contents.rs | 5 +++-- tests/suite/common/release_asset.rs | 31 +++++++++++++++++++---------- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/tests/suite/common/file_contents.rs b/tests/suite/common/file_contents.rs index 47ed675..b8033ad 100644 --- a/tests/suite/common/file_contents.rs +++ b/tests/suite/common/file_contents.rs @@ -1,6 +1,7 @@ use crate::common::ReleaseAsset; use flate2::write::GzEncoder; use flate2::Compression; +use semver::Version; use serde_json::json; use sha2::{Digest, Sha256}; use std::io::Write; @@ -48,8 +49,8 @@ pub fn dist_manifest_json(latest: &str) -> String { .to_string() } -pub fn dfx_tarball(contents: &[u8]) -> Vec { - let dirname = ReleaseAsset::dfx_tarball_basename(); +pub fn dfx_tarball(version: &Version, contents: &[u8]) -> Vec { + let dirname = ReleaseAsset::dfx_tarball_basename(version); let include_docs = false; tool_tarball("dfx", dirname, contents, include_docs) diff --git a/tests/suite/common/release_asset.rs b/tests/suite/common/release_asset.rs index a8a89cd..8213763 100644 --- a/tests/suite/common/release_asset.rs +++ b/tests/suite/common/release_asset.rs @@ -18,13 +18,13 @@ impl ReleaseAsset { } pub fn dfx_tarball_with_dfx_contents(version: &str, executable: &[u8]) -> ReleaseAsset { - let filename = Self::dfx_tarball_filename().to_string(); let version = Version::parse(version).unwrap(); + let filename = Self::dfx_tarball_filename(&version).to_string(); // must match the download_url_template in ReleaseServer::new let url_path = format!("/any/arbitrary/path/{version}/{filename}"); - let contents = dfx_tarball(executable); + let contents = dfx_tarball(&version, executable); ReleaseAsset { url_path, filename, @@ -52,16 +52,27 @@ impl ReleaseAsset { .unwrap() } - pub fn dfx_tarball_basename() -> &'static str { - #[cfg(target_os = "macos")] - let basename = "dfx-x86_64-apple-darwin"; - #[cfg(target_os = "linux")] - let basename = "dfx-x86_64-unknown-linux-gnu"; - basename + #[allow(unused_variables)] + pub fn dfx_tarball_basename(version: &Version) -> &'static str { + #[cfg(all(target_os = "macos", target_arch = "x86_64"))] + return "dfx-x86_64-apple-darwin"; + #[cfg(all(target_os = "macos", target_arch = "aarch64"))] + { + // This is the first version that supports aarch64-apple-darwin. + let aarch64_apple_darwin_version = Version::parse("0.28.0-beta.1").unwrap(); + if version >= &aarch64_apple_darwin_version { + return "dfx-aarch64-apple-darwin"; + } + return "dfx-x86_64-apple-darwin"; + } + #[cfg(all(target_os = "linux", target_arch = "x86_64"))] + return "dfx-x86_64-unknown-linux-gnu"; + #[cfg(all(target_os = "linux", target_arch = "aarch64"))] + return "dfx-aarch64-unknown-linux-gnu"; } - pub fn dfx_tarball_filename() -> String { - let basename = Self::dfx_tarball_basename(); + pub fn dfx_tarball_filename(version: &Version) -> String { + let basename = Self::dfx_tarball_basename(version); let archive_format = "tar.gz"; format!("{basename}.{archive_format}") } From 47fd841f362a387185af2278d26ef164d80cf129 Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Wed, 6 Aug 2025 14:02:51 +0800 Subject: [PATCH 7/7] Update changelog. --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 23737ad..4a8ca3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - ReleaseDate +- `dfxvm` now has the aarch64-linux version and supports installing dfx with the aarch64-linux binaries. + ## [1.0.1] - 2025-07-02 - `dfxvm --list` now supports listing the available dfx versions.