为什么编译器没有定义 __ARM_FEATURE_CRC32?
问题描述
我已经研究这个问题一段时间了,我希望有人能指出我的错误.我想我再也看不到森林了.
I've been working on this issue for some time now, and I hope someone can point out my mistake. I guess I can no longer see the forest through the trees.
我有一个用于测试的 LeMaker HiKey 开发板.它的 AArch64,因此它具有 NEON 和其他 cpu 功能,如 AES、SHA 和 CRC32:
I have a LeMaker HiKey dev board I use for testing. Its AArch64, so its has NEON and the other cpu features like AES, SHA and CRC32:
当我尝试编译程序时:
结果如下:
文件系统的 grep 显示 arm_acle.h
实际上是标题:
A grep of the file system reveals arm_acle.h
is in fact the header:
根据 ARM® C Language Extensions,第 9.7 节 CRC32 Intrinsics,假设在定义 __ARM_FEATURE_CRC32
时会出现缺失的符号.检查 arm_acle.h
即可确认.
And according to ARM® C Language Extensions, Section 9.7 CRC32 Intrinsics, the missing symbols are suppose be present when __ARM_FEATURE_CRC32
is defined. Inspecting arm_acle.h
confirms it.
为了完整起见,我尝试使用 -march=native
进行编译,但编译器拒绝了它.
For completeness, I tried compiling with -march=native
, but the compiler rejected it.
为什么编译器没有定义__ARM_FEATURE_CRC32
?
Why is __ARM_FEATURE_CRC32
not being defined by the compiler?
我可以做些什么来让程序与板上可用的本机功能一起编译?
What can I do to get the program to compile with the native features available on the board?
<小时>
推荐答案
至于为什么默认不开启这个功能;这是您的编译器所针对的基线 ABI 中不存在的可选功能,即您的编译器生成的二进制文件预计能够在缺少 CRC 功能的设备上运行.
As for why this feature isn't enabled by default; this is an optional feature not present in the baseline ABI that your compiler targets, i.e. the binaries that your compiler produces are expected to be able to run on devices lacking the CRC feature.
至少对于 gcc,你可以使用 -march
修饰符 crc
启用这个功能,像这样:
At least for gcc, you can enable this feature with the -march
modifier crc
, like this:
参见 https://gcc.gnu.org/onlinedocs/gcc-6.1.0/gcc/AArch64-Options.html(或旧 gcc 版本的同一页面)以获取有关如何设置的更多文档.
See https://gcc.gnu.org/onlinedocs/gcc-6.1.0/gcc/AArch64-Options.html (or the same page for older gcc versions) for more docs on how to set this.
我想人们可能希望 -march=native
做同样的事情,但该选项目前似乎只针对 x86 架构实现.
I guess one could expect -march=native
to do the same, but that option currently only seems to be implemented for x86 architectures.
这篇关于为什么编译器没有定义 __ARM_FEATURE_CRC32?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!