Skip to content

Commit 39b63c0

Browse files
feat: Support aarch64-linux. (#110)
* Support aarch64-linux. * Add build target for aarch64-linux. * Run tests on all the platforms. * Fixed tests. * Fixed build. * Fixed the tests again. * Update changelog.
1 parent e35c14d commit 39b63c0

7 files changed

Lines changed: 43 additions & 21 deletions

File tree

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
os: [ubuntu-latest, macos-latest]
16+
os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest-large, macos-latest]
1717
steps:
1818
- uses: actions/checkout@v4
1919

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
## [Unreleased] - ReleaseDate
1111

12+
- `dfxvm` now has the aarch64-linux version and supports installing dfx with the aarch64-linux binaries.
13+
1214
## [1.0.1] - 2025-07-02
1315

1416
- `dfxvm --list` now supports listing the available dfx versions.

dist-workspace.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ci = "github"
1010
# The installers to generate for each app
1111
installers = []
1212
# Target platforms to build apps for (Rust target-triple syntax)
13-
targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu"]
13+
targets = ["aarch64-apple-darwin", "aarch64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu"]
1414
# Which actions to run on pull requests
1515
pr-run-mode = "plan"
1616
# The archive format to use for non-windows builds (defaults .tar.xz)
@@ -21,5 +21,6 @@ dist = true
2121
[dist.github-custom-runners]
2222
global = "ubuntu-22.04"
2323
x86_64-unknown-linux-gnu = "ubuntu-22.04"
24+
aarch64-unknown-linux-gnu = "ubuntu-22.04-arm"
2425
x86_64-apple-darwin = "macos-13"
2526
aarch64-apple-darwin = "macos-15"

src/dfxvm/install.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,10 @@ async fn download_verified_tarball(
101101

102102
#[allow(unused_variables)]
103103
fn format_tarball_basename(version: &Version) -> &'static str {
104-
#[cfg(target_os = "linux")]
104+
#[cfg(all(target_os = "linux", target_arch = "x86_64"))]
105105
return "dfx-x86_64-unknown-linux-gnu";
106+
#[cfg(all(target_os = "linux", target_arch = "aarch64"))]
107+
return "dfx-aarch64-unknown-linux-gnu";
106108
#[cfg(all(target_os = "macos", target_arch = "x86_64"))]
107109
return "dfx-x86_64-apple-darwin";
108110
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]

src/dfxvm/self_update.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,13 @@ pub fn cleanup_self_updater(locations: &Locations) -> Result<(), CleanupSelfUpda
6565
}
6666

6767
fn format_tarball_url(settings: &Settings) -> Result<Url, FormatTarballUrlError> {
68-
#[cfg(target_arch = "aarch64")]
68+
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
6969
let architecture = "aarch64-apple-darwin";
7070
#[cfg(all(target_os = "macos", target_arch = "x86_64"))]
7171
let architecture = "x86_64-apple-darwin";
72-
#[cfg(target_os = "linux")]
72+
#[cfg(all(target_os = "linux", target_arch = "aarch64"))]
73+
let architecture = "aarch64-unknown-linux-gnu";
74+
#[cfg(all(target_os = "linux", target_arch = "x86_64"))]
7375
let architecture = "x86_64-unknown-linux-gnu";
7476

7577
let basename = format!("dfxvm-{}", architecture);

tests/suite/common/file_contents.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::common::ReleaseAsset;
22
use flate2::write::GzEncoder;
33
use flate2::Compression;
4+
use semver::Version;
45
use serde_json::json;
56
use sha2::{Digest, Sha256};
67
use std::io::Write;
@@ -48,8 +49,8 @@ pub fn dist_manifest_json(latest: &str) -> String {
4849
.to_string()
4950
}
5051

51-
pub fn dfx_tarball(contents: &[u8]) -> Vec<u8> {
52-
let dirname = ReleaseAsset::dfx_tarball_basename();
52+
pub fn dfx_tarball(version: &Version, contents: &[u8]) -> Vec<u8> {
53+
let dirname = ReleaseAsset::dfx_tarball_basename(version);
5354
let include_docs = false;
5455

5556
tool_tarball("dfx", dirname, contents, include_docs)

tests/suite/common/release_asset.rs

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ impl ReleaseAsset {
1818
}
1919

2020
pub fn dfx_tarball_with_dfx_contents(version: &str, executable: &[u8]) -> ReleaseAsset {
21-
let filename = Self::dfx_tarball_filename().to_string();
2221
let version = Version::parse(version).unwrap();
22+
let filename = Self::dfx_tarball_filename(&version).to_string();
2323

2424
// must match the download_url_template in ReleaseServer::new
2525
let url_path = format!("/any/arbitrary/path/{version}/{filename}");
2626

27-
let contents = dfx_tarball(executable);
27+
let contents = dfx_tarball(&version, executable);
2828
ReleaseAsset {
2929
url_path,
3030
filename,
@@ -52,27 +52,41 @@ impl ReleaseAsset {
5252
.unwrap()
5353
}
5454

55-
pub fn dfx_tarball_basename() -> &'static str {
56-
#[cfg(target_os = "macos")]
57-
let basename = "dfx-x86_64-apple-darwin";
58-
#[cfg(target_os = "linux")]
59-
let basename = "dfx-x86_64-unknown-linux-gnu";
60-
basename
55+
#[allow(unused_variables)]
56+
pub fn dfx_tarball_basename(version: &Version) -> &'static str {
57+
#[cfg(all(target_os = "macos", target_arch = "x86_64"))]
58+
return "dfx-x86_64-apple-darwin";
59+
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
60+
{
61+
// This is the first version that supports aarch64-apple-darwin.
62+
let aarch64_apple_darwin_version = Version::parse("0.28.0-beta.1").unwrap();
63+
if version >= &aarch64_apple_darwin_version {
64+
return "dfx-aarch64-apple-darwin";
65+
}
66+
return "dfx-x86_64-apple-darwin";
67+
}
68+
#[cfg(all(target_os = "linux", target_arch = "x86_64"))]
69+
return "dfx-x86_64-unknown-linux-gnu";
70+
#[cfg(all(target_os = "linux", target_arch = "aarch64"))]
71+
return "dfx-aarch64-unknown-linux-gnu";
6172
}
6273

63-
pub fn dfx_tarball_filename() -> String {
64-
let basename = Self::dfx_tarball_basename();
74+
pub fn dfx_tarball_filename(version: &Version) -> String {
75+
let basename = Self::dfx_tarball_basename(version);
6576
let archive_format = "tar.gz";
6677
format!("{basename}.{archive_format}")
6778
}
6879

80+
#[allow(unused_variables)]
6981
pub fn dfxvm_tarball_basename() -> String {
70-
#[cfg(target_arch = "aarch64")]
71-
let arch_and_os = "aarch64-apple-darwin";
82+
#[cfg(all(target_os = "linux", target_arch = "x86_64"))]
83+
let arch_and_os = "x86_64-unknown-linux-gnu";
84+
#[cfg(all(target_os = "linux", target_arch = "aarch64"))]
85+
let arch_and_os = "aarch64-unknown-linux-gnu";
7286
#[cfg(all(target_os = "macos", target_arch = "x86_64"))]
7387
let arch_and_os = "x86_64-apple-darwin";
74-
#[cfg(target_os = "linux")]
75-
let arch_and_os = "x86_64-unknown-linux-gnu";
88+
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
89+
let arch_and_os = "aarch64-apple-darwin";
7690

7791
format!("dfxvm-{}", arch_and_os)
7892
}

0 commit comments

Comments
 (0)