Re: How to compile Linux kernel to llvm bitcodes?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Mar 20, 2023 at 7:14 PM tr4v3ler <0xtr4v3ler@xxxxxxxxx> wrote:
>
> I would like to compile all C files into. ll or. bc to facilitate analyzing the entire kernel.

So there's a make target compile_commands.json. That will give you a
json list of triples that contain the exact command used to compile
the kernel. It's probably 10 lines of python to parse that, then rerun
the exact command used the build each translation unit with -emit-llvm
and -S (or not depending on if you want .ll or .bc).  That will give
you a .ll/.bc for everything that's built as part of your config for
that configuration.

Otherwise, kbuild has rules to do:

$ make LLVM=1 lib/string.ll

There's no support for .bc (would be trivial to add) because you
typically end up running llvm-dis on .bc files to get .ll files
anyways.  I almost never use .bc files.

>
> Nick Desaulniers <ndesaulniers@xxxxxxxxxx> 于 2023年3月21日周二 01:12写道:
>>
>> On Mon, Mar 20, 2023 at 2:53 AM tr4v3ler <0xtr4v3ler@xxxxxxxxx> wrote:
>> >
>> > Hi,I found the following compilation targets in the makefile(https://github.com/torvalds/linux/blob/master/scripts/Makefile.build#L136) of the Linux kernel. However, I don't know how to make this goal effective, compile the Linux kernel, and generate llvm bitcodes. Do I need to specify specific parameters for the make command? Or through environment variables?
>>
>> What precisely are you looking for? A single .ll file? A single .bc
>> file? .ll or .bc files for every translation unit?
>> --
>> Thanks,
>> ~Nick Desaulniers



-- 
Thanks,
~Nick Desaulniers




[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux