<div dir="ltr">Hello all,<br><br>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<br><blockquote>-Wl,-plugin-opt=also-emit-llvm<br></blockquote>which causes clang to output an llvm file when linking. For some cases, if I take that file (say, program.bc) and run <br><br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">
clang $CFLAGS $LDFLAGS program.bc -o program<br></blockquote><div> <br></div><div>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?<br>
<br></div><div>Thanks,<br></div><div>Jeremy<br></div></div>