[LLVMdev] Getting LLVM bit-code for programs using a couple of libraries

Tim Northover t.p.northover at gmail.com
Tue May 27 10:36:16 PDT 2014


Hi Sandeep,

On 27 May 2014 02:58, Sandeep K Chaudhary <babbusandy2006 at gmail.com> wrote:
> My aim is to get the bitcode for these programs but if I try to
> generate the bitcode with -emit-llvm option, it produces linking
> issues as follows : (also at - http://pastebin.com/zkmL2SAH)

You shouldn't really expect "-emit-llvm" to work well with an existing
build system. That flag means the normal .o files produced by clang
will be LLVM bitcode *instead* of ELF (or whatever). This happens to
be the norm with "-flto" compilations, but that needs a compatible
linker and really it needs clang to know that's what it's doing (i.e.
-flto at *all* stages of compilation).

If you just want the LLVM IR for a reasonably large project, you
should probably setup a parallel set of "build" steps that produce the
IR but aren't involved in the actual compilation.

Mostly I find I want it just for one file occasionally. So I just
copy/paste the command-line and add -emit-llvm manually (usually with
"-S -o-" because I want to see it *now*).

Cheers.

Tim.



More information about the llvm-dev mailing list