-
Notifications
You must be signed in to change notification settings - Fork 25
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
machine returns x86_64 on Apple M2 (arm64) #25
Comments
no, you are probably correct :) |
Yep, I'll take that challenge. 😀 It might actually be a problem with the |
TIL a bunch about Apple Silicon, M2, and universal binaries. tl;dr: To test this, I created a simple Rust application, using extern crate libc;
use self::libc::{uname, utsname};
use std::ffi::CStr;
use std::mem::MaybeUninit;
macro_rules! cstr2cow {
($v:expr) => {
CStr::from_ptr($v.as_ref().as_ptr()).to_string_lossy()
};
}
fn main() {
unsafe {
let mut uts = MaybeUninit::<utsname>::uninit();
if uname(uts.as_mut_ptr()) != -1 {
let uts = uts.assume_init();
println!("{}", cstr2cow!(uts.machine));
}
}
} It is possible to build a native arm64 binary:
With this binary,
This creates a Universal Binary containing both architectures: $ file arch
arch: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64Mach-O 64-bit executable x86_64] [arm64:Mach-O 64-bit executable arm64Mach-O 64-bit executable arm64]
arch (for architecture x86_64): Mach-O 64-bit executable x86_64
arch (for architecture arm64): Mach-O 64-bit executable arm64 Running the Universal Binary results in this, which I presume is the default architecture $ arch
arm64 |
Observed behavior: machine returns
x86_64
.Expected behavior: machine returns
arm64
.I recently switched from testing on an Intel Macbook Pro to an M2 chip, which is arm64. I noticed that platform-info is returning
x86_64
, though, when I'd expect it to returnarm64
. Am I just thinking about it wrong?The text was updated successfully, but these errors were encountered: