2
votes

I have a makefile that has a ton of subsystem and am able to build it with the -j flag so that it goes much faster and builds the different recipes in parallel.

This seems to be working fine for now but am not sure if I am missing some needed dependencies and am just "getting lucky" with the order that these are being built.

Is there a way where I can randomize the order recipes are run while still following all the dependencies that I have defined?

1
GNU make follows all dependencies strictly. It will not build something if all its dependencies are not up to date. - igagis
The only way is to do it yourself in your makefile. Make has no ability to do this. - MadScientist
You could redefine CC, CXX, etc with something like: CC:=sleep $(bc -l <<< "scale=4 ; ${RANDOM}/3276") && gcc, which will randomize build order a bit - blackghost
@igagis I am talking more about the things that dont depend on each other. For example if you have rules A-F and only B depends on C then there could be issues when it runs A C D E F B vs running F A E D C B but when it runs ether way it follows the dependence rules. - Daniel H
@DanielH If there are issues if those are run in wrong order, then you have to specify dependencies so that those are run in correct order. It's a matter of writing your makefile properly. - igagis

1 Answers

1
votes

You can control number of jobs Make is allowed to run asynchronously with -j command line option. This way you can "randomize" recipes being executed simultaneously and catch some issues in your makefiles.