Skip to content
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

Unable to get architecture of the current processor #43246

Closed
TonyValenti opened this issue Oct 10, 2020 · 7 comments
Closed

Unable to get architecture of the current processor #43246

TonyValenti opened this issue Oct 10, 2020 · 7 comments
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-System.Runtime.InteropServices
Milestone

Comments

@TonyValenti
Copy link

It seems as though the ProcessArchitecture enum does not contain ARM64/32 variants which should be added.

@TonyValenti TonyValenti added the api-suggestion Early API idea and discussion, it is NOT ready for implementation label Oct 10, 2020
@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-System.Reflection untriaged New issue has not been triaged by the area owner labels Oct 10, 2020
@TonyValenti
Copy link
Author

@danmosemsft I don't believe that is it. How would I get the architecture of the current processor?

This is close:
https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.runtimeinformation.processarchitecture?view=netcore-3.1

But that gives the process architecture of the currently running app, not of the machine.

I need to be able to detect if an x86 app is running on an x64 or arm64 processor. Using the above, running x86 on x64 returns x86 which is not what I need.

@danmoseley
Copy link
Member

Ah, I'm not sure whether we attempt to expose that -- generally, the OS tries hard to conceal it from you.

Outside of .NET, I have usually seen people check eg the PROCESSOR_ARCHITEW6432 environment variable (at least that's for detecting WOW64, not sure about on ARM)

@iSazonov
Copy link
Contributor

Is it related with adding osx-arm64 #43313?

@steveharter
Copy link
Member

The System.Reflection namespace is not intended for environmental detection. The linked System.Runtime.InteropServices is a better fit.

@steveharter steveharter changed the title System.Reflection.ProcessArchitecture.Arm64 Unable to get architecture of the current processor Nov 12, 2020
@AaronRobinsonMSFT
Copy link
Member

@danmosemsft and @TonyValenti This is a good question and one that warrants a longer discussion. The RuntimeInformation.ProcessorArchitecture is meant to indicate the processor type the runtime is on top of, not necessarily details about the underlying hardware. Since there is an x86 emulation layer on an ARM64 machine this is stating what it was intended to state - the emulation layer is in play here and confusing things further. I don't think this is something the runtime should try and handle honestly. It becomes an exercise in futility as we must try to constantly peer into how the runtime is being run and honestly the entire point of the runtime is to abstract that away - not possible in all cases but is an ideal.

I also think this is enough of niche case that we should defer this until we get more user feedback. I would have some reservations about creating a new API. For context, APIs that represent this distinction on Windows are GetSystemInfo and GetNativeSystemInfo - the runtime uses GetSystemInfo in the implementation.

@AaronRobinsonMSFT AaronRobinsonMSFT removed the untriaged New issue has not been triaged by the area owner label Dec 2, 2020
@AaronRobinsonMSFT AaronRobinsonMSFT added this to the Future milestone Dec 2, 2020
@jkotas
Copy link
Member

jkotas commented Dec 25, 2021

Duplicate of #58463

@jkotas jkotas marked this as a duplicate of #58463 Dec 25, 2021
@jkotas jkotas closed this as completed Dec 25, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Jan 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-System.Runtime.InteropServices
Projects
None yet
Development

No branches or pull requests

7 participants