Closed daydayup40 closed 6 years ago
(Copied from the email I sent to you)
As of now, most part of the Linux kernel has built-in support for being compiled with LLVM by just adding CC=clang before make.
For details, check https://lkml.org/lkml/2017/11/22/943 and https://lwn.net/Articles/734071/ for the latest progress.
There are also wrappers that help you with the process, for example, https://github.com/ramosian-glider/clang-kernel-build (There are many on GitHub).
The very old schooled way (not sure whether it is still working now) is via the LLVMLinux proeject (https://wiki.linuxfoundation.org/llvmlinux).
Thanks for your detail and early reply. I have follwed a tutorial to build a linux kernel like https://github.com/ramosian-glider/clang-kernel-build, but I cannot find any IR files(.bc and .ll) for analyze. I used make CC=$CLANG_PATH/clang CFLAG="-emit-llvm -c" command, but still not generate IR files. Could you tell me how did you generate the IR files(.bc and .ll) for analyze?
How to use clang to complie linux kernel into LLVM IR?