On Wed, Jul 06, 2022 at 10:57:53AM +0000, Zhihao Lin wrote:
> Hello, I'm trying to build the kernel using LLVM and generate LLVM IR.
> In the makefile, I saw there is a target "dir/file.ll" provided.
> However, I want to add more attributes to the IR file generated, such
> as adding debug information. Is there any way to generate personalized
> IR by either modifying the Makefile or changing Makefile variables?
You can add additional flags to the "dir/file.ll" compiler invocation
with the KCFLAGS make variable:
$ make KCFLAGS="-ffoo -Wfoo" dir/file.ll
Additionally, there are kernel configurations, such as CONFIG_DEBUG_INFO
or CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT (depending on the kernel
version you are working against), which will add the compiler arguments
to generate debug info.
If you have any further questions, feel free to let us know! I have
added our new mailing list (ll...@lists.linux.dev
) to the thread so it
can be archived at https://lore.kernel.org/llvm
for future travellers,
please use that list if you start any new threads in the future :)