如何检查静态库是否包含位代码? [英] How to check a static library is built contain bitcode?
问题描述
我有一个由其他公司构建的静态库。我想知道它是否是一个包含位代码的静态库,哪个命令可以在终端中检测到它?
I have a static library that is built by other company. I want to know if it's a static library containing bitcode, which command can detect it in terminal?
推荐答案
在其他答案中,
otool -l yourlib.a | grep __LLVM
是必经之路。
一位苹果工程师说使用
otool -l yourlib.a | grep bitcode
不可靠。
搜索位码部分不是检测文件是否包含嵌入式位码的可靠方法。如果要这样做,请搜索 __LLVM段。您应该意识到,带有-fembed-bitcode-marker选项的常规构建将产生最小尺寸的嵌入式位代码段,而没有任何实际内容。这是一种测试构建中与位码相关的方面的方法,而不会减慢构建过程。进行存档构建时,将包括实际的位码内容。
Searching for a "bitcode" section is not a reliable way to detect if your files contain embedded bitcode. If you want to do that, search for the "__LLVM" segment. You should be aware that a normal build with the -fembed-bitcode-marker option will produce minimal size embedded bitcode sections without any real content. This is done as a way of testing the bitcode-related aspects of your build without slowing down the build process. The actual bitcode content is included when you do an Archive build.
另请参见xCocoa 。
似乎, otool
如果包含了iPhone Simulator的体系结构代码(x86_64或i386),则不会报告该位代码。
It seems, that otool
does not report the bitcode if code for the iPhone Simulator's architecture is included (x86_64 or i386).
您可以使用以下命令列出lib的体系结构:
You can list the lib's architectures with:
lipo -info yourlib.a
然后您可以分别检查每种体系结构的位代码,例如:
Then you can check for bitcode for each architecture separately, e.g:
otool -arch armv7 -l yourlib.a | grep bitcode
otool -arch arm64 -l yourlib.a | grep bitcode
这篇关于如何检查静态库是否包含位代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!