‹ BackHN Continuity

Thread

Recursive `make` and `-j`

33 points · 14 comments · ibobev

  1. fragmede · · focus · HN ↗
    Don't do it!

    <a href="https:&#x2F;&#x2F;accu.org&#x2F;journals&#x2F;overload&#x2F;14&#x2F;71&#x2F;miller_2004&#x2F;" rel="nofollow">https:&#x2F;&#x2F;accu.org&#x2F;journals&#x2F;overload&#x2F;14&#x2F;71&#x2F;miller_2004&#x2F;

    Recursive Make Considered Harmful

    By Peter Miller

    1. theamk · · focus · HN ↗
      Disagree on main premise of that.

      If you have sub-projects which cross-depend on each other (no total ordering), then recursive make will have a bad time. I agree.

      Author thinks the best way is to stop doing recursive make. I disagree.

      IMHO, the best way to solve this is to arrange your sub-projects properly, so the are no circular dependencies and thus there is one correct order. Not only your build should be a DAG on file level, it should also be a DAG on the sub-project&#x2F;directory level. Then a single recursive &quot;make&quot; pass builds everything properly, no need for ugly tricks like running make twice, or intentionally omitting some dependencies.

      (Even better option is to stop using make for such large projects - it&#x27;s great for smaller ones, but for the huge ones, there are much better runners available. But I assume there is some reason to use make)

      1. entrope · · focus · HN ↗
        Having a clean DAG still breaks down with recursive Make: if binary X depends on library A, then X&#x27;s Makefile either has a rule to recurse to A (and then parallel builds of A might happen, even when building from the top level, unless you use -j1) or it doesn&#x27;t (and then you can only build from the top level Makefile and you might give up parallelism due to granularity of the top-level DAG).

        At the time that essay was written, Make was the best runner available, and the only portable one. There are better options now.

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.