-
Notifications
You must be signed in to change notification settings - Fork 340
[Clang][ScanDeps] Add C API and implement enough to build Foundation. #699
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
[Clang][ScanDeps] Add C API and implement enough to build Foundation. #699
Conversation
@swift-ci please test |
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.
I'm fine with this being on apple/master temporarily, as long as we continue to push forward on getting this reviewed at llvm.org in parallel.
a049f94
to
124c28a
Compare
Test failure was due to non determinism in the output. Fixed by sorting file-deps in the C API. @swift-ci please test |
This adds an experimental C API for clang-scan-deps. It provides both the full module dependency graph along with a flattened list of dependencies. See clang/include/clang-c/Dependencies.h for the API and documentation. You can test it out using: c-index-test core --scan-deps <working-directory> -- clang --cc1 <args> This will output a list of modules and then the direct dependencies of the main translation unit.
This function returns the equivalent of -### <rdar://problem/49928458> <rdar://problem/49396121>
…e-options Removes any arguments before this one that would be incompatible with explicitly building a module. This includes things like -o and input files. This option can be used to append arguments to convert a build of a translation unit with implicit modules into an explicit build of a specific module.
This assert fires for ObjectiveC id, SEL, and Class declarations when the module is explicitly built. For implicit builds it works fine. This reproduces with: typedef struct objc_class Class; struct objc_class; As a module imported into another module, and both the above and that module imported into a third TU. Changing the name (`Class`) or reordering the declarations does not assert. rdar://58552906
Gives the last of -f{no-}implicit-module-maps precedence. rdar://58883354
Building the actual module still fails, but make sure it fails for the right reason.
The `UmbrellaAsWritten` and `NameAsWritten` fields in `clang::Module` are a lie for framework modules. For those they actually are the path to the header or umbrella relative to the `clang::Module::Directory`. The exception to this case is for inferred modules. Here it actually is the name as written, because we print out the module and read it back in when implicitly building modules. This causes a problem when explicitly building an inferred module, as we skip the printing out step. In order to fix this issue this patch adds a new field for the path we want to use in `getInputBufferForModule`. It also makes `NameAsWritten` actually be the name written in the module map file (or that would be, in the case of an inferred module). rdar://58619519
This shows up with inferred modules, but it doesn't exist on disk, so don't report it as a dependency.
124c28a
to
21c4c10
Compare
I was not able to reproduce the previous test failure. Trying again. @swift-ci please test |
I was able to confirm that the failing tests were already failing on master, and aren't related to this change. |
This patch enables explicitly building inferred modules. Effectively a cherry-pick of swiftlang#699 authored by @Bigcheese with libclang and dependency scanner changes omitted. Contains the following changes: 1. [Clang] Fix the header paths in clang::Module for inferred modules. * The UmbrellaAsWritten and NameAsWritten fields in clang::Module are a lie for framework modules. For those they actually are the path to the header or umbrella relative to the clang::Module::Directory. * The exception to this case is for inferred modules. Here it actually is the name as written, because we print out the module and read it back in when implicitly building modules. This causes a problem when explicitly building an inferred module, as we skip the printing out step. * In order to fix this issue this patch adds a new field for the path we want to use in getInputBufferForModule. It also makes NameAsWritten actually be the name written in the module map file (or that would be, in the case of an inferred module). 2. [Clang] Allow explicitly building an inferred module. * Building the actual module still fails, but make sure it fails for the right reason. Split from D100934. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D102491
This patch adds support for inferred modules to the dependency scanner. Effectively a cherry-pick of swiftlang#699 authored by @Bigcheese with libclang and other changes omitted. Contains following changes: 1. [Clang][ScanDeps] Ignore __inferred_module.map dependency. * This shows up with inferred modules, but it doesn't exist on disk, so don't report it as a dependency. 2. [Clang][ScanDeps] Use the module map a module was inferred from for inferred modules. Also includes a smoke test that uses clang-scan-deps output to perform an explicit build. There's no intention to duplicate whatever `test/Modules` contains, just to verify the produced command-line does "work" (with very loose definition of work). Split from D100934. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D102495
This patch enables explicitly building inferred modules. Effectively a cherry-pick of swiftlang/llvm-project#699 authored by @Bigcheese with libclang and dependency scanner changes omitted. Contains the following changes: 1. [Clang] Fix the header paths in clang::Module for inferred modules. * The UmbrellaAsWritten and NameAsWritten fields in clang::Module are a lie for framework modules. For those they actually are the path to the header or umbrella relative to the clang::Module::Directory. * The exception to this case is for inferred modules. Here it actually is the name as written, because we print out the module and read it back in when implicitly building modules. This causes a problem when explicitly building an inferred module, as we skip the printing out step. * In order to fix this issue this patch adds a new field for the path we want to use in getInputBufferForModule. It also makes NameAsWritten actually be the name written in the module map file (or that would be, in the case of an inferred module). 2. [Clang] Allow explicitly building an inferred module. * Building the actual module still fails, but make sure it fails for the right reason. Split from D100934. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D102491
This patch adds support for inferred modules to the dependency scanner. Effectively a cherry-pick of swiftlang/llvm-project#699 authored by @Bigcheese with libclang and other changes omitted. Contains following changes: 1. [Clang][ScanDeps] Ignore __inferred_module.map dependency. * This shows up with inferred modules, but it doesn't exist on disk, so don't report it as a dependency. 2. [Clang][ScanDeps] Use the module map a module was inferred from for inferred modules. Also includes a smoke test that uses clang-scan-deps output to perform an explicit build. There's no intention to duplicate whatever `test/Modules` contains, just to verify the produced command-line does "work" (with very loose definition of work). Split from D100934. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D102495
This patch enables explicitly building inferred modules. Effectively a cherry-pick of swiftlang/llvm-project#699 authored by @Bigcheese with libclang and dependency scanner changes omitted. Contains the following changes: 1. [Clang] Fix the header paths in clang::Module for inferred modules. * The UmbrellaAsWritten and NameAsWritten fields in clang::Module are a lie for framework modules. For those they actually are the path to the header or umbrella relative to the clang::Module::Directory. * The exception to this case is for inferred modules. Here it actually is the name as written, because we print out the module and read it back in when implicitly building modules. This causes a problem when explicitly building an inferred module, as we skip the printing out step. * In order to fix this issue this patch adds a new field for the path we want to use in getInputBufferForModule. It also makes NameAsWritten actually be the name written in the module map file (or that would be, in the case of an inferred module). 2. [Clang] Allow explicitly building an inferred module. * Building the actual module still fails, but make sure it fails for the right reason. Split from D100934. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D102491 llvm-monorepo: d3676d4b666ead794fc58bbc7e07aa406dcf487a
This patch adds support for inferred modules to the dependency scanner. Effectively a cherry-pick of swiftlang/llvm-project#699 authored by @Bigcheese with libclang and other changes omitted. Contains following changes: 1. [Clang][ScanDeps] Ignore __inferred_module.map dependency. * This shows up with inferred modules, but it doesn't exist on disk, so don't report it as a dependency. 2. [Clang][ScanDeps] Use the module map a module was inferred from for inferred modules. Also includes a smoke test that uses clang-scan-deps output to perform an explicit build. There's no intention to duplicate whatever `test/Modules` contains, just to verify the produced command-line does "work" (with very loose definition of work). Split from D100934. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D102495 llvm-monorepo: 1d9e8e13dd7b3204fa51ada17d1608bdbd1bed66
This adds an experimental C API to
clang-scan-deps
and implements enough to build the Foundation module and everything it depends on. See individual commit messages for details.