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
Thu Jun 5 12:05:27 UTC 2014


The same problem exists on linux, so here is a diff for both bsd and linux:

$ hg qdiff
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:
diff --git a/make/linux/makefiles/vm.make b/make/linux/makefiles/vm.make
--- a/make/linux/makefiles/vm.make
+++ b/make/linux/makefiles/vm.make
@@ -290,6 +290,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:




On 5 jun 2014, at 13:52, Staffan Larsen <staffan.larsen at oracle.com> wrote:

> 
> On 5 jun 2014, at 13:38, David Holmes <david.holmes at oracle.com> wrote:
> 
>> On 4/06/2014 11:54 PM, Staffan Larsen wrote:
>>> 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.
>> 
>> You mean clang reports an error when regenerating the pch file? That seems like a bug to me.
> 
> Yes. It also deletes the files, so rerunning the same command again succeeds...
> 
>> 
>> Deleting the file first seems quite reasonable.
> 
> Thanks.
> 
> /Staffan
> 
>> 
>> Thanks,
>> David
>> 
>>> 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