Reputation: 35
I am tring to build linux kernel using clang/llvm. I am trying to save the .bc file while generating the .o file . I find LLVM have the API "writebitcodetofile" whcich can save the bc code to certain file, but I am not sure how to use it.
Upvotes: 0
Views: 905
Reputation: 4117
There is a number of flags that can do that for you:
-flto
enables Link-time optimization, which uses LLVM bitcode. In this case (almost) all the .o
files will in fact contain the bitcode.-save-temps
tells clang to put the results of each intermediate phase into a separate file. Simple clang -save-temps main.c
may output main.o
, main.bc
, main.i
, main.s
, or object file, bitcode file, preprocessed file, and assembly file, respectively.-fembed-bitcode
tells clang to include the bitcode representation of a file into the resulting object file. You can learn more about this here: https://jonasdevlieghere.com/libebc-ebcutil/Note, however, that you won't get bitcode for assembly files.
Upvotes: 1