转帖:Linux Kernel: Speed Up Compilation
来源:互联网 发布:国际纵队知乎 编辑:程序博客网 时间:2024/05/02 07:05
Linux Kernel: Speed Up Compilation
I have been having a hard time for the last few days in doing my"Linux Kernel Assignment". No, programming is not the hardest part.Waiting for the kernel to compile is the main problem. Its patheticallythe moment when you become the sitting duck. :). So here are some ofthe things I came across to speed up the compilation.
- Make sure you have
ccache
installed and configured. As the name suggests,ccache
dramatically speeds up subsequent compilations by caching the objectfiles. In most new Fedora distros, its enabled by default. You cancheck it by doing$which gcc
. If it says something like/usr/lib/ccache/gcc
, you are all set up. If not, try google, :)
You can see see its status by issuing command$ccache -s
. Its good to set the cache amount a bigger than default, so$ccache -M 2G
will set the cache to 2GB which is enough for everyone. - Use
gcc
option-pipe
whenever possible. Self explanatory, it uses pipes instead of temporary files. - Ifyou have dual core or quad core processor and a lot of RAM, you'llnotice that while compiling, only a fraction of your processor and RAMgets used. This is because there is only one compile process running ata time. You can specify multiple
make
jobs by passing parameter like this$make -j 2
.Here, make will run at most 2 jobs at a time, taking full advantage ofyour multi-core CPU and RAM. Some argue on setting higher value, but Ido not recommend it, as it likely to have negative effect because ofthe large amount of context switched in the CPU. People say that thisapproach leads to race conditions but I haven't bumped into any of thatyet. - For Linux Kernel compilation, make sure you have
CONFIG_DEBUG_KERNEL
unset in.config
file. If set, this builds your kernel with debugging symbol making yourkernel a lot bigger and significantly longer to build. It will makekernel debugging impossible though, but when you are in a hurry, thisreally makes more sense. Also strip the.config
file fromany unnecessary drivers/modules you don't require, but this willrequire you to have a thorough knowledge about both your PC and runningkernel. - For those with high speed network (ethernet or more), give a try to
distcc
,that distributes the compilation among multiple machine. Theconfiguration is quite straight forward. Check the references sectionfor details. - Try
tmpfs
. It enables you to mountany folder in your file system in RAM, so theoretically speeding up thecompilation. Try mounting your build folder withtmpfs
like this$sudo mount -t tmpfs -o size=500M,mode=0777 tmpfs /usr/src/linux-build
.
Usingthe above mentioned method, you can get a clean build of 2.6.29 kernelin less than 15 minutes. Let me know if you have any problems or comeup with any better solutions. :)
References:
https://help.ubuntu.com/community/Kernel/Compile
http://www.linux.org/docs/ldp/howto/Modules/speedup.html
http://en.gentoo-wiki.com/wiki/Portage_TMPDIR_on_tmpfs
http://www.ibm.com/developerworks/linux/library/l-distcc.html
- 转帖:Linux Kernel: Speed Up Compilation
- Linux kernel compilation steps
- Linux Kernel Compilation
- How to use CCache to speed up cocos2d-x android compilation
- How to use CCache to speed up cocos2d-x android compilation
- Speed Up your Hard Disk on Linux
- Compilation of Android kernel
- Speed up Eclipse
- Speed up resilver
- Kernel Compilation& Avoiding ‘Unresolved Symbol’
- SURF: speed up robust feature
- Speed up your PC -- win7
- Speed Up Octopress with InstantClick
- Vagrant speed up for windows
- speed up performance of python
- Speed up Booting Embedded System
- Speed up your Android UI
- 11 Tips To Speed Up Computers Running Ubuntu 12.10/12.04/Linux Mint 13 (Maya)
- Windows下重叠I/O模型(转)
- 在莱康的这段日子
- 悟透JavaScript
- 小于连连看游戏说明
- SQL、Linux 脚本与 Ruby 之比较
- 转帖:Linux Kernel: Speed Up Compilation
- C#多线程学习(三) 生产者和消费者
- Tomcat6.0虚拟目录配置
- 从ruleset中删除一个rule.
- .NET 应用webservices的实现全国各地省市县的选择....
- 学习学习
- MFC中动态创建一个控件
- 美化Ubuntu桌面——苹果
- Tomcat5.0(如何修改默认的ROOT路径)