eclipse-omr / omr

Eclipse OMR™ Cross platform components for building reliable, high performance language runtimes
http://www.eclipse.org/omr
Other
950 stars 397 forks source link

Compiler dependency file generation race breaks incremental rebuilds #1739

Open lmaisons opened 7 years ago

lmaisons commented 7 years ago

When we compile cpp files to object files, we also generate a file listing all source and header file dependencies for use by make in incremental rebuilds. Through another mechanism, that dependency file itself is listed as a dependency for compiling the cpp file into an object file.

However, the modification time of the generated dependency file can end up being more recent than the object file, causing it to require a rebuild on the next make. On at least some systems, some files seem to be able to do this consistently:

[lmaisons@statik:~/elf/omr/jitbuilder]$ ls --full-time ../build/compiler/optimizer/LoopVersioner.o*
-rw-r--r-- 1 lmaisons users 3493784 2017-09-27 20:12:46.571947693 +0000 ../build/compiler/optimizer/LoopVersioner.o
-rw-r--r-- 1 lmaisons users   19797 2017-09-27 20:12:46.575281160 +0000 ../build/compiler/optimizer/LoopVersioner.o.depend.mk
[lmaisons@statik:~/elf/omr/jitbuilder]$ make PLATFORM=amd64-linux64-clang BUILD_CONFIG=debug CX_FLAGS_EXTRA='-Wfatal-errors' ../build/compiler/optimizer/LoopVersioner.o
clang++ -std=c++0x -fno-rtti -fno-threadsafe-statics -Wno-deprecated -Wno-enum-compare -Wno-invalid-offsetof -Wno-write-strings  -pthread -fomit-frame-pointer -fasynchronous-unwind-tables -Wreturn-type -fno-dollars-in-identifiers -ggdb3 -Wno-parentheses -Werror=header-guard -Wfatal-errors  -DBITVECTOR_BIT_NUMBERING_MSB -DUT_DIRECT_TRACE_REGISTRATION -DJITTEST -DJITBUILDER_SPECIFIC -DPROD_WITH_ASSUMES -DTR_HOST_X86 -DTR_HOST_64BIT -DBITVECTOR_64BIT -DLINUX -DTR_TARGET_X86 -DTR_TARGET_64BIT -DSUPPORTS_THREAD_LOCAL -D_LONG_LONG -DDEBUG -I'../include_core' -I'../jitbuilder/x/amd64' -I'../jitbuilder/x' -I'../jitbuilder' -I'../compiler/x/amd64' -I'../compiler/x' -I'../compiler' -I'..' -MMD -MF ../build/compiler/optimizer/LoopVersioner.o.depend.mk -MT ../build/compiler/optimizer/LoopVersioner.o -MP -o ../build/compiler/optimizer/LoopVersioner.o -c ../compiler/optimizer/LoopVersioner.cpp
[lmaisons@statik:~/elf/omr/jitbuilder]$ ls --full-time ../build/compiler/optimizer/LoopVersioner.o*
-rw-r--r-- 1 lmaisons users 3493784 2017-09-27 20:14:20.695734301 +0000 ../build/compiler/optimizer/LoopVersioner.o
-rw-r--r-- 1 lmaisons users   19797 2017-09-27 20:14:20.699067768 +0000 ../build/compiler/optimizer/LoopVersioner.o.depend.mk

Any such file will end up always 'requiring' a rebuild on every invocation of make.

lmaisons commented 7 years ago

One potential solution would be to touch the generated object file after compiling as part of the object file generation make recipe. I'm not sure what the implications of this would be though.