[LLVMdev] A new mechanism to compiler kernel modules using llvm: Defer type evaluation in clang?

James Courtier-Dutton james.dutton at gmail.com
Mon Apr 29 09:46:05 PDT 2013


I sounds me that you are just substituting "compile C source file" for
"compile LLVM IR source file" or "compile LLVM IR .o file"
The problem is you wish to link in the linux kernel headers at "install" time.
The problem I see is that the linux kernel headers are C source files,
so how is that going to work?
You need a C compiler to understand the Linux kernel headers.


On 28 April 2013 17:42, Jovi Zhang <bookjovi at gmail.com> wrote:
> Hi,
>
> First of all, I didn't study on compiler too much, I'm a Linux kernel developer,
> Now I have one idea about compile kernel module by using llvm framework.
>
> In Linux world, traditionally compile Linux kernel module only have one way:
> compile it to machine code directly, deploy to target machine, then
> run it in target machine.
>
> This have some problem from long term view, especially kernel module
> compatibility issue,
> we know that Linux kernel change fast, when kernel change the data
> structure exposed to external
> kernel modules, then all ko depend on that data structure will need
> recompile, one case is
> kernel upgrade.
> This is really a problem, we already suffered it many years, in whole
> Linux world.
> Linux distribution suffer it, third party kernel modules developers suffer it.
> hardware driver developers also suffer it, we cannot avoid re-compile
> kernel modules whenever new kernel
> release if the structure changed, why? because kernel modules depend
> on kernel header data structure, this is the point.
>
> Is there have any method to fix it? let's try to decouple kernel
> modules with kernel, by using llvm.
> Please give comments on following mechanism, 3 steps:
>
> 1) kernel modules developer compile C file into high level IR, not to
> machine code.
>
> 2) In install time, the high level IR file "link" with kernel header
> data structure file, generate  low level
> IR file, it could be .bc or .ll file in llvm form.
>
> 3) llvm compile the low level IR file into machine code in target
> machine, then insert kernel modules, run it.
>
> Using this method, kernel module code is not need to change when
> kernel header file change, because it evaluate
> structure type info at install time, not C code compile time. it fix
> compatibility  issue in a clean way.
> The key point of this method is we need defer structure type
> evaluation into install time, Is Clang support
> this "feature" at present?
>
> How about this idea sounds? I really think llvm design is nature to
> suit this idea, benefit from llvm's IR.
> If we really implement this idea, it would be very valuable for whole
> Linux community, trust me:)
>
> I would appreciate if you can give me some technical comments on this design.
> Thanks very much.
>
> .jovi
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev



More information about the llvm-dev mailing list