0

I have 10 targets in cmake. If i give

  gmake -j4

it is compiling all the targets paralllely. I want all the cores to be work on single target and after finishing that it should go for next target. I know that it can be achieved with adding dependency between targets. but i don't want to do that because sometimes i want to compile only one target. if dependency is there, it will compile all the dependency targets before compiling the required target.

how to make the compilation faster but in the sequential manner ?

  • 2
    "_I want all the cores to be work on single target_" - Are the dependencies for each target split up in smaller parts so that all cores _can_ work torwards building the target in parallel? – Ted Lyngmo Apr 08 '21 at 09:43
  • 2
    A build system just executes commands, specified for targets. According to dependencies between targets, a build system could choose the order of these commands, or choose a processor core for execute a specific command. But a build system is not responsible for consolidate CPUs for execute a single command. E.g. if the command is a compiler invocation, then a build system just invokes the compiler. It is up to the compiler whether it uses several cores or not. – Tsyvarev Apr 08 '21 at 09:58
  • you use make -j4 asking for paralelism and request no paralelism... just use `make` and all will run sequentially. – OznOg Apr 10 '21 at 11:38
  • is it possible to assign 2 or more cores to work on the same target simultaneously? @OznOg – Deepan Muthusamy Apr 12 '21 at 05:38
  • a given target cannot be built simultaneously by different cores, but usually you have many targets to be built, and a dependency tree beteen them. The option -j X tries to build X targets that have all their dependencies ready. If X is 1, then target are built in sequence. – OznOg Apr 12 '21 at 07:34
  • i have a target which does not have dependency on other targets. if i give -j1, it is taking 7 mins to build. if I give -j4, it is taking 2 mins. that means a given target can be built simultaneously by different cores.@OznOg – Deepan Muthusamy Apr 12 '21 at 16:46

0 Answers0