Race condition bug in meson build
We have a regular build failure on the Windows build, with the following error:
[60/2051] Generating gimp-plug-ins.rc with a custom command
FAILED: plug-ins/file-jpeg/build_windows_gimp-plug-ins.rc_gimp-plug-ins.o
/usr/bin/x86_64-w64-mingw32-windres --define 'ORIGINALFILENAME_STR="file-jpeg.exe"' --define 'INTERNALNAME_STR="file-jpeg"' --define 'TOP_SRCDIR="/builds/GNOME/gimp"' -I./. -I../. -I./app -I../app build/windows/gimp-plug-ins.rc plug-ins/file-jpeg/build_windows_gimp-plug-ins.rc_gimp-plug-ins.o --preprocessor-arg=-MD --preprocessor-arg=-MQplug-ins/file-jpeg/build_windows_gimp-plug-ins.rc_gimp-plug-ins.o --preprocessor-arg=-MFplug-ins/file-jpeg/build_windows_gimp-plug-ins.rc_gimp-plug-ins.o.d
build/windows/gimp-plug-ins.rc:2:10: fatal error: git-version.h: No such file or directory
2 | #include "git-version.h"
| ^~~~~~~~~~~~~~~
compilation terminated.
/usr/bin/x86_64-w64-mingw32-windres: preprocessing failed.
This is a race condition because meson does not have generic order dependency, which explains why the error is random. It has dependency support on many specific commands, but not on generic ones. In particular configure_file()
does not have dependency support, yet gimp-plug-ins.rc
is generated with this function while it includes git-version.h
which is also a generated file.
Most often, git-version.h
is luckily generated before any of the usages (35 usages!) of gimp-plug-ins.rc
, but sometimes it isn't. This is when the build fails.
We can probably find some complicated (hence bug-prone) solution by tweaking and working around issues, but the real solution would be to have a meson function adding generic order dependency. This is why I am discussing on this request: https://github.com/mesonbuild/meson/issues/8123