PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, June 25, 2022

[FIXED] Why does march=native not work on Apple M1?

 June 25, 2022     c, c++, compilation, compiler-errors     No comments   

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)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing