Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Ho do I know macOS has intel chip (or) m1 chip from command line?

Hi All,


I need to run an executable based on the processor it has. If it has intel based chip then I will run one kind of executable and for arm based m1 chip i will run another executable which intended for same operation.


In order to do above task, in my code I need to get the information on which processor was installed in the mac PC from command line? Could anyone suggest how to get the processor information from command line for macOS?



MacBook Pro (2020 and later)

Posted on Jan 27, 2022 10:20 PM

Reply
Question marked as Best reply

Posted on Jan 27, 2022 11:09 PM

Hi!


You can use the uname command to print the processor architecture of the computer. On an intel machine I get:

$ uname -m      
x86_64


And on an arm Mac it is:

$ uname -m
arm64


Alternatively uname also offers the 'p' option. Just have a look at 'man uname'. This command is also available on Linux machines.


Christian


3 replies
Question marked as Best reply

Jan 27, 2022 11:09 PM in response to nhkrishna

Hi!


You can use the uname command to print the processor architecture of the computer. On an intel machine I get:

$ uname -m      
x86_64


And on an arm Mac it is:

$ uname -m
arm64


Alternatively uname also offers the 'p' option. Just have a look at 'man uname'. This command is also available on Linux machines.


Christian


Jan 30, 2022 8:46 AM in response to nhkrishna

For macOS, this particular detail can usually be ignored for apps using multi-architectural binaries:


https://developer.apple.com/documentation/apple-silicon/building-a-universal-macos-binary


That link includes building such binaries, as well as conditional compilations for Swift and Objective C, as well as conditional compilations for iOS, iPadOS, and macOS targets.


Other programming languages with Apple hardware targets usually have similar conditional support.


This approach—rather than run-time checks—can greatly simplify packaging and distribution of these apps.


Or use uname or similar run-time architectural sniffing, and your own cross-platform support for whatever language and app and targets you’re using. (Your question and your follow-up question are really open-ended, here.)


If you do decide to use a shell script, use a shebang and select either bash or (probably preferably) zsh explicitly, so that you don't run into problems with different default shells, as older logins can have bash and newer logins will have zsh.


As for the other platforms, best check with them. Microsoft Windows does not presently have a supported version for Apple silicon; there’s no purchasable product available (as yet?). What Windows for ARM64 is available is an unsupported insider’s beta, via a virtual machine. Linux is also just getting going on Apple silicon. Either of these can likely use uname via WSL (if/as that’s available), or via the Linux shell. Microsoft seems to prefer folks use .NET, and the CLR deals with most architectural baggage.


Again, you’ll want to check with Microsoft folks around how to differentiate x86-64, x86-64, AArch64, Alpha, Itanium, or whatever other Windows targets you might need. Most of those have been de-supported, but Windows has been multi-architecture for a while, so this should not be hard to find from a Windows-focused resource.


And Java can ignore pretty much all of this stuff most everywhere, outside of code using JNI or whatever that’s now called.

Ho do I know macOS has intel chip (or) m1 chip from command line?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.