Does monolithic link-time optimization work with static libraries?

429 Views Asked by At

This article discusses how object files can contain LLVM IR that is used for link-time optimization. But what if the linker is compiling a project that includes a static library, do static libraries have the information as well? If so, under which circumstances?

1

There are 1 best solutions below

2
On BEST ANSWER

Yes. Static libraries can contain llvm-IR-bitcode also.

A. Step for build static libs with llvm-IR-bitcode

  1. In Xcode Static Lib Project:
    Build Settings->Enable Bitcode , Switch to Yes
  2. Product->Archive

B. Check if a static lib contains llvm-IR-bitcode or not.

  1. otool -l libDemo.a
  2. In the output, search for __bitcode and check whether the size is bigger than 000001 or not.
    if size > 000001 : then the static lib contain llvm-IR-bitcode
    else: the static lib do not contain llvm-IR-bitcode.

Wish this answers your question.