我正在嘗試爲我們的Xcode交叉編譯設置配置項。交叉編譯測試ARMv7和ARMv8。事情看起來當談到時間鏈接以ARMv8除了良好:Apple Clang在Xcdoe 10下是否缺少針對ARMv8/Aarch64的CRC32?
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;所有ARMv8/Aarch64機器都具有CRC-32和CRC-32C;所有ARMv8/Aarch64機器都具有CRC-32和CRC-32C;但Crypto擴展是可選的。錯誤沒有多大意義。
Apple Clang在Xcode 10下是否缺少針對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
謝謝@beshio。 *「爲避免崩潰,因此需要進行某種運行時檢查......」 - 請參閱[如何確定iOS上運行時的ARMv8功能?](https://stackoverflow.com/q/45637888/ 608639) – jww
@jww,感謝您的信息。我會檢查鏈接並研究它。 – beshio