Build race
Another chapter in the parable of Writing Makefiles Is Hard, Don't Do It:
/builds/engineering/yocto/meta-arm/work/build/tmp/work/cortexa35-poky-linux-musl/external-system/0.1.0+gitAUTOINC+8c9dca74b1-r0/git/product/corstone-1000/firmware/config_log.c:13:10: error: /builds/engineering/yocto/meta-arm/work/build/tmp/work/cortexa35-poky-linux-musl/external-system/0.1.0+gitAUTOINC+8c9dca74b1-r0/build/product/corstone-1000/firmware/fwk_module_idx.h is shorter than expected [-Werror]
13 | #include <fwk_module_idx.h>
| ^~~~~~~~~~~~~~~~~~
[GEN] /builds/engineering/yocto/meta-arm/work/build/tmp/work/cortexa35-poky-linux-musl/external-system/0.1.0+gitAUTOINC+8c9dca74b1-r0/build/product/corstone-1000/firmware/fwk_module_idx.h...
[GEN] /builds/engineering/yocto/meta-arm/work/build/tmp/work/cortexa35-poky-linux-musl/external-system/0.1.0+gitAUTOINC+8c9dca74b1-r0/build/product/corstone-1000/firmware/fwk_module_idx.h...
In file included from /builds/engineering/yocto/meta-arm/work/build/tmp/work/cortexa35-poky-linux-musl/external-system/0.1.0+gitAUTOINC+8c9dca74b1-r0/git/framework/include/fwk_event.h:16,
from /builds/engineering/yocto/meta-arm/work/build/tmp/work/cortexa35-poky-linux-musl/external-system/0.1.0+gitAUTOINC+8c9dca74b1-r0/git/framework/include/fwk_module.h:17,
from /builds/engineering/yocto/meta-arm/work/build/tmp/work/cortexa35-poky-linux-musl/external-system/0.1.0+gitAUTOINC+8c9dca74b1-r0/git/product/corstone-1000/firmware/config_log.c:12:
/builds/engineering/yocto/meta-arm/work/build/tmp/work/cortexa35-poky-linux-musl/external-system/0.1.0+gitAUTOINC+8c9dca74b1-r0/git/product/corstone-1000/firmware/config_log.c:48:33: error: 'FWK_MODULE_IDX_PL011' undeclared here (not in a function)
48 | .device_id = FWK_ID_ELEMENT(FWK_MODULE_IDX_PL011, 0),
| ^~~~~~~~~~~~~~~~~~~~
/builds/engineering/yocto/meta-arm/work/build/tmp/work/cortexa35-poky-linux-musl/external-system/0.1.0+gitAUTOINC+8c9dca74b1-r0/git/framework/include/fwk_id.h:154:27: note: in definition of macro 'FWK_ID_ELEMENT_INIT'
154 | .module_idx = MODULE_IDX, \
| ^~~~~~~~~~
/builds/engineering/yocto/meta-arm/work/build/tmp/work/cortexa35-poky-linux-musl/external-system/0.1.0+gitAUTOINC+8c9dca74b1-r0/git/product/corstone-1000/firmware/config_log.c:48:18: note: in expansion of macro 'FWK_ID_ELEMENT'
48 | .device_id = FWK_ID_ELEMENT(FWK_MODULE_IDX_PL011, 0),
| ^~~~~~~~~~~~~~
The compiler is reading the generated fwk_module_idx.h
at the same time as gen_module_code.py
is writing it, with the predictable problem.
The underlying issue is that the gen_module
target is .PHONY
so will re-run every time it is referenced in the Makefiles. In this failed build log it had been ran six times so far. One solution would be to rewrite the Makefiles so targets which generate files (such as gen_module
) are not phony. The easier workaround is to simply atomically write the files.
I've already fixed this problem twice in the past and both times the easy workaround was accepted instead of rewriting the Makefiles to not have ordering bugs. For example, scp-firmware: https://github.com/ARM-software/SCP-firmware/commit/34e1c04534607f5605255f39fb46e26261fc9c4e.