为什么march = native在Apple M1上不起作用? [英] Why does march=native not work on Apple M1?

查看:149
本文介绍了为什么march = native在Apple M1上不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我尝试在带有M1芯片的Macbook上使用 march = native 编译任何C ++程序时,使用clang时都会出现以下错误:

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'

但是,它过去只能在具有Intel CPU的旧Macbook上运行.铛尚不支持这种架构吗?

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

clang --version 给出:

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

推荐答案

据我所知,这不是 Apple M1 所特有的,对于其他各种体系结构(大多数是其他种种分支),它也会在clang中发生处理器).例如请在此处查看此错误报告 https://github.com/DMOJ/judge-server/issues/303

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

基本上,用于新体系结构的每个clang版本都必须选择为"march = native"提供默认值.是否为编译器构建的目标;如果没有,那么您将看到此错误消息.即使对于那些确实具有优化目标的手臂处理器,您通常也必须专门使用"-mcpu = xxx"而不是"-march".

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".

例如对于iPhone,您可以使用 -mcpu = apple-a11 -mcpu = apple-a12 等.

e.g. For the iphone you would use -mcpu=apple-a11 -mcpu=apple-a12 etc.

但是对于 Apple M1

这篇关于为什么march = native在Apple M1上不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆