No CPU information from an emulated app on Apple Silicon(DTK)

Hello,

Application is failing to get CPU information when executing commands from an emulated app.

Trying to get system information using systemprofiler SPHardwareDataType, when this is run on developer Transition kit from an emulated app, there is no cputype info available in the returned xml. When the same is executed from universal app, it has a valid value for cpu_type .(this code works on Intel based systems without any issues )

There are other dependencies to be sorted out, before our app can be made Universal.
Meanwhile how can the CPU information for Apple silicon be obtained programatically from an emulated app.
Running system_profiler to get CPU information is a pretty heavyweight choice. Are you running it for other reasons as well? Or just for this? And what are you doing with the info you get back?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
We try to get other hardware information as well, not just the CPU info. This information is used to know the hardware info of the system where our app is run.(tried with sysctl -n machdep.cpu.brand_string, even this is not returning any value)

This information is used to know the hardware info of the system where
our app is run.

For reporting purposes? Or because you runtime decisions based on that info?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"

>> For reporting purposes? Or because you runtime decisions based on that info?

For reporting purposes


For reporting purposes

Cool.

Re-reading your initial email, I think I might’ve got the wrong end of the stick here. Are you trying to get the native (Arm) CPU information? Or the emulated (Intel) CPU info?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
>>Re-reading your initial email, I think I might’ve got the wrong end of the stick here. Are you trying to get the native (Arm) CPU information? Or the emulated (Intel) CPU info?

We are trying to get native (Arm) CPU information, but from an emulated app. Is this not possible?
Basically we want to report it as Apple processor if the hardware is Apple processor, (About Mac .. it shows as Apple A12Z ), but how can the same be read/found from an emulated app.

We are trying to get native (Arm) CPU information, but from an
emulated app.

Ah, tricky. Rosetta does its best to hide this from you.

The fact that system_profiler is not showing this info when run from your emulated app suggests that the code you’re using to execute it is following the ‘if emulating, keep emulating’ approach. If that is, if you launch a process from an emulated process it’ll run that process emulated.

In this past I’ve used various techniques to override this (like the arch command, see its man page). It looks like macOS 11 beta has a shiny new posix_spawnattr_setarchpref_np API to support this directly. I’m not set up to test that now, but you should give it a try and let us know how you get along.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
Thank you for the pointers, but looks like posixspawnattrsetarchpref_np is available with Xcode 12, our code is not yet compatible with Xcode 12. and the documentation says that it sets the preferred architecture. we don't want to set it but just report the hardware info.

our code is not yet compatible with Xcode 12

OK then, just to test, you should try bouncing through arch.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
OK, something really wonky is going on here. system_profiler claims to support the SPHardwareDataType:

Code Block
% sw_vers
ProductName: macOS
ProductVersion: 11.0
BuildVersion: 20A5374i
% system_profiler -listDataTypes
SPHardwareDataType


but when you ask for that data it returns nothing, but also doesn’t fail:

Code Block
% system_profiler SPHardwareDataType ; echo $?
0
%


Curiously, if you run the Intel slice of system_profiler you get results:

Code Block
% arch -arch x86_64 system_profiler SPHardwareDataType
Hardware:
Hardware Overview:
Model Name: Mac
Model Identifier: ADP3,2
Processor Name:
Processor Speed: 2.4 GHz
Number of Processors: 1
Total Number of Cores: 4
L2 Cache (per Core): 8 MB


I’ve no idea what’s gone wrong here but it’s clearly bugworthy. Two suggestions:
  1. Repeat the test above on 11.0b9 to see if it’s still a problem there (the DTK I’m working on hasn’t been updated yet, alas).

  2. If so, file a bug about this. Regardless of your big picture issue, system_profiler shouldn’t claim to support a particular report type and then produce no results.

Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
it's the same on beta9 too

it's the same on beta9 too

Indeed.

What was the number of the bug you filed about this?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
No CPU information from an emulated app on Apple Silicon(DTK)
 
 
Q