Issue
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
Solution
As far as I know this is not Apple M1
specific, it occurs also with clang for various other architectures (mostly various other arm processors).
e.g. See this bug report here https://github.com/DMOJ/judge-server/issues/303
Basically every build of clang for a new architecture must choose to provide defaults for "march=native" for the target for which the compiler is built or not; and if not then you will see this error message. Even for those arm processors who do have optimisation targets you often have to use specifically "-mcpu=xxx" instead of "-march".
e.g. For the iphone you would use -mcpu=apple-a11
-mcpu=apple-a12
etc.
However no such target has been implemented yet for Apple M1
Answered By - Malcolm MacLeod Answer Checked By - Timothy Miller (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.