Skip to content

Commit 7949505

Browse files
committed
Merge rust-bitcoin#71: Fix to download the correct binary for Apple silicon Macs
d692352 fix: codesign the bitcoin binary on mac arm64 (Cliff Syner) f38db55 fix: use arm64 binary for apple silicon (Cliff Syner) Pull request description: Previously, using the (node) crate with the `from_downloaded()` trait would fail on apple silicon with `bad CPU type in executable` Part of the update includes some code-signing, this is necessary for unsigned binaries (like bitcoind) to run on Arm Macs: bitcoin/bitcoin#26694 (comment) ACKs for top commit: tcharding: utACK d692352 Tree-SHA512: 7e01009622d3c3a16ee296e068bb881a63656eb8e74f3e51249c3079f76cee59822fe28df5023fbe183d4067dd4869fcd3be346a4a664316fb8e27747cc2f6c7
2 parents 5ffe690 + d692352 commit 7949505

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

node/build.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ mod download {
2020

2121
include!("src/versions.rs");
2222

23-
#[cfg(all(target_os = "macos", any(target_arch = "x86_64", target_arch = "aarch64"),))]
23+
#[cfg(all(target_os = "macos", target_arch = "x86_64"))]
2424
fn download_filename() -> String {
2525
if cfg!(not(feature = "23_2")) {
2626
format!("bitcoin-{}-osx64.tar.gz", &VERSION)
@@ -29,6 +29,9 @@ mod download {
2929
}
3030
}
3131

32+
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
33+
fn download_filename() -> String { format!("bitcoin-{}-arm64-apple-darwin.tar.gz", &VERSION) }
34+
3235
#[cfg(all(target_os = "linux", target_arch = "x86_64"))]
3336
fn download_filename() -> String { format!("bitcoin-{}-x86_64-linux-gnu.tar.gz", &VERSION) }
3437

@@ -153,6 +156,24 @@ mod download {
153156
}
154157
}
155158
}
159+
160+
// Code signing for arm64 macOS:
161+
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
162+
{
163+
use std::process::Command;
164+
let status = Command::new("codesign")
165+
.arg("-s")
166+
.arg("-")
167+
.arg(existing_filename.to_str().unwrap())
168+
.status()
169+
.with_context(|| "failed to execute codesign")?;
170+
if !status.success() {
171+
return Err(anyhow::anyhow!(
172+
"codesign failed with exit code {}",
173+
status.code().unwrap_or(-1)
174+
));
175+
}
176+
}
156177
}
157178
Ok(())
158179
}

0 commit comments

Comments
 (0)