This is an archive of the discontinued LLVM Phabricator instance.

[ASTWriter] Provide capability to output a PCM/PCH file that does not write out information about its output path
ClosedPublic

Authored by akyrtzi on Jul 28 2022, 7:37 AM.

Details

Summary

This is useful to enable sharing of the same PCH file even when it's intended for a different output path.

The only information this option disables writing is for ORIGINAL_PCH_DIR record which is treated as optional and (when present) used as fallback for resolving input file paths relative to it.

Diff Detail

Event Timeline

akyrtzi created this revision.Jul 28 2022, 7:37 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 28 2022, 7:37 AM
akyrtzi requested review of this revision.Jul 28 2022, 7:37 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 28 2022, 7:37 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Is the functionality provided by ORIGINAL_PCH_DIR still useful for making it possible to move a PCH and its referenced headers? It's not completely clear to me when this feature is used in practice. It would be nice to remove it or change the default behaviour if possible, rather than require a new option, but I'm open to this approach if we think we can't change the default.

@v.g.vassilev is the functionality of "write ORIGINAL_PCH_DIR and resolve headers relative to it if PCH file and headers moved together" used by Cling?

akyrtzi added a subscriber: rmaz.Jul 28 2022, 10:49 AM

Also pinging @rmaz who made a related change, is this used by Facebook?

@v.g.vassilev is the functionality of "write ORIGINAL_PCH_DIR and resolve headers relative to it if PCH file and headers moved together" used by Cling?

We currently use -fmodules-embed-all-files which zips all header files in a blob in the PCH/PCM that gives us flexibility to not require the headers to be present at a specific location. We have mostly moved to PCMs and the PCH is of less interest to us. Does that patch help making the implicitly built module files easier to relocate?

@v.g.vassilev is the functionality of "write ORIGINAL_PCH_DIR and resolve headers relative to it if PCH file and headers moved together" used by Cling?

We currently use -fmodules-embed-all-files which zips all header files in a blob in the PCH/PCM that gives us flexibility to not require the headers to be present at a specific location. We have mostly moved to PCMs and the PCH is of less interest to us. Does that patch help making the implicitly built module files easier to relocate?

Not sure whether ORIGINAL_PCH_DIR relates to implicitly built module files or not, I'm wondering whether ORIGINAL_PCH_DIR is still useful and, if I understand correctly, it's not useful for Cling since it embeds the header file contents, right?

akyrtzi updated this revision to Diff 448715.Jul 29 2022, 2:25 PM

Add FIXME comment to consider either removing ORIGINAL_PCH_DIR or changing the default.

Is the functionality provided by ORIGINAL_PCH_DIR still useful for making it possible to move a PCH and its referenced headers? It's not completely clear to me when this feature is used in practice. It would be nice to remove it or change the default behaviour if possible, rather than require a new option, but I'm open to this approach if we think we can't change the default.

Given that there was a recent change related to ORIGINAL_PCH_DIR, I'm reluctant to change the default at this point, I added a FIXME for following up to see if we can remove it or change the default later on.

benlangmuir accepted this revision.Jul 29 2022, 2:45 PM
This revision is now accepted and ready to land.Jul 29 2022, 2:45 PM
rmaz added a comment.Aug 1 2022, 12:19 AM

Is the functionality provided by ORIGINAL_PCH_DIR still useful for making it possible to move a PCH and its referenced headers? It's not completely clear to me when this feature is used in practice. It would be nice to remove it or change the default behaviour if possible, rather than require a new option, but I'm open to this approach if we think we can't change the default.

Given that there was a recent change related to ORIGINAL_PCH_DIR, I'm reluctant to change the default at this point, I added a FIXME for following up to see if we can remove it or change the default later on.

We don't use this functionality, no. My change was made for the same reason: to be able to relocate and cache pcm files when used in conjunction with -fmodule-file-home-is-cwd, removing the field entirely would be preferable from our perspective.