[cfe-dev] how to generate both IR and object file

James Courtier-Dutton james.dutton at gmail.com
Sun Jun 22 00:58:34 PDT 2014


On 19 June 2014 21:38, Jinwook Shin <Jinwook.Shin at microsoft.com> wrote:
> Hi,
>
> I use the -emit-llvm flag to generate IR files and use LTO to link them together to produce the final executable. Sometimes LTO gives me link-time errors, so I want to avoid using it, yet I need IR files.
>
> Question: Is there a way to instruct clang to generate *both* an IR file and a regular object file at compile-time, and during the link time, use the object files only, while leaving out the IR files?
>
> Thanks,
> JS
>

Surely you can just change the way the Makefile behaves to do what you want.
At the moment you have:
compile dependencies:
.c/.cpp -> .bc   (clang)
link dependencies for LTO:
Many .bc -> big .so or .a or exe

Change this to:
compile dependencies
.c/.cpp -> .bc    (with clang)
.bc -> .o    (with llc)
link dependencies:
many .o -> big .so or .a or exe

A normal compiler would do this:
compile dependencies
.c/.cpp -> .o    (with clang)
link dependencies:
many .o -> big .so or .a or exe

So, you are breaking the compile dependencies into two.



More information about the cfe-dev mailing list