Serialize game and test build to ease pressure on RAM, especially in CI #73793
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
None
Purpose of change
Some chatter on discord brought some build failures like https://github.com/CleverRaven/Cataclysm-DDA/actions/runs/9078930225/job/24950004752#step:14:746 to my attention, looks like memory exhaustion?
Describe the solution
This adds an "ordering only" dependency on the test executable to new clones of the test and check targets in the makefile, along with an option to enable this behavior.
The effect of this is the test part of the build will not start until the game executable is fully linked, which should ease our memory pressure, ESPECIALLY if the test builds are flying through compilation due to high ccache hit rates and it starts linking the test exe befire the link of the game exe is done.
Describe alternatives you've considered
There are a number of options, potentially splitting the test exe into several pieces could work to limit the peak amount of rAM usage on each link job.
It's possible that building a .so of the game code instead of a .a would reduce the overhead of the test link job?
As for how to structure this feature, it's not TOTALLY necessary to add this to the Makefile, you can invoke it like make -j X bla bla bla cataclysm && make -j X bla bla tests, and you can do that locally or in the tests
I'm not totally against doing it this way, but right now I really want to get some idea of whether this will fix the problem at all.
Testing
The acid test will be if the GCC 9 LTO job passes, but also it might need several runs because I don't know what the pass rate recently is.
Additional context
I've been seeing this a lot on my local system as well, if I end up linking the game and test exe at the same time my computer locks up, this is why I'm working this into the Makefile instead of just editing the gha_compile_only.sh to do the build in stages.