[LLVMdev] HELP: Clang options needed in command to compile device driver into linux module.

15102925731 zhenkaixd at 126.com
Thu Apr 12 00:48:29 PDT 2012


BTW,  the Makefile is as folllow,

CC := gcc
obj-m := hellomodule.o
KERNELDIR := /lib/modules/`uname -r`/build
PWD := $(shell pwd)
modules:
    $(MAKE) -C $(KERNELDIR) M=$(PWD) modules

Can I use an option of clang to specify the KERNELDIR ,etc?
Thank you!


--

            祝好!
 
  甄凯
------------------------------------------------------------------------------------------------------
2012-04-12
------------------------------------------------------------------------------------------------------
Name: 甄凯(ZhenKai)
Homepage:http://www.renren.com/262729393
Email: zhenkaixd at 126.com or 846227103 at qq.com
TEL: 15810729006(Beijing)
Address: Room I-406, Central Building, Tsinghua University, Beijing, China. 100084.

At 2012-04-12 15:05:17,15102925731 <zhenkaixd at 126.com> wrote:

Wow that's to much output information.

Maybe I can put it in this way. Could you tell me the clang option that can include the linux kernel headers???
Something like
 "clang -O3 -isystem /lib/modules/`uname -r`/build/include -emit-llvm hellomodule.c -c   -o hellomodule.bc"
Thank you!


--

            祝好!
 
  甄凯
------------------------------------------------------------------------------------------------------
2012-04-12
------------------------------------------------------------------------------------------------------
Name: 甄凯(ZhenKai)
Homepage:http://www.renren.com/262729393
Email: zhenkaixd at 126.com or 846227103 at qq.com
TEL: 15810729006(Beijing)
Address: Room I-406, Central Building, Tsinghua University, Beijing, China. 100084.



At 2012-04-12 14:07:38,"Nick Lewycky" <nicholas at mxc.ca> wrote:
>15102925731 wrote:
>> Hi, Nick
>> I think that's the question. I just don't know what's the command line
>> that can tell clang to find the linux head file like a makefile will do.
>> Please help me!
>
>In the linux kernel, "make V=1" will compile verbosely, printing out 
>each command it runs. Each .o file produced will have its own 
>command-line (many of them will be the same, but you have to make sure 
>you use the right one).
>
>Nick
>
>>
>> --
>> 祝好!
>> 甄凯
>> ------------------------------------------------------------------------------------------------------
>>
>> 2012-04-12
>> ------------------------------------------------------------------------------------------------------
>>
>> Name: 甄凯(ZhenKai)
>> Homepage:http://www.renren.com/262729393
>> Email: zhenkaixd at 126.com <mailto:zhenkaixd at 126.com> or 846227103 at qq.com
>> <mailto:846227103 at qq.com>
>> TEL: 15810729006(Beijing)
>> Address: Room I-406, Central Building, Tsinghua University, Beijing,
>> China. 100084.
>>
>>
>> 在  2012-04-12  12:45:14,"Nick  Lewycky"  <nicholas at mxc.ca>  写道:
>>>15102925731  wrote:
>>>>  Hello,
>>>>
>>>>  What  option  should  be  added  in  the  clang  command  to  compile  linux  device
>>>>  driver(from  .c  to  .bc)?
>>>>  Typically  we  need  a  makefile  to  compile  a  module.  But  I  just  want  a
>>>>  simple  command  line.
>>>
>>>Make,  using  the  information  in  the  Makefile,  runs  gcc  or  clang  with  a
>>>long  command  line.  That  command  line  tells  gcc/clang  how  to  do  things,
>>>like  where  to  find  linux/init.h  or  how  certain  macros  are  to  be  defined.
>>>
>>>It  doesn't  matter  whether  you  run  clang  from  the  makefile  or  not,  but
>>>you  will  need  the  correct  command  line  for  it  to  work.  What  command  line
>>>does  make  run  gcc  with?
>>>
>>>Nick
>>>
>>>>
>>>>  I  tried  *"clang  -O3  -emit-llvm  hello.c  -c  -o  hello.bc  "*  but  errors
>>>>  occurred  saying
>>>>  fatal  error:  'linux/init.h'  file  not  found
>>>>  #include  <linux/init.h>
>>>>  ^
>>>>  1  error  generated
>>>>  Then  I  was  taught  to  add  -D  or  -I  option  so  that  clang  can  find  the
>>>>  linux  kernel  head  file.  But  I  still  dont  know
>>>>  how  exactly  the  command  like......All  I  want  to  know  is  a  clang  command
>>>>  line  that  can  compile  a  helloworldmodule.c  into  helloworldmodule.bc.
>>>>
>>>>  Please  give  me  some  suggestion.
>>>>  Any  help  would  be  appreciated!
>>>>
>>>>  --
>>>>  祝好!
>>>>  甄凯
>>>>  ------------------------------------------------------------------------------------------------------
>>>>
>>>>  2012-04-12
>>>>  ------------------------------------------------------------------------------------------------------
>>>>
>>>>  Name:  甄凯(ZhenKai)
>>>>  Homepage:http://www.renren.com/262729393
>>>>  Email:  zhenkaixd at 126.com  <mailto:zhenkaixd at 126.com>  or  846227103 at qq.com
>>>>  <mailto:846227103 at qq.com>
>>>>  TEL:  15810729006(Beijing)
>>>>  Address:  Room  I-406,  Central  Building,  Tsinghua  University,  Beijing,
>>>>  China.  100084.
>>>>
>>>>
>>>>
>>>>
>>>>  _______________________________________________
>>>>  LLVM  Developers  mailing  list
>>>>  LLVMdev at cs.uiuc.edu                  http://llvm.cs.uiuc.edu
>>>>  http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>>>
>>
>>
>>
>



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120412/6a063b7c/attachment.html>


More information about the llvm-dev mailing list