加速 GNU make 构建过程 - 并行性?
我经常构建一个巨大的项目,即使配置了预编译头,也需要很长时间(超过一小时)才能完成。他们是否有任何指导方针或技巧允许 make 并行工作(例如在后台启动 gcc,...等)以允许更快的构建?
注意:源代码和二进制文件太大,无法放置在 ram 文件系统中,而且我不想更改目录结构或构建原理。
I build a huge project frequently and this takes long time (more than one hour) to finish even after configuring pre-compiled headers. Are their any guidelines or tricks to allow make work in parallel (e.g. starting gcc in background, ...etc) to allow for faster builds?
Note: Sources and binaries are too large in size to be placed in a ram file system and I don't want to change the directory structure or build philosophy.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
你可以尝试
You can try
由于大多数机器都是多核的,因此 make -jN 是必须的。如果你不想每次都写
-jN
,你可以放入你的
.bashrc
。您可能还想查看 distcc。
make -jN
is a must now that most machines are multi-core. If you don't want to write-jN
each time, you can putin your
.bashrc
.You may also want to checkout distcc.
如果您的项目太大,一台机器无法处理,您可以使用分布式 make 替代品之一,例如 电云。
If your project is becoming too big for one machine to handle, you can use one of the distributed make replacements, such as Electric Cloud.
如果您想并行运行构建,则
可以完成这项工作,但请记住:
N
应等于您的计算机支持的最大线程数
,如果您输入大于该数字,make
会自动生成N=您的机器支持的最大线程数
make
不支持使用进行并行构建-jN
在MSDOS
中,它只是进行串行构建。如果您指定 -jN
,则会降级N=1
。从
make
源代码中了解更多信息:http://cmdlinelinux.blogspot.com/2014/04/parallel-build-using-gnu-make-j.htmlIf you want to run your build in parallel,
does the job, but keep in mind:
N
should be equal to themaximum number of threads your machine supports
, if you enter a number greater than that,make
automatically makesN=maximum number of threads your machine supports
make
doesn't support parallel build using-jN
inMSDOS
, it just does a serial build. If you specify -jN
, it will downgradeN=1
.Read more here, from the
make
source: http://cmdlinelinux.blogspot.com/2014/04/parallel-build-using-gnu-make-j.html