自动为多核计算机设置作业(-j)标志? [英] Automatically setting jobs (-j) flag for a multicore machine?
问题描述
我有一台拥有大量内核的机器上有一个Makefile,但是我似乎总是忘记在编译项目时写-jX
,并且花费的时间比应该的长.
I have a Makefile on a machine that has a ton of cores in it, but I always seem to forget to write -jX
when compiling my project and it takes way longer than it should.
是否可以通过环境变量或其他持久性配置文件设置-j
标志,以便make在该计算机上并行自动执行多个作业?
Is there some way I can set the -j
flag through an environment variable or some other persistent config file so that make will automatically execute multiple jobs in parallel on this machine?
推荐答案
看来,MAKEFLAGS
环境变量可以传递标志,这些标志是每个make
运行的一部分(至少对于GNU make).我本人不太幸运,但是可能可以使用-l
而不是-j
来自动运行尽可能多的,适合您可用核心数量的作业.
It appears that the MAKEFLAGS
environment variable can pass flags that are part of every make
run (at least for GNU make). I haven't had much luck with this myself, but it might be possible to use -l
rather than -j
to automatically run as many jobs as are appropriate for the number of cores you have available.
这篇关于自动为多核计算机设置作业(-j)标志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!