5 ms·
It exposes bugs in your make rules.
by bicolao 7y ago
It exposes bugs in your make rules.
- IshKebab 7y agoYou mean not using `-j` exposes bugs? Doubtful. If you are missing a dependency edge in your build graph then there are no guarantees that it will cause an issue with or without `-j`. The only way to properly solve missing dependencies is to hide targets unless they are explicitly depended on. The only systems I know that do that are Nix and Bazel (and its clones).
- deleted 7y ago[deleted]
- asveikau 7y agoIf your rules have side-effects that aren't reflected in the dependency part of the declaration but nonetheless depended upon, running the jobs in parallel means the order of execution varies instead of being sequential, so sometimes you may get a file not found on something produced in an earlier rule. If make knows about all the inputs and outputs of every rule, it can make sure dependencies are built before they are used. The problem occurs when the makefile doesn't tell make about every dependency. Also the rule scripts themselves can have race conditions. A trivial example is if they end up using the same temp filename when doing work.
- IshKebab 7y agoYes I know. But the order of execution can vary even if you don't run in parallel. For example if you have two targets, A and B, and B depends on A's output but you forgot to say so, then `make` can build B before A even if you don't use the `-j` option.
- asveikau 7y agoI thought the behavior I have seen is it's always in the order that the targets are specified. So if you have: all: A B Then if both need a rebuild A is always first, except when -j breaks that. But I can't say I have played close attention to every time I have typed make.
- IshKebab 7y agoAh right, but that's just a lucky coincidence. Make is perfectly within its rights to randomise the order of A and B even if you don't specify `-j`. And if you're driving Make from some other system, e.g. CMake, you really have no idea what order stuff is going to end up in the makefiles anyway.
- klyrs 7y agoI prefer processes that expose bugs over those that obscure them...
- jschwartzi 7y agoI've learned over my engineering career to prefer rules which are based on the facts of the situation at hand rather than rules which are applied dogmatically. Dogma is what gave us Chernobyl.