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