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

Sandeep K Chaudhary babbusandy2006 at gmail.com
Tue May 27 14:04:30 PDT 2014


Thank you so much for the reply, Tim ! I have some follow up questions
(in the inline replies), it would be great if you can answer those.

On Tue, May 27, 2014 at 1:36 PM, Tim Northover <t.p.northover at gmail.com> wrote:
> 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).

Does it mean that I need to give -flto option for compilation while
building the libraries that I am using i.e. lttng-ust and libdl?

>
> 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.

So, does it mean adding -flto option in each build step? Can you
please explain this a bit? I mean - how to set up such a parallel set
of builds in my case?

>
> 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*).

Yeah, getting the bit-code for just one file is straight forward as
you mentioned. :)

>
> Cheers.
>
> Tim.

-- 
Thanks and regards,
Sandeep K Chaudhary.



More information about the llvm-dev mailing list