Ninja: 3.27 regresses Fortran module dependencies with parallel execution
I have tried to compile xtb project [https://github.com/grimme-lab/xtb]. Unfortunately, there still are issues with compilation after !8974 (merged) which was included into cmake 3.28.0-rc5.
Steps to reproduce (will use GCC):
wget https://github.com/Kitware/CMake/releases/download/v3.28.0-rc5/cmake-3.28.0-rc5-linux-x86_64.sh
wget https://github.com/grimme-lab/xtb/archive/refs/tags/v6.6.1.tar.gz
bash cmake-3.28.0-rc5-linux-x86_64.sh --skip-license
tar -xzvf v6.6.1.tar.gz
cd xtb-6.6.1
../bin/cmake -G"Ninja" -Bbuild -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_Fortran_COMPILER=gfortran
ninja -C build
Note, in my case, ninja runs ~100 command simultaneously.
With 3.28.0-rc4, cmake was failed on configure stage. Now, with 3.28.0-rc5, compilation fails due to improper dependency list, so one will receive messages like:
xtb/src/prog/argparser.f90:20:8:
20 | use xtb_mctc_accuracy, only : wp
| 1
Fatal Error: Cannot open module file 'xtb_mctc_accuracy.mod' for reading at (1): No such file or directory
Re-running ninja in parallel mode multiple times leads to success compilation. Like:
for i in `seq 1 100`
do
ninja -C build
done
Running ninja in single thread mode compiles xtb project successfully from the first run.
I failed to create a minimal reproducible example to notice such behaviour not in a real project.