Apple m2-max not being detected as the host CPU?

I have a MacBook with an m2-max CPU:

❯ sysctl -n machdep.cpu.brand_string
Apple M2 Max

But rustc defaults to m1:

❯ rustc +nightly --version
rustc 1.74.0-nightly (58eefc33a 2023-08-24)

❯  rustc +nightly --print target-cpus
Available CPUs for this target:
    native          - Select the CPU of the current host (currently apple-m1).
    apple-m1        - This is the default target CPU for the current build target (currently arm64-apple-macosx11.0.0).

Is there a reason for this that I am missing, or is it worth me trying to dig into this and create a PR to default to m2 when running an m2-max?

LLVM is responsible for detecting the native cpu. Looks like LLVM doesn't yet know how to detect cpu's newer than m1:


Thanks for that!

I've submitted this patch ⚙ D158840 Detect apple M2 processor targets to try and fix that. It's not a very friendly contribution experience if you are new, so I'm unclear as to if it's in the right place or who to add as a reviewer.

Let's see!


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.