Why does march=native not work on Apple M1?

Whenever I try to compile any C++ program with march=native on a Macbook with a M1 chip, I get the following error when using clang:

clang: error: the clang compiler does not support '-march=native'

However, it used to work on an older Macbook with an Intel CPU. Does clang not support this architecture (yet)?

clang --version gives:

Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: arm64-apple-darwin20.2.0

I see the same behaviour, and I see that this works with apple clang 13 on x64, so they must have made a decision to not support this (for some reason).

I’m not familiar with the code, or specifics about this, but it looks to me like this special case of native just isn’t implemented for arm64 like it is for x86_64. Here’s the x86_64 handling

And the relevant arm64 handling happens here llvm-project/AArch64.cpp at 4465c299069f3ff5b93ba648edf699faf7f39e79 · llvm/llvm-project · GitHub

Which ends up checking what you pass against this switch llvm-project/AArch64TargetParser.cpp at 4465c299069f3ff5b93ba648edf699faf7f39e79 · llvm/llvm-project · GitHub

You could probably submit a change handling native if you have a good use case and I imagine some more folks might see it

I submitted ⚙ D119788 [AArch64] Add support for -march=native for Apple M1 CPU for this

But what about M2? Also what about latencies sheduler vs M1? Also, what about support for GitHub - corsix/amx: Apple AMX Instruction Set?

My machine.h has a new entry:

#define CPUFAMILY_ARM_BLIZZARD_AVALANCHE 0xda33d83d

That is probably an A15 or the M2.

LLVM has no machine models for modern Apple CPUs. It does not know the number of ports or latencies of the instructions. The difference between M1 and M2 will be that the M2 supports more instructions. ARMv8.5-A vs ARMv8.6-A.

Thanks for M2 support ⚙ D134351 AArch64: add definitions for recent Apple CPUs.

No, M2 is ARMv8.6-A, it just does not have SM4 instruction set, that it should.