Skip to content

feat: Add dfx binaries for aarch64-darwin. #4277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jun 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,14 @@ jobs:
matrix:
# We build a dynamic-linked linux binary because otherwise HSM support fails with:
# Error: IO: Dynamic loading not supported
os: [macos-13, ubuntu-22.04, ubuntu-24.04, windows-2022]
os: [macos-13, macos-13-xlarge, ubuntu-22.04, ubuntu-24.04, windows-2022]
include:
- os: macos-13
target: x86_64-apple-darwin
binary_path: target/x86_64-apple-darwin/release/dfx
- os: macos-13-xlarge
target: aarch64-apple-darwin
binary_path: target/aarch64-apple-darwin/release/dfx
- os: ubuntu-22.04
target: x86_64-unknown-linux-gnu
binary_path: target/x86_64-unknown-linux-gnu/release/dfx
Expand Down Expand Up @@ -111,7 +114,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [macos-13, ubuntu-22.04, ubuntu-24.04]
os: [macos-13, macos-13-xlarge, ubuntu-22.04, ubuntu-24.04]
steps:
- uses: actions/checkout@v4
- name: Download dfx binary
Expand Down Expand Up @@ -181,7 +184,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [macos-13, ubuntu-22.04, ubuntu-24.04]
os: [macos-13, macos-13-xlarge, ubuntu-22.04, ubuntu-24.04]
steps:
- name: Checking out repo
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-13-large, windows-latest ]
os: [ ubuntu-latest, macos-13-large, macos-13-xlarge, windows-latest ]

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prepare-dfx-assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-13-large ]
os: [ ubuntu-latest, macos-13-large, macos-13-xlarge ]
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,18 @@ 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, x86_64-unknown-linux-gnu ]
target: [ x86_64-apple-darwin, aarch64-apple-darwin, x86_64-unknown-linux-gnu ]
include:
- os: macos-13-large
target: x86_64-apple-darwin
binary_path: target/x86_64-apple-darwin/release
name: x86_64-darwin
tar: gtar
- os: macos-13-xlarge
target: aarch64-apple-darwin
binary_path: target/aarch64-apple-darwin/release
name: aarch64-darwin
tar: gtar
- os: ubuntu-22.04
target: x86_64-unknown-linux-gnu
binary_path: target/x86_64-unknown-linux-gnu/release
Expand Down Expand Up @@ -146,7 +151,7 @@ jobs:
strategy:
fail-fast: false
matrix:
name: [ 'x86_64-darwin', 'x86_64-linux' ]
name: [ 'x86_64-darwin', 'aarch64-darwin', 'x86_64-linux' ]
steps:
- uses: actions/checkout@v4

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-13-large ]
os: [ ubuntu-latest, macos-13-large, macos-13-xlarge ]
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ You can get the fees by `get_config` API on the [BTC Mainnet Canister](https://d
If you were using the contents of the `pocket-ic-proxy-port` file to determine the port for
the `/http_gateway` endpoint, you should instead use `dfx info pocketic-config-port`

### feat: add dfx native support for aarch64-Darwin

Add dfx native support for aarch64-Darwin.

## Dependencies

### Replica
Expand Down
2 changes: 1 addition & 1 deletion scripts/update-motoko.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
declare -A variants=([x86_64-darwin]=Darwin-x86_64 [x86_64-linux]=Linux-x86_64 [arm64-darwin]=Darwin-arm64)
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")")
Expand Down
6 changes: 4 additions & 2 deletions scripts/update-replica.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ sources="src/dfx/assets/dfx-asset-sources.json"
rev=$1
echo "Updating sources to rev ${rev}"
jq '."replica-rev" = $rev' --arg rev "$rev" "$sources" | sponge "$sources"
for platform in x86_64-darwin x86_64-linux; do
pocketic_url=$(printf 'https://download.dfinity.systems/ic/%s/binaries/%s/pocket-ic.gz' "$rev" "$platform")

declare -A variants=([x86_64-darwin]=pocket-ic.gz [x86_64-linux]=pocket-ic.gz [arm64-darwin]=pocket-ic-server-arm64-darwin)
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)
jq '.[$platform]."pocket-ic" = {url: $url, sha256: $sha256, rev: $rev}' --arg platform "$platform" --arg rev "$rev" \
--arg url "$pocketic_url" --arg sha256 "$pocketic_sha" "$sources" | sponge "$sources"
Expand Down
5 changes: 5 additions & 0 deletions scripts/workflows/e2e-matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ def test_scripts(prefix):
"os": "macos-13",
"serial": serial,
})
include.append({
"test": test,
"os": "macos-13-xlarge",
"serial": serial,
})

matrix = {
"include": include,
Expand Down
5 changes: 4 additions & 1 deletion src/dfx/assets/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ struct Sources {
x86_64_linux: HashMap<String, Source>,
#[serde(rename = "x86_64-darwin")]
x86_64_darwin: HashMap<String, Source>,
#[serde(rename = "arm64-darwin")]
aarch64_darwin: HashMap<String, Source>,
common: HashMap<String, Source>,
#[serde(rename = "replica-rev")]
replica_rev: String,
Expand Down Expand Up @@ -99,7 +101,8 @@ fn find_assets(sources: Sources) -> PathBuf {
&*env::var("CARGO_CFG_TARGET_ARCH").unwrap(),
&*env::var("CARGO_CFG_TARGET_OS").unwrap(),
) {
("x86_64" | "aarch64", "macos") => sources.x86_64_darwin, // rosetta
("x86_64", "macos") => sources.x86_64_darwin, // rosetta
("aarch64", "macos") => sources.aarch64_darwin, // aarch64
("x86_64", "linux" | "windows") => sources.x86_64_linux,
(arch, os) => panic!("Unsupported OS type {arch}-{os}"),
};
Expand Down
12 changes: 12 additions & 0 deletions src/dfx/assets/dfx-asset-sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@
"rev": "ac7ff452684f84ea0cfc3fd0a27228220a368b33"
}
},
"arm64-darwin": {
"motoko": {
"url": "https://github.com/dfinity/motoko/releases/download/0.14.12/motoko-Darwin-arm64-0.14.12.tar.gz",
"sha256": "48460d0952f870f1e69b69a6eb956cf02f822166f5ae8853546c3e37319849ce",
"version": "0.14.12"
},
"pocket-ic": {
"url": "https://download.dfinity.systems/ic/ac7ff452684f84ea0cfc3fd0a27228220a368b33/binaries/arm64-darwin/pocket-ic-server-arm64-darwin",
"sha256": "f6cd133fee202ce57a6b4c8c88d648d3d42d4c2d10d9d3d0fe264f2012a691d9",
"rev": "ac7ff452684f84ea0cfc3fd0a27228220a368b33"
}
},
"x86_64-linux": {
"motoko": {
"url": "https://github.com/dfinity/motoko/releases/download/0.14.12/motoko-Linux-x86_64-0.14.12.tar.gz",
Expand Down
38 changes: 24 additions & 14 deletions src/dfx/assets/prepare_assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,23 +184,33 @@ async fn download_binaries(
.unwrap_or_else(|| panic!("Cannot find source for {bin}"))
.clone();
let client_ = client.clone();
joinset.spawn(async move { (bin, download_and_check_sha(client_, source).await) });
joinset.spawn(async move {
(
bin,
source.clone(),
download_and_check_sha(client_, source).await,
)
});
}
let mut map = HashMap::new();
while let Some(res) = joinset.join_next().await {
let (bin, content) = res.unwrap();
let decompressed = spawn_blocking(|| {
let mut buf = BytesMut::new();
io::copy(
&mut GzDecoder::new(content.reader()),
&mut (&mut buf).writer(),
)
.unwrap();
buf.freeze()
})
.await
.unwrap();
map.insert(bin.into(), decompressed);
let (bin, source, content) = res.unwrap();
let final_content = if source.url.ends_with(".gz") {
spawn_blocking(|| {
let mut buf = BytesMut::new();
io::copy(
&mut GzDecoder::new(content.reader()),
&mut (&mut buf).writer(),
)
.unwrap();
buf.freeze()
})
.await
.unwrap()
} else {
content
};
map.insert(bin.into(), final_content);
}
map
}
Expand Down