在多核或分布式系统上编译程序
Linux 中是否有可用的软件可以在多核或分布式系统上并行编译包含大量文件的源代码。像 gcc 或 xserver 这样的库在单核/双核机器上编译需要很长时间,并且大多数时候当您需要大量重新编译时会令人沮丧。有没有并行编译此类源代码的技术?
Is there any software available in linux which compiles a source code containing large number of files parallely on either multicore or distributed systems. Libraries like gcc or xserver takes very time for compilation on unicore/dual machine and most of the times it is frustrating when you need lot of recompilation. Is there any technique for compiling such source code parallely ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在分布式内存系统上,您可以使用 distcc 将编译作业外包给其他计算机。这需要一些设置,但如果您碰巧有一些额外的机器,它确实可以加快您的构建速度。
在共享内存多核系统上,您只需使用
make -j
,它将尝试根据 makefile 中的依赖项生成构建作业。您可以像这样运行:这将对生成的作业数量没有限制,或者您可以使用整数参数运行:
这将限制并发构建作业的数量。此处,并发作业的限制为 8 个。通常您希望该值接近系统上的核心数量。
On distributed-memory systems, you can use distcc to farm out compile jobs to other machines. This takes a little bit of setup, but it can really speed up your build if you happen to have some extra machines around.
On shared-memory multicore systems, you can just use
make -j
, which will try to spawn build jobs based on the dependencies in your makefiles. You can run like this:which will impose no limit on the number of jobs spawned, or you can run with an integer parameter:
which will limit the number of concurrent build jobs. Here, the limit is 8 concurrent jobs. Usually you want this to be something close to the number of cores on your system.
ccache 也可以用来加速编译过程
ccache can be used too to speed up compilation process
GNU make(安装在 Linux 系统上的标准 make)支持并行命令执行 - 看看 http://www.gnu.org/software/make/manual/make.html#Parallel
GNU make (the standard make installed on Linux systems) supports parallel command execution - take a look at http://www.gnu.org/software/make/manual/make.html#Parallel