This is an archive of the discontinued LLVM Phabricator instance.

[PCH] Disable inclusion of timestamps when generating pch files on windows.
AbandonedPublic

Authored by pgousseau on May 13 2016, 9:11 AM.

Details

Reviewers
rsmith
Summary

On Linux, if a header file included in the pch is modified then a fatal error is emitted, which is reasonable.
On Windows the check is ifdefed out, allowing the compilation to continue in a broken state.
This leads to "#pragma once" directives to be ignored.
This change disables the inclusion of timestamps in pch files on Windows, for now.

Diff Detail

Event Timeline

pgousseau updated this revision to Diff 57202.May 13 2016, 9:11 AM
pgousseau retitled this revision from to [PCH] Disable inclusion of timestamps when generating pch files on windows..
pgousseau updated this object.
pgousseau added a reviewer: rsmith.
pgousseau added a subscriber: cfe-commits.

Please make sure the test files have newlines at the end.
"touch-pragma-once.cpp" should probably be named something like "pragma-once-timestamp.cpp".

Please make sure the test files have newlines at the end.
"touch-pragma-once.cpp" should probably be named something like "pragma-once-timestamp.cpp".

Will fix thanks!

pgousseau updated this revision to Diff 57324.May 16 2016, 2:21 AM

Add newlines and change test's name following Paul's comments.

This is fine as far as I'm concerned, but I think somebody more familiar with the area ought to chime in.

I've seen rare cases where parses using the PCH files were yielding completely invalid data, almost as if they were corrupted. I wonder now if this could be the cause. (We're on Windows too.)

thakis added a subscriber: wristow.May 18 2016, 2:59 PM
thakis added a subscriber: thakis.

Did you see http://reviews.llvm.org/D19815 ? Does that help? Warren might have opinions on this.

Did you see http://reviews.llvm.org/D19815 ? Does that help? Warren might have opinions on this.

Yes, these are definitely related. Fixing that other problem does not also fix the issue here, however the fix here will only work if that other fix is also applied.

In my view, that other issue is a fairly overt bug (PR24387) where #pragma once is blatantly ignored in a header-file processed for creating a PCH. That can result in incorrect behavior, and always results in a misleading/confusing warning. That issue also is independent of the host environment.

Whereas the timestamp issue described here is much more subtle, and it only impacts Windows hosts (due to some problem with the timestamps on the Windows file system).

Essentially, the proposed fix here is blocked by that other issue. I should have realized and commented here earlier. Thanks for bringing it to my attention.

Did you see http://reviews.llvm.org/D19815 ? Does that help? Warren might have opinions on this.

Yes thanks, I agree with Warren, this is a separate issue.
In the test I am adding I avoid the issue that Warren's review is for by only using '#pragma once' in a sub header of the PCH.

bruno added a subscriber: bruno.May 23 2016, 1:53 PM

Hi Pierre,

test/PCH/pragma-once-timestamp.cpp
18

Can you move this to the beginning of the file? It makes it easier to spot that this is windows only.

Hm, the ASTReader code this works around is over 6 years old (r100866). Maybe we could try enabling the access time check instead?

pgousseau updated this revision to Diff 58207.May 24 2016, 1:50 AM

Moving REQUIRE line higher following Bruno's comments.

Hm, the ASTReader code this works around is over 6 years old (r100866). Maybe we could try enabling the access time check instead?

Yes the issue described in ASTReader lacks a reproducible so it makes sense to tentatively re-enabling the timestamp check on windows. If the issue still occurs on some bots then at least we can document the issue better before re-disabling it.

I also would like to provide a switch to disable inclusion of timestamps. I will hopefully be proposing a patch for it soon.