This is an archive of the discontinued LLVM Phabricator instance.

[clang] add -fmodule-file-home-is-cwd
ClosedPublic

Authored by rmaz on May 3 2022, 1:51 PM.

Details

Summary

This diff adds a new frontend flag -fmodule-file-home-is-cwd.
The behavior of this flag is similar to
-fmodule-map-file-home-is-cwd but does not require the module
map files to be modified to have inputs relative to the cwd.
Instead the output modules will have their BaseDirectory set
to the cwd and will try and resolve paths relative to that.

The motiviation for this change is to support relocatable pcm
files that are built on different machines with different paths
without having to alter module map files, which is sometimes not
possible as they are provided by 3rd parties.

Diff Detail

Event Timeline

rmaz created this revision.May 3 2022, 1:51 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 3 2022, 1:51 PM
rmaz requested review of this revision.May 3 2022, 1:51 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 3 2022, 1:51 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
rmaz updated this revision to Diff 427034.May 4 2022, 9:00 AM

Use regex for path separators in test

rmaz updated this revision to Diff 427065.May 4 2022, 10:31 AM

fix windows paths attempt #2

urnathan added inline comments.May 9 2022, 5:35 AM
clang/lib/Serialization/ASTWriter.cpp
1231–1236

This looks unfortunately duplicatey. Any less-worse way of avoiding that?

rmaz added inline comments.May 9 2022, 7:19 AM
clang/lib/Serialization/ASTWriter.cpp
1231–1236

It could be moved into the else clause at the cost of complicating the if statement with another case and adding another nested if. I thought it was simpler like this, but can change if you prefer.

urnathan added inline comments.May 10 2022, 6:12 AM
clang/lib/Serialization/ASTWriter.cpp
1231–1236

IMHO it would be simpler to remove the duplication. It'd make it clearer one's essentially doing the same thing with CWD as with Directory, (modulo the conditional bit just below).

code bloat make compiler slow :)

rmaz updated this revision to Diff 428483.May 10 2022, 1:27 PM

Refactor branch into existing case

rmaz marked an inline comment as done.May 10 2022, 1:30 PM
urnathan accepted this revision.May 11 2022, 6:11 AM

thanks!

This revision is now accepted and ready to land.May 11 2022, 6:11 AM
This revision was automatically updated to reflect the committed changes.