This is an archive of the discontinued LLVM Phabricator instance.

[docs] PCH usage documentation update
ClosedPublic

Authored by ivanmurashko on Apr 30 2022, 1:49 PM.

Details

Summary

The documentation has an incorrect example of PCH files usage via -include option. The possibility has not been available since llvm-svn: 174385.

Diff Detail

Event Timeline

ivanmurashko created this revision.Apr 30 2022, 1:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 30 2022, 1:49 PM
ivanmurashko requested review of this revision.Apr 30 2022, 1:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 30 2022, 1:49 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Minor changes at the doc

ivanmurashko retitled this revision from [clang,doc] PCH usage documentation update to [docs] PCH usage documentation update.
aaron.ballman accepted this revision.May 2 2022, 6:04 AM

LGTM, thanks for improving the docs!

This revision is now accepted and ready to land.May 2 2022, 6:04 AM

Some clarifications for the direct include example were added

This revision was landed with ongoing or failed builds.May 3 2022, 12:27 AM
This revision was automatically updated to reflect the committed changes.
tahonermann reopened this revision.May 4 2022, 1:48 PM
tahonermann added a subscriber: tahonermann.

Reopening for further discussion or clarification.

The changes appear to suggest that a PCH file won't be implicitly used when an explicit include for the corresponding header is made via the -include option, but that is not correct.

$ cat t.h
const int i = 0;
$ cat t.c
int g = i;
$ clang t.h
$ ls -1
t.c
t.h
t.h.gch
$ clang -c -I. -include t.h t.c
$ touch t.h
$ clang -c -I. -include t.h t.c
fatal error: file '/iusers/thonerma/tmp/pch/t.h' has been modified since the precompiled header 't.h.gch' was built: mtime changed
note: please rebuild precompiled header 't.h.gch'
1 error generated.

If the ability to include a PCH file via -include is intentional behavior (as I have always believed it to be), then I think the documentation should demonstrate both the -include and -include-pch methods of using a PCH file.

Please note that gcc also supports implicit use of a PCH file via its -include option.

This revision is now accepted and ready to land.May 4 2022, 1:48 PM
tahonermann closed this revision.May 6 2022, 1:44 PM

Re-closing since this review has already landed.

@akyrtzi, did you see my last comment? If I don't hear back from you, I'll submit a new doc change that covers both forms of PCH use.