Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
338 views
in Technique[技术] by (71.8m points)

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?

question from:https://stackoverflow.com/questions/32755775/how-to-check-a-static-library-is-built-contain-bitcode

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

As it was alread written in other answers,

otool -l yourlib.a | grep __LLVM

is the way to go.

An Apple engineer says using

otool -l yourlib.a | grep bitcode

is not reliable.

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.

See also the comments by xCocoa.

It seems, that otool does not report the bitcode if code for the iPhone Simulator's architecture is included (x86_64 or i386).

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...