gpt4 book ai didi

ios - Clang 是否缺少适用于 ARMv8/Aarch64 的 CRC32?

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:32:09 27 4
gpt4 key购买 nike

我正在尝试为我们的 Xcode 交叉编译设置 CI。交叉编译测试 ARMv7 和 ARMv8。一切看起来都不错,除了链接 ARMv8 的时候:

clang++ -DNDEBUG -g2 -O3 -fPIC -pipe -Wall -miphoneos-version-min=7 -arch arm64 \
-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.2.sdk \
-stdlib=libc++ -c cryptlib.cpp
clang++ -DNDEBUG -g2 -O3 -fPIC -pipe -Wall -miphoneos-version-min=7 -arch arm64 \
-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.2.sdk \
-stdlib=libc++ -c cpu.cpp
...

clang++ -o cryptest.exe -DNDEBUG -g2 -O3 -fPIC -pipe -Wall -miphoneos-version-min=7 -arch arm64 \
-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.2.sdk \
-stdlib=libc++ test.o bench1.o bench2.o ... ./libcryptopp.a

Undefined symbols for architecture arm64:

"CryptoPP::CRC32_Update_ARMV8(unsigned char const*, unsigned long, unsigned int&)", referenced from:

CryptoPP::CRC32::Update(unsigned char const*, unsigned long) in libcryptopp.a(crc.o)

"CryptoPP::CRC32C_Update_ARMV8(unsigned char const*, unsigned long, unsigned int&)", referenced from:

CryptoPP::CRC32C::Update(unsigned char const*, unsigned long) in libcryptopp.a(crc.o)

ld: symbol(s) not found for architecture arm64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

make: *** [cryptest.exe] Error 1

我们显然不运行输出工件 cryptest.exe。我们只是编译和链接来测试东西。

代码在 LLVM Clang 下测试良好。

所有 ARMv8/Aarch64 机器都有 CRC-32 和 CRC-32C;但加密扩展是可选的。该错误没有多大意义。

Clang 是否缺少适用于 ARMv8/Aarch64 的 CRC32?


下面是导致错误的代码。

#if defined(__ARM_FEATURE_CRC32)

void CRC32_Update_ARMV8(const uint8_t *s, size_t n, uint32_t& c)
{
for(; !IsAligned<uint32_t>(s) && n > 0; s++, n--)
c = __crc32b(c, *s);

for(; n > 4; s+=4, n-=4)
c = __crc32w(c, *s);

for(; n > 0; s++, n--)
c = __crc32b(c, *s);
}

#endif

最佳答案

在 Xcode 8.3.3 下,我在 __crc32*() 处遇到了编译错误。然后我添加了命令行开关

-march=armv8-a+crc

this 找到链接,然后代码编译良好。我用 iphone7+/iOS10.3.1 测试过,它可以正常工作。

注意根据ARM's document (“ARM® 架构引用手册ARMv8, for ARMv8-A architecture profile"DDI0487B_a_armv8_arm.pdf: page A1-58), crc32 instructions are optional for v8 and mandatory for v8.1. 当我在 iphone6+/iOS9.3.3 上运行相同的程序时,它在 __crc32* 处崩溃()。我还用内联汇编程序对其进行了验证。因此,为了避免崩溃,需要进行某种运行时检查。我不完全理解如何做,但作为最后的手段,我们可以使用模型名称。

关于ios - Clang 是否缺少适用于 ARMv8/Aarch64 的 CRC32?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45625725/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com