Mom*_*omo 6 c c++ compiler-errors compilation
每当我尝试march=native
在带有 M1 芯片的 Macbook 上编译任何 C++ 程序时,使用 clang 时都会出现以下错误:
clang: error: the clang compiler does not support '-march=native'
Run Code Online (Sandbox Code Playgroud)
但是,它曾经适用于配备 Intel CPU 的旧款 Macbook。clang 不支持这种架构(还)吗?
clang --version
给出:
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: arm64-apple-darwin20.2.0
Run Code Online (Sandbox Code Playgroud)
cha*_*iac 25
在 Apple clang 版本 13.0.0 中,-mcpu=apple-m1
现已可用。
小智 19
$ clang --print-supported-cpus
Apple clang version 12.0.5 (clang-1205.0.22.9)
Target: arm64-apple-darwin20.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
Available CPUs for this target:
a64fx
apple-a10
apple-a11
apple-a12
apple-a13
apple-a14
apple-a7
apple-a8
apple-a9
apple-latest
apple-s4
apple-s5
carmel
cortex-a34
cortex-a35
cortex-a53
cortex-a55
cortex-a57
cortex-a65
cortex-a65ae
cortex-a72
cortex-a73
cortex-a75
cortex-a76
cortex-a76ae
cortex-a77
cortex-a78
cortex-x1
cyclone
exynos-m3
exynos-m4
exynos-m5
falkor
generic
kryo
lightning
neoverse-e1
neoverse-n1
saphira
thunderx
thunderx2t99
thunderx3t110
thunderxt81
thunderxt83
thunderxt88
tsv110
vortex
Run Code Online (Sandbox Code Playgroud)
-mcpu=apple-a14
可能是 M1 的最佳选择。
据我所知,这不是Apple M1
特定的,它也发生在其他各种架构(主要是其他各种 arm 处理器)的 clang 中。例如,在此处查看此错误报告https://github.com/DMOJ/judge-server/issues/303
基本上,新架构的每个 clang 构建都必须选择为编译器构建或不构建的目标提供“march=native”的默认值;如果没有,您将看到此错误消息。即使对于那些确实有优化目标的 arm 处理器,您通常也必须专门使用“-mcpu=xxx”而不是“-march”。
例如,对于您将使用的 iphone-mcpu=apple-a11
-mcpu=apple-a12
等。
但是目前还没有实现这样的目标 Apple M1