[LLVMdev] A new mechanism to compiler kernel modules using llvm: Defer type evaluation in clang?
Joshua Cranmer 🐧
Pidgeot18 at gmail.com
Mon Apr 29 06:21:17 PDT 2013
On 4/29/2013 7:32 AM, Jovi Zhang wrote:
> The case I really want to solve is some kernel change cause ko must
> need to recompile, like data structure field offset changed in new
> kernel, this will make offset mismatch between new kernel and old ko.
> This is the reason why I want to delay type structure evaluation into
> install time in Clang, In theory, ko compiled now could work in 10
> years later whatever how kernel changes.
This kind of fix is not possible with LLVM IR right now and generally
not possible with C code ever unless you make a lot of simplifying
assumptions. Note that, for example, offsetof and sizeof are resolved to
a constant by Clang before they are ever lowered to LLVM IR in the first
place. Also, the way that structs are referenced in LLVM IR do not
satisfy binary compatibility: a struct is lowered to a sequence of its
constituent members accessed by their index and not be a given name.
This means that inserting a member into the struct invalidates the IR.
--
Joshua Cranmer
Thunderbird and DXR developer
Source code archæologist
More information about the llvm-dev
mailing list