<html>
  <head>
    <meta content="text/html; charset=gbk" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    On 4/11/12 8:25 PM, 15102925731 wrote:
    <blockquote
      cite="mid:4f9b730e.2280a.136a427ad44.Coremail.zhenkaixd@126.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html; charset=gbk">
      <div style="line-height: 1.7; color: rgb(0, 0, 0); font-size:
        14px; font-family: arial;">Yeah, but I tried that command and
        error message was generated:<br>
        <br>
        hellomodule.c:1:10: fatal error: 'linux/init.h' file not found<br>
        #include <linux/init.h><br>
                 ^<br>
        1 error generated.<br>
        <br>
        how to solve this problem??<br>
      </div>
    </blockquote>
    <br>
    Well, you do have to include all the -I and -D options so that clang
    can find the Linux kernel header files.  I don't know off hand what
    those specific options are, but the easiest thing to do is to build
    the kernel, grab the gcc command line that compiles your .c file to
    a .o file, and then replace gcc with clang and add the -emit-llvm
    option to the command line.<br>
    <br>
    -- John T.<br>
    <br>
    <blockquote
      cite="mid:4f9b730e.2280a.136a427ad44.Coremail.zhenkaixd@126.com"
      type="cite">
      <div
        style="line-height:1.7;color:#000000;font-size:14px;font-family:arial"><br>
        Thanks!<br>
        <br>
        <div>--<br>
          <div>
            <div>
              <div><font color="#c0c0c0" size="2">
                  <div><font color="#c0c0c0"><font size="3">  <span
                          style="COLOR: #000000">          ×£ºÃ£¡</span></font></font></div>
                  <span style="COLOR: #000000">
                    <div> </div>
                    <div><font size="3">  Õç¿­</font></div>
                    <div>
                      <div><font color="#c0c0c0"><font size="3">------------------------------------------------------------------------------------------------------</font></font></div>
                    </div>
                    <div><font color="#c0c0c0"><font size="3">2012-04-12</font></font></div>
                  </span></font></div>
              <div><font color="#c0c0c0"><font size="3">------------------------------------------------------------------------------------------------------</font></font></div>
              <div><font color="#c0c0c0"><font size="3">Name:
                    Õç¿­(ZhenKai)<br>
                    Homepage:<a class="moz-txt-link-freetext" href="http://www.renren.com/262729393">http://www.renren.com/262729393</a></font></font></div>
              <div><font color="#c0c0c0"><font size="3">Email: </font><a
                    moz-do-not-send="true"
                    href="mailto:zhenkaixd@126.com" target="_blank"
                    _listener="1901"><font color="#0066cc" size="3">zhenkaixd@126.com</font></a><font
                    size="3"> or <a moz-do-not-send="true"
                      href="mailto:846227103@qq.com">846227103@qq.com</a></font></font></div>
              <div><font color="#c0c0c0" size="3">TEL:
                  15810729006(Beijing)<br>
                  Address: Room I-406, Central Building, Tsinghua
                  University, Beijing, China. 100084.</font></div>
            </div>
          </div>
        </div>
        <br>
        At 2012-04-11
        23:48:07,"John Criswell" <a class="moz-txt-link-rfc2396E" href="mailto:criswell@illinois.edu"><criswell@illinois.edu></a> wrote:<br>
        <blockquote id="isReplyContent" style="PADDING-LEFT: 1ex;
          MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"> On
          4/10/12 10:11 PM, 15102925731 wrote:
          <blockquote
            cite="mid:17dd7b99.6c38.1369f62c87a.Coremail.zhenkaixd@126.com"
            type="cite">
            <div style="line-height: 1.7; color: rgb(0, 0, 0);
              font-size: 14px; font-family: arial;">It's actually is .c
              file. <br>
              I just want firstly to compile helloworldmodule.c into
              helloworldmodule.bc.<br>
              Then I run a LLVM pass on it to do some optimization, and
              then I compile the modified .bc file into .ko file.<br>
              <br>
               So, could you tell me how to compile helloworldmodule.c
              into helloworldmodule.bc? I think it's not the same
              command <b>"clang -O3 -emit-llvm hello.c -c -o hello.bc".
              </b>Because it is a device driver that will be at last
              compiled to be .ko file.<br>
            </div>
          </blockquote>
          <br>
          No, that's exactly how you would do it, although you might
          need to use GCC + Dragonegg instead of clang because the Linux
          3.0 kernel doesn't compile with Clang out-of-the-box (at least
          for me, anyway).<br>
          <br>
          -- John T.<br>
          <br>
          <blockquote
            cite="mid:17dd7b99.6c38.1369f62c87a.Coremail.zhenkaixd@126.com"
            type="cite">
            <div
              style="line-height:1.7;color:#000000;font-size:14px;font-family:arial"><br>
              Thank you!<br>
              <br>
              <div>--<br>
                <div>
                  <div>
                    <div><font color="#c0c0c0" size="2">
                        <div><font color="#c0c0c0"><font size="3">  <span
                                style="COLOR: #000000">          ×£ºÃ£¡</span></font></font></div>
                        <span style="COLOR: #000000">
                          <div> </div>
                          <div><font size="3">  Õç¿­</font></div>
                          <div>
                            <div><font color="#c0c0c0"><font size="3">------------------------------------------------------------------------------------------------------</font></font></div>
                          </div>
                          <div><font color="#c0c0c0"><font size="3">2012-04-11</font></font></div>
                        </span></font></div>
                    <div><font color="#c0c0c0"><font size="3">------------------------------------------------------------------------------------------------------</font></font></div>
                    <div><font color="#c0c0c0"><font size="3">Name:
                          Õç¿­(ZhenKai)<br>
                          Homepage:<a moz-do-not-send="true"
                            class="moz-txt-link-freetext"
                            href="http://www.renren.com/262729393">http://www.renren.com/262729393</a></font></font></div>
                    <div><font color="#c0c0c0"><font size="3">Email: </font><a
                          moz-do-not-send="true"
                          href="mailto:zhenkaixd@126.com"
                          target="_blank" _listener="1901"><font
                            color="#0066cc" size="3">zhenkaixd@126.com</font></a><font
                          size="3"> or <a moz-do-not-send="true"
                            href="mailto:846227103@qq.com">846227103@qq.com</a></font></font></div>
                    <div><font color="#c0c0c0" size="3">TEL:
                        15810729006(Beijing)<br>
                        Address: Room I-406, Central Building, Tsinghua
                        University, Beijing, China. 100084.</font></div>
                  </div>
                </div>
              </div>
              <br>
              ÔÚ 2012-04-11 09:56:21£¬"Justin Holewinski" <a
                moz-do-not-send="true" class="moz-txt-link-rfc2396E"
                href="mailto:justin.holewinski@gmail.com"><justin.holewinski@gmail.com></a>
              Ð´µÀ£º<br>
              <blockquote id="isReplyContent" style="PADDING-LEFT: 1ex;
                MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><br>
                <div class="gmail_quote">2012/4/10 15102925731 <span
                    dir="ltr"><<a moz-do-not-send="true"
                      href="mailto:zhenkaixd@126.com">zhenkaixd@126.com</a>></span><br>
                  <blockquote class="gmail_quote" style="margin:0 0 0
                    .8ex;border-left:1px #ccc solid;padding-left:1ex">
                    <div
                      style="line-height:1.7;font-size:14px;font-family:arial"> Hi,

                      my friends<br>
                      <br>
                      <br>
                      I know there is a difference between compiling a
                      linux module and a simple helloworld programme.<br>
                      If I compile a helloworld.c file, the command is <br>
                      <b>"clang -O3 -emit-llvm hello.c -c -o hello.bc"</b><br>
                      But what the command should be if I want to
                      compile a linux module into a .bc file? (I know it
                      may be an easy question to you guys, but I really
                      don't know where to find the answer on <a
                        moz-do-not-send="true" href="http://llvm.org"
                        target="_blank">llvm.org</a>.)<br>
                    </div>
                  </blockquote>
                  <div><br>
                  </div>
                  <div>What do you mean by linux module?  A shared
                    library (.so)? A kernel module (.ko)?</div>
                  <div> </div>
                  <blockquote class="gmail_quote" style="margin:0 0 0
                    .8ex;border-left:1px #ccc solid;padding-left:1ex">
                    <div
                      style="line-height:1.7;font-size:14px;font-family:arial"><br>
                      Thank you!<br>
                      <br>
                      <br>
                      <br>
                      <br>
                      <div>--<br>
                        <div>
                          <div>
                            <div><font color="#c0c0c0">
                                <div><font color="#c0c0c0"><font
                                      size="3">  <span style="">         
                                        ×£ºÃ£¡</span></font></font></div>
                                <span style="">
                                  <div> </div>
                                  <div><font size="3">  Õç¿­</font></div>
                                  <div>
                                    <div><font color="#c0c0c0"><font
                                          size="3">------------------------------------------------------------------------------------------------------</font></font></div>
                                  </div>
                                  <div><font color="#c0c0c0"><font
                                        size="3">2012-04-11</font></font></div>
                                </span></font></div>
                            <div><font color="#c0c0c0"><font size="3">------------------------------------------------------------------------------------------------------</font></font></div>
                            <div><font color="#c0c0c0"><font size="3">Name:

                                  Õç¿­(ZhenKai)<br>
                                  Homepage:<a moz-do-not-send="true"
                                    href="http://www.renren.com/262729393"
                                    target="_blank">http://www.renren.com/262729393</a></font></font></div>
                            <div><font color="#c0c0c0"><font size="3">Email: </font><a
                                  moz-do-not-send="true"
                                  href="mailto:zhenkaixd@126.com"
                                  target="_blank"><font color="#0066cc"
                                    size="3">zhenkaixd@126.com</font></a><font
                                  size="3"> or <a
                                    moz-do-not-send="true"
                                    href="mailto:846227103@qq.com"
                                    target="_blank">846227103@qq.com</a></font></font></div>
                            <div><font color="#c0c0c0" size="3">TEL:
                                15810729006(Beijing)<br>
                                Address: Room I-406, Central Building,
                                Tsinghua University, Beijing, China.
                                100084.</font></div>
                          </div>
                        </div>
                      </div>
                    </div>
                    <br>
                    <br>
                    <span title="neteasefooter"><span></span></span><br>
                    _______________________________________________<br>
                    LLVM Developers mailing list<br>
                    <a moz-do-not-send="true"
                      href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>
                            <a moz-do-not-send="true"
                      href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
                    <a moz-do-not-send="true"
                      href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev"
                      target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
                    <br>
                  </blockquote>
                </div>
                <br>
                <br clear="all">
                <div><br>
                </div>
                -- <br>
                <br>
                <div>Thanks,</div>
                <div><br>
                </div>
                <div>Justin Holewinski</div>
                <br>
              </blockquote>
            </div>
            <br>
            <br>
            <span title="neteasefooter"><span id="netease_mail_footer"></span></span><br>
            <fieldset class="mimeAttachmentHeader"></fieldset>
            <br>
            <pre wrap="">_______________________________________________
LLVM Developers mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre>
          </blockquote>
          <br>
        </blockquote>
      </div>
      <br>
      <br>
      <span title="neteasefooter"><span id="netease_mail_footer"></span></span>
    </blockquote>
    <br>
  </body>
</html>