Cross-Compiling Rust for Rosetta on Mac
27 November 2024
On an Apple Silicon Mac I was a cross-compiling some Rust code for the x86 version of a Mac and wanted to run some tests. That is:
cargo test --target x86_64-apple-darwin
This gave me an error I didn't expect: "Bad CPU type in executable (os error 86)".
Aren't Apple Silicon Macs supposed to come with you-beaut emulation so that they run x86 binaries flawlessly? Well yes, but it turns out it's not installed by default.
% softwareupdate --install-rosetta I have read and agree to the terms of the software license agreement. A list of Apple SLAs may be found here: https://www.apple.com/legal/sla/ Type A and press return to agree: A 2024-11-27 19:32:19.298 softwareupdate[69420:4381642] Package Authoring Error: 072-12297: Package reference com.apple.pkg.RosettaUpdateAuto is missing installKBytes attribute Install of Rosetta 2 finished successfully
After running this command the cargo invocation works correctly.
Tech Tidbits Blog by Thomas Karpiniec
Posts RSS, Atom