On Fri, Jun 07, 2019 at 12:58:33PM -0400, Derrick McKee wrote: > Hi all, > > Now that the kernel can be built with clang, I'd like to implement a > new build target to generate LLVM bytecode for all C source files > involved for a specific build configuration. I am thinking that this > should be very simple if I know the make variables that captures the > needed information. Specifically, I think I just need to perform the > following command for all C files: > > clang -emit-llvm -c <appropriate CFLAGS and include paths> <source > file> -o <corresponding object file location>.bc > > My problem is that I don't know how to get the info in the brackets, > but I am thinking that I should make a new build target `bytecode`. > Any help would be appreciated. Thanks. I know this isn't exactly what you're asking for, but one way to get kernel object files as bitcode is to add -save-temps=obj to KCFLAGS. That gives you bitcode for each object file, and you can pull them together into a single object using llvm-link. Note that at least when I was experimenting with this, I also needed to turn off some warnings, because setting -save-temps=obj changes the way that clang builds the objects. In particular, I needed to set -Wno-constant-logical-operand -Wno-parentheses-equality -Wno-pointer-bool-conversion -Wno-self-assign > > Derrick McKee