Dariusz
Dariusz

Reputation: 1044

How to get cpu architecture e.g. Mac/M1/Intel?

I need to find out at runtime which architecture the CPU is running. I've so far used qt: QSysInfo::currentCpuArchitecture() but there is a problem.

The returned value will change when ever I run application that was compiled for x86_64 or arm64. So this will not return the hardware architecture that the system is natively running, but the emulated one by mac. Say if I run x86_64 it would run via Rosetta probably and then the arch would be x86_64 and not arm64.

I need a way to find out hardware arch of system that is, and not is emulated. How can I do it?

Macros/etc will not work.

Running QProcess from within the app still returns x86_64 from uname -p etc.

Upvotes: 1

Views: 1832

Answers (1)

Dariusz
Dariusz

Reputation: 1044

Starting QProcess does not work, he inherits base application architecture.

I found out that apple added a command to figure out if I'm running in "translated" mode, this can then be used as indication if we are on intel or arm.

https://developer.apple.com/documentation/apple-silicon/about-the-rosetta-translation-environment

Upvotes: 1

Related Questions