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

Nick Lewycky nicholas at mxc.ca
Wed Apr 11 23:07:38 PDT 2012


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
>>
>
>
>




More information about the llvm-dev mailing list