Trigger missing dependencies in (parallel) GNU make by changing order of execution

我们两清 提交于 2019-12-23 17:43:46

问题


Suppose I have a Makefile:

a.out:
    sleep 3
    touch a.out a1

b.out:
    cat a1 > b.out

c.out: a.out b.out
    cat a.out b.out > c.out

make c.out will usually succeed, as the commands for a.out are executed before the commands for b.out. But make b.out will fail (in a clean directory), as will make -j c.out.

As in real-life scenarios there is seldomly a sleep 3 and the bug will thus only show very randomly, I'm looking for a way to smoke out such errors with a higher probability. One idea would be to reverse the order of execution for targets "on the same level": As the test suite will usually trigger first generation of a.out, then b.out, if instead first b.out was generated, the bug would surface.

Is there a way in GNU make to do this?


回答1:


Paul Smith replied on help-make@gnu.org that this is not possible with current GNU make.




回答2:


The single re-ordering of the target dependencies that is most likely to reveal unstated dependencies between the dependencies of a target is the reverse ordering of the target dependencies.

You can achieve the reverse ordering by testing the Makefile with a conditionally executed dependency section such as:

a.out: b.out

For longer dependency lists this would be:

a.out: b.out
b.out: d.out
d.out: e.out
:
:


来源:https://stackoverflow.com/questions/9437459/trigger-missing-dependencies-in-parallel-gnu-make-by-changing-order-of-executi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!