RFR: 8044797 Building with clang gives: fatal error: file '...' has been modified since the precompiled header was built

Staffan Larsen staffan.larsen at oracle.com
Wed Jun 4 13:54:39 UTC 2014


When building with clang and changing a file that is part of the precompiled header, you can get:

fatal error: file '/Users/staffan/mercurial/jdk9-hs-rt/hotspot/src/share/vm/runtime/thread.hpp' has been modified since the precompiled header was built

clang behaves differently than gcc here.

Example with clang:

$ ls
test.h
$ cat test.h
#include <stdio.h>
$ clang -x c-header -include test.h test.h -o test.h.pch
$ touch test.h
$ clang -x c-header -include test.h test.h -o test.h.pch
fatal error: file '/Users/staffan/tmp/pch/test.h' has been modified since the precompiled header was built
1 error generated.

Same with gcc:

$ ls
test.h
$ cat test.h
#include <stdio.h>
$ gcc -x c-header -include test.h test.h -o test.h.pch
$ touch test.h
$ gcc -x c-header -include test.h test.h -o test.h.pch


The proposed fix is to delete the .pch file before calling clang or gcc.

diff --git a/make/bsd/makefiles/vm.make b/make/bsd/makefiles/vm.make
--- a/make/bsd/makefiles/vm.make
+++ b/make/bsd/makefiles/vm.make
@@ -295,6 +295,7 @@
 $(PRECOMPILED_HEADER):
 	$(QUIETLY) echo Generating precompiled header $@
 	$(QUIETLY) mkdir -p $(PRECOMPILED_HEADER_DIR)
+	$(QUIETLY) rm -f $@
 	$(QUIETLY) $(COMPILE.CXX) $(DEPFLAGS) -x c++-header $(PRECOMPILED_HEADER_SRC) -o $@ $(COMPILE_DONE)

 # making the library:


Thanks,
/Staffan


More information about the hotspot-dev mailing list