15102925731
2012-Apr-11 03:11 UTC
[LLVMdev] How to compile a linux module into .bc file using clang or llvm command?
It's actually is .c file. I just want firstly to compile helloworldmodule.c into helloworldmodule.bc. Then I run a LLVM pass on it to do some optimization, and then I compile the modified .bc file into .ko file. So, could you tell me how to compile helloworldmodule.c into helloworldmodule.bc? I think it's not the same command "clang -O3 -emit-llvm hello.c -c -o hello.bc". Because it is a device driver that will be at last compiled to be .ko file. Thank you! -- 祝好! 甄凯 ------------------------------------------------------------------------------------------------------ 2012-04-11 ------------------------------------------------------------------------------------------------------ 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. 在 2012-04-11 09:56:21,"Justin Holewinski" <justin.holewinski at gmail.com> 写道: 2012/4/10 15102925731 <zhenkaixd at 126.com> Hi, my friends I know there is a difference between compiling a linux module and a simple helloworld programme. If I compile a helloworld.c file, the command is "clang -O3 -emit-llvm hello.c -c -o hello.bc" 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 llvm.org.) What do you mean by linux module? A shared library (.so)? A kernel module (.ko)? Thank you! -- 祝好! 甄凯 ------------------------------------------------------------------------------------------------------ 2012-04-11 ------------------------------------------------------------------------------------------------------ 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. _______________________________________________ LLVM Developers mailing list LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev -- Thanks, Justin Holewinski -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120411/f6b4cb5f/attachment.html>
John Criswell
2012-Apr-11 15:48 UTC
[LLVMdev] How to compile a linux module into .bc file using clang or llvm command?
On 4/10/12 10:11 PM, 15102925731 wrote:> It's actually is .c file. > I just want firstly to compile helloworldmodule.c into > helloworldmodule.bc. > Then I run a LLVM pass on it to do some optimization, and then I > compile the modified .bc file into .ko file. > > So, could you tell me how to compile helloworldmodule.c into > helloworldmodule.bc? I think it's not the same command *"clang -O3 > -emit-llvm hello.c -c -o hello.bc". *Because it is a device driver > that will be at last compiled to be .ko file.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). -- John T.> > Thank you! > > -- > ??! > ?? > ------------------------------------------------------------------------------------------------------ > 2012-04-11 > ------------------------------------------------------------------------------------------------------ > 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-11 09:56:21,"Justin Holewinski" > <justin.holewinski at gmail.com> ??: > > > 2012/4/10 15102925731 <zhenkaixd at 126.com <mailto:zhenkaixd at 126.com>> > > Hi, my friends > > > I know there is a difference between compiling a linux module > and a simple helloworld programme. > If I compile a helloworld.c file, the command is > *"clang -O3 -emit-llvm hello.c -c -o hello.bc"* > 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 > llvm.org <http://llvm.org>.) > > > What do you mean by linux module? A shared library (.so)? A > kernel module (.ko)? > > > Thank you! > > > > > -- > ??! > ?? > ------------------------------------------------------------------------------------------------------ > 2012-04-11 > ------------------------------------------------------------------------------------------------------ > 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 <mailto:LLVMdev at cs.uiuc.edu> > http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > > > > -- > > Thanks, > > Justin Holewinski > > > > > > _______________________________________________ > 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/20120411/5a81cfa3/attachment.html>
15102925731
2012-Apr-12 01:25 UTC
[LLVMdev] How to compile a linux module into .bc file using clang or llvm command?
Yeah, but I tried that command and error message was generated: hellomodule.c:1:10: fatal error: 'linux/init.h' file not found #include <linux/init.h> ^ 1 error generated. how to solve this problem?? Thanks! -- 祝好! 甄凯 ------------------------------------------------------------------------------------------------------ 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-11 23:48:07,"John Criswell" <criswell at illinois.edu> wrote: On 4/10/12 10:11 PM, 15102925731 wrote: It's actually is .c file. I just want firstly to compile helloworldmodule.c into helloworldmodule.bc. Then I run a LLVM pass on it to do some optimization, and then I compile the modified .bc file into .ko file. So, could you tell me how to compile helloworldmodule.c into helloworldmodule.bc? I think it's not the same command "clang -O3 -emit-llvm hello.c -c -o hello.bc". Because it is a device driver that will be at last compiled to be .ko file. 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). -- John T. Thank you! -- 祝好! 甄凯 ------------------------------------------------------------------------------------------------------ 2012-04-11 ------------------------------------------------------------------------------------------------------ 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. 在 2012-04-11 09:56:21,"Justin Holewinski" <justin.holewinski at gmail.com> 写道: 2012/4/10 15102925731 <zhenkaixd at 126.com> Hi, my friends I know there is a difference between compiling a linux module and a simple helloworld programme. If I compile a helloworld.c file, the command is "clang -O3 -emit-llvm hello.c -c -o hello.bc" 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 llvm.org.) What do you mean by linux module? A shared library (.so)? A kernel module (.ko)? Thank you! -- 祝好! 甄凯 ------------------------------------------------------------------------------------------------------ 2012-04-11 ------------------------------------------------------------------------------------------------------ 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. _______________________________________________ LLVM Developers mailing list LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev -- Thanks, Justin Holewinski _______________________________________________ LLVM Developers mailing list LLVMdev at cs.uiuc.eduhttp://llvm.cs.uiuc.eduhttp://lists.cs.uiuc.edu/mailman/listinfo/llvmdev -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120412/b1ac1a66/attachment.html>
Apparently Analagous Threads
- [LLVMdev] How to compile a linux module into .bc file using clang or llvm command?
- [LLVMdev] How to compile a linux module into .bc file using clang or llvm command?
- [LLVMdev] How to compile a linux module into .bc file using clang or llvm command?
- [LLVMdev] HELP: Clang options needed in command to compile device driver into linux module.
- [LLVMdev] HELP: Clang options needed in command to compile device driver into linux module.