[LLVMdev] How to compile this linux-driver like programme into .bc file?

陳韋任 chenwj at iis.sinica.edu.tw
Mon Apr 16 00:35:25 PDT 2012


> The thing is that I know the Makefile to complete that task. But what  I want to know the clang command that can do that. Since the makefile will generate a .ko file while I can use the clang command "-O3-emit-llvm" to generate a corresponding .bc file so the pass can be run on that.

  I guess you can use something like (I am not SURE if Clang support those GCC
flags entirely, try it yourself),

$ clang -O2 -DMODULE -D__KERNEL__ YOUR_MODULE.c \
  -W -Wall -Wstrict-prototypes -Wmissing-prototypes \
  -isystem /lib/modules/`uname -r`/build/include \
  -emit-llvm -o YOUR_MODULE.bc

Regards,
chenwj

-- 
Wei-Ren Chen (陳韋任)
Computer Systems Lab, Institute of Information Science,
Academia Sinica, Taiwan (R.O.C.)
Tel:886-2-2788-3799 #1667
Homepage: http://people.cs.nctu.edu.tw/~chenwj




More information about the llvm-dev mailing list