-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[clang][deps] Add module map describing compiled module to file dependencies. #160226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
vsapsai
wants to merge
9
commits into
llvm:main
Choose a base branch
from
vsapsai:add-extra-modulemap-to-file-dependencies
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
46288ff
[clang][deps] Add module map describing compiled module to file depen…
vsapsai 377a157
Merge branch 'main' into add-extra-modulemap-to-file-dependencies
vsapsai 3902244
Address PR comments: move module map dependency reporting to `ModuleD…
vsapsai f2e0215
Add a test case showing that `FileEntryRef::getName` doesn't work som…
vsapsai e0643f7
Switch `getName` to `getNameAsRequested`.
vsapsai b9928d7
Attempt to handle back slashes on Windows.
vsapsai 8af54e0
Merge branch 'main' into add-extra-modulemap-to-file-dependencies
vsapsai 7cd357d
Merge branch 'main' into add-extra-modulemap-to-file-dependencies
vsapsai bbfebe5
Try a different approach to handle backslash.
vsapsai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
clang/test/ClangScanDeps/modules-current-modulemap-file-dep.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// RUN: rm -rf %t | ||
// RUN: split-file %s %t | ||
|
||
// RUN: sed -e "s|DIR|%/t|g" %t/vfs.yaml.in > %t/vfs.yaml | ||
|
||
// RUN: clang-scan-deps -format experimental-full -j 1 -- \ | ||
// RUN: %clang -ivfsoverlay %t/vfs.yaml -fmodules -fimplicit-module-maps \ | ||
// RUN: -fmodules-cache-path=%t/cache -fmodule-name=ModuleName \ | ||
// RUN: -I %/t/remapped -c %t/header-impl.c -o %t/header-impl.o \ | ||
// RUN: | FileCheck %s -DPREFIX=%/t | ||
|
||
// CHECK: "command-line": [ | ||
// CHECK: "-fmodule-map-file=[[PREFIX]]/remapped/module.modulemap" | ||
// CHECK: "file-deps": [ | ||
// CHECK: "[[PREFIX]]/remapped/module.modulemap" | ||
|
||
//--- vfs.yaml.in | ||
{ | ||
"version": 0, | ||
"case-sensitive": "false", | ||
"roots": [ | ||
{ | ||
"name": "DIR/remapped", | ||
"type": "directory", | ||
"contents": [ | ||
{ | ||
"name": "module.modulemap", | ||
"type": "file", | ||
"external-contents": "DIR/original/module.modulemap" | ||
}, | ||
{ | ||
"name": "header.h", | ||
"type": "file", | ||
"external-contents": "DIR/original/header.h" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
|
||
//--- original/module.modulemap | ||
module ModuleName { | ||
header "header.h" | ||
export * | ||
} | ||
|
||
//--- original/header.h | ||
int foo_function(void); | ||
|
||
//--- header-impl.c | ||
#include <header.h> | ||
|
||
int foo_function(void) { | ||
return 0; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With
->getName()
I haveThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The failure is expected. The
"file-deps"
field is intended for consumption by tools that might not understand Clang's virtual filesystem overlays, so the only thing they can reason about is the on-disk path for files ("external-contents"
in the VFS overlay file). That's of course different from what we put on the command-line for Clang itself, as Ben explained above.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's take a step back. What use cases do you have for "file-deps"? Because I've realized that for reproducers I'm not interested in the output paths to process them somehow. Actually, I want to take the paths and provide them to the compiler as the input.
I'm considering if we should have 2 flavours of file dependencies - one before all the file system remappings and one after clang applied the remappings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The build system uses file-deps to check their modification time during incremental builds and figure out what needs to be recompiled.
What do you mean by input and output paths? All file dependencies are inputs currently.
How do you plan to feed the list of files to the compiler?