Using Ninja with nvcc_wrapper re-compiles sources every time
Created by: bradking
Discussion in #261 found the problem can be reproduced with stock CMake and Ninja, so I'm starting a new issue for it since it is independent of the custom (Fortran-supporting) CMake and Ninja versions reported there. Here are steps to reproduce on Linux:
$ export PATH=/path/to/Trilinos/packages/kokkos/config:$PATH
$ export OMPI_CC=gcc-4.9
$ export OMPI_CXX=nvcc_wrapper
$ export NVCC_WRAPPER_DEFAULT_COMPILER=g++-4.9
$ export CC=mpicc CXX=mpicxx
$ mpicxx -showme:version
mpicxx: Open MPI 1.10.2 (Language: C++)
$ nvcc --version
...
Cuda compilation tools, release 7.0, V7.0.27
$ cmake --version
cmake version 3.5.2
$ (cd ../Trilinos; git rev-parse HEAD)
9289740d06a6b708e9fc75cad9e2b71615e6dd66
$ cmake ../Trilinos -GNinja -DTrilinos_ENABLE_Fortran=OFF -DTrilinos_ENABLE_Gtest=ON -DTPL_ENABLE_Matio=OFF
$ ninja commonTools/gtest/CMakeFiles/gtest.dir/gtest/gtest-all.cc.o
[1/1] Building CXX object commonTools/gtest/CMakeFiles/gtest.dir/gtest/gtest-all.cc.o
$ ninja -t deps commonTools/gtest/CMakeFiles/gtest.dir/gtest/gtest-all.cc.o
commonTools/gtest/CMakeFiles/gtest.dir/gtest/gtest-all.cc.o: #deps 1, deps mtime 1461877501 (VALID)
/tmp/tmpxft_00003d40_00000000-14_gtest-all.ii
$ ninja -d explain commonTools/gtest/CMakeFiles/gtest.dir/gtest/gtest-all.cc.o
$ ninja -d explain commonTools/gtest/CMakeFiles/gtest.dir/gtest/gtest-all.cc.o
ninja explain: output /tmp/tmpxft_00003d40_00000000-14_gtest-all.ii of phony edge with no inputs doesn't exist
ninja explain: /tmp/tmpxft_00003d40_00000000-14_gtest-all.ii is dirty
[1/1] Building CXX object commonTools/gtest/CMakeFiles/gtest.dir/gtest/gtest-all.cc.o
The compiler wrappers somehow use a temporary already-preprocessed .ii
file as input to the g++-4.9
call. This causes the -MD
option to generate a depfile listing only the temporary file. Ninja records this dependency and then cannot find it on the next build.
Tasks: