[LLVMdev] Continuing compilation from output of -flto -Wl, -plugin-opt=also-emit-llvm

Jeremy Salwen jeremysalwen at gmail.com
Thu Jul 3 10:27:29 PDT 2014


Hello all,

I have  a program that compiles correctly with clang with link-time
optimization enabled.  What I would like to do is save the llvm bitcode of
the program, and then later compile that bitcode into a (hopefully
equivalent) executable.  Some helpful folks on IRC pointed out the option

-Wl,-plugin-opt=also-emit-llvm

which causes clang to output an llvm file when linking.  For some cases, if
I take that file (say, program.bc)  and run

clang $CFLAGS $LDFLAGS program.bc -o program
>

it will generate an executable, and the executable will do the same thing
as if I compiled the program normally.  However, in some cases it will give
an error about invalid linkage type for global variable, or it will
compile, but then segfault when I try to run it.  Is there something I'm
missing?  what would be the proper way to compile this bitcode file?

Thanks,
Jeremy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140703/30515a91/attachment.html>


More information about the llvm-dev mailing list