Why does march=native not work on Apple M1?(为什么 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 上运行.clang 不支持这种架构(还)吗?
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(主要是各种其他 arm处理器).例如在此处查看此错误报告 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"提供默认值;对于编译器构建与否的目标;如果没有,那么您将看到此错误消息.即使对于那些确实有优化目标的 arm 处理器,您通常也必须专门使用-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 上不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为什么 March=native 在 Apple M1 上不起作用?


基础教程推荐
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 我有静态或动态 boost 库吗? 2021-01-01
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 常量变量在标题中不起作用 2021-01-01
- 这个宏可以转换成函数吗? 2022-01-01
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 如何通过C程序打开命令提示符Cmd 2022-12-09