问题描述
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 ?
推荐答案
在分布式内存系统上,您可以使用 distcc 将编译作业分发给其他计算机.这需要一些设置,但是如果碰巧有一些额外的机器,它确实可以加快构建速度.
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.
在共享内存多核系统上,您可以仅使用 make -j
,它将尝试根据您的makefile中的依赖项来生成构建作业.您可以这样运行:
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:
$ make -j
这不会对产生的作业数量施加任何限制,或者您可以使用整数参数运行
which will impose no limit on the number of jobs spawned, or you can run with an integer parameter:
$ make -j8
这将限制并发构建作业的数量.在此,限制为8个并发作业.通常,您希望它的数量接近系统上的内核数量.
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.
这篇关于在多核或分布式系统上编译程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!