I want clang to compile my C/C++ code to LLVM bitcode rather than a binary executable. How can I achieve that?
And if I have the LLVM bitcode, how can I further compile it to a binary executable?
I want to add some of my own code to the LLVM bitcode before compiling to a binary executable.
Given some C/C++ file
foo.c:Produces
foo.llwhich is an LLVM IR file.The
-emit-llvmoption can also be passed to the compiler front-end directly, and not the driver by means of-cc1:Produces
foo.llwith the IR.-cc1adds some cool options like-ast-print. Check out-cc1 --helpfor more details.To compile LLVM IR further to assembly, use the
llctool:Produces
foo.swith assembly (defaulting to the machine architecture you run it on).llcis one of the LLVM tools – here is its documentation.