-
Notifications
You must be signed in to change notification settings - Fork 12.1k
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
Add Apple M4 host detection #117530
base: main
Are you sure you want to change the base?
Add Apple M4 host detection #117530
Conversation
case CPUFAMILY_UNKNOWN: | ||
return "invalid"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsure if I should return "generic" or "invalid" when the host CPU cannot be detected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be "generic"
, or perhaps change sys::getHostCPUName()
to return a std::optional<StringRef>
✅ With the latest revision this PR passed the C/C++ code formatter. |
7944594
to
82bd606
Compare
82bd606
to
6074a26
Compare
Also add support for older ARM families (this is likely never going to get used, since only macOS is officially supported as host OS, but nice to have for completeness sake). Error handling (checking CPUFAMILY_UNKNOWN) is also included here. Finally, add links to extra documentation to make it easier for others to update this in the future. These values should be up to date with Xcode 16.2 beta 3.
6074a26
to
7b5d723
Compare
// | ||
// NOTE: We choose to return `apple-mX` instead of `apple-aX`, since the M1, | ||
// M2, M3 etc. aliases are more widely known to users than A14, A15, A16 etc. | ||
// (and this code is basically only used on host macOS anyways). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From that perspective, I think it only makes sense to include the ones that shipped in a Mac. All the others are effectively dead code.
case CPUFAMILY_ARM_TAHITI: | ||
return "apple-m4"; // A18 Pro | ||
case CPUFAMILY_ARM_TUPAI: | ||
return "apple-m4"; // A18 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mind combining these with fallthroughs?
Add Apple M4 host detection, which fixes rust-lang/rust#133414.
Also add support for older ARM families (this is likely never going to get used, since only macOS is officially supported as host OS, but nice to have for completeness sake). Error handling (checking
CPUFAMILY_UNKNOWN
) is also included here.Finally, add links to extra documentation to make it easier for others to update this in the future.
NOTE: These values are taken from the Xcode 16.2 Beta 3 SDK, and has been confirmed on an M4 Max in rust-lang/rust#133414 (comment).