Kan Li
Kan Li

Reputation: 8797

llvm and install time optimization

Based on LLVM official page, it is possible to have install-time optimization, based on my understanding, which first compiles to bytecode on build machine before distribution, and then on target machines, converts the bytecode to native code when installing.

Is there any real world example on this feature? More specifically, I am wondering if it is possible to take an arbitrary open source C/C++ project which uses autoconf (i.e. typically built and installed by ./configure && make && make install), and

  1. on build machine, by running ./configure && make in a special way (e.g. setting some environment variables, or even modify the configure.ac or some other autoconf files) so that it generates executable and libraries as byte code;
  2. I transfer the build tree to target machine, and run make install in a special way so that it installs all files as usual, but converts byte code to native code for executable and libraries.

Upvotes: 15

Views: 821

Answers (2)

Colin V.
Colin V.

Reputation: 11

LLVM IR is target independent, meaning that it could be generated on one machine (compile time) and converted to bytecode (link time) on another and it would still generate the same bytecode as it would have on the first machine, provided that you were using the same version of LLVM with the same options. It does not mean that the IR that was generated would produce a valid binary on all machines.

The problem with this lies in the way that the ABI can vary between different systems.

This post addresses those differences in more detail: LLVM bitcode cross-platform

Upvotes: 1

Chandler Carruth
Chandler Carruth

Reputation: 3341

As @delnan indicated, this isn't possible in general. LLVM is a target independent IR, but it is not portable.

There have been a few attempts to construct a portable IR, PNaCl among them, but these are different from LLVM.

Upvotes: 2

Related Questions