[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Are prerequisites made in deterministic order when parallelism is di
Re: Are prerequisites made in deterministic order when parallelism is disabled?
Wed, 14 Jun 2017 09:36:51 -0500
On Wed, Jun 14, 2017 at 2:00 AM, Edward Welbourne
> Brett Stahlman (13 June 2017 17:33)
>> I don't see anything in the Make docs that guarantees prerequisites
>> will be processed in left to right order. Opinions on the web seems to
>> be split into 2 camps:
>> 1. Make always builds dependencies in left to right order, but a
>> well-designed Makefile won't rely upon it.
>> 2. Make is free to build dependencies in any order it likes, provided
>> it respects the stated dependencies.
>> My own recent experience suggests #2 is the correct statement, but I
>> can't rule out the possibility that a bug in my Makefile is producing
>> the apparent non-determinism I'm observing. At any rate, can anyone
>> point me to a definitive source on this?
> I suspect most implementations of make do in fact build in left-to-right
> order but none guarantee it; and I won't be surprised if GNU make used
> to but has lately stopped doing so, although I can't give you a
> definitive source either way. I certainly wouldn't ever assume
> deterministic build order; if one prerequisite needs to be built before
> another, the make-file should express that via a dependency (perhaps
> just an order-only one).
Makes sense. I saw it suggested somewhere that Make has to perform a
complex, inherently unstable, topological sort, which may make it
difficult to preserve left to right order. By experimentation, I
discovered that the order seemed to be affected by the actual target
names: e.g., names such as "foo" and "foo22222" produced left to right
order, whereas "foo2" did not. For the vast majority of target names
tried, the order was strictly left to right.