Commit Graph

115 Commits

Author SHA1 Message Date
Xi Ge
056f00322d DependenciesScanner: refactor cross import overlay resolver to a standalone function. NFC
This change facilitates resolving cross-import overlays from transitive dependencies.
2020-07-23 17:47:47 -07:00
Artem Chikin
9ee4ebf507 [Dependency Scanner] Use pragma clang module import in the hack file used to invoke the clang dependency scanner.
Using `@import` does not woth in C-mode(`-disable-objc-interop`), so C modules cannot be found in this mode.
This also means the dependency scanner is not able to invoke the Clang dependency scanner tool on Linux at all.
2020-06-29 13:44:02 -07:00
Xi Ge
b6a8af599e DependenciesScanner: move -fapinotes-swift-version to extra PCM arguments
Swift interface files may specify the effective language version to use. When building
a PCM loadable for these textual interface files, we should respect the language
version. This patch moves -fapinotes-swift-version from the generic PCM
commands to the extra PCM arguments owned by each loading Swift module.
2020-06-16 11:38:28 -07:00
Xi Ge
00872ba53e DependencyScanner: add a new extraPcmArgs field for each Swift module
Building each Swift module explicitly requires dependency PCMs to be built
with the exactly same deployment target version. This means we may need to
build a Clang module multiple times with different target triples.

This patch removes the -target arguments from the reported PCM build
arguments and inserts extraPcmArgs fields to each Swift module.
swift-driver can combine the generic PCM arguments with these extra arguments
to get the command suitable for building a PCM specifically for
that loading Swift module.
2020-06-16 09:42:59 -07:00
Xi Ge
9e88549199 ModuleInterface: teach module interface building to use explicitly built PCMs 2020-06-02 16:51:45 -07:00
Xi Ge
1ae70a5b26 DependenciesScanner: avoid reporting output file path because build system should specify it 2020-06-02 16:51:45 -07:00
Matt Davis
765c3cedf6 [clangimporter] Fix a StringRef to std::string conversion.
Explictly call StringRef::str, the implicit conversion operator was
removed in an earlier commit:
(See https://github.com/llvm/llvm-project/commit/adcd02683856c)
2020-05-28 08:34:38 -07:00
Xi Ge
38c0452d65 DependenciesScanner: report command-line arguments for building pcm explicitly 2020-05-22 07:50:08 -07:00
Xi Ge
3952fd5bf7 ModuleInterface: refactor compiler instance configuration to a standalone delegate class. NFC
Module interface builder used to maintain a separate compiler instance for
building Swift modules. The configuration of this compiler instance is also
useful for dependencies scanner because it needs to emit front-end compiler invocation
for building Swift modules explicitly.

This patch refactor the configuration out to a delegate class, and the
delegate class is also used by the dependency scanner.
2020-05-12 16:19:27 -07:00
Xi Ge
9bc036c050 DependencyScanner: honor additional compiler flags in interfaces files when collecting imports
Additional flags in interface files may change parsing behavior like #if
statements. We should use a fresh ASTContext with these additional
flags when parsing interface files to collect imports.

rdar://62612027
2020-05-04 22:18:11 -07:00
Michael Forster
4852210fd5 More StringRef->std::string conversion fixes 2020-04-29 17:40:51 +02:00
Doug Gregor
6b5e7efc0e [Dependency scanner] Capture Clang context hash and command-line arguments. 2020-04-24 12:58:45 -07:00
Doug Gregor
fdfadf8363 [Dependency scanner] Get the Clang module file name from Clang. 2020-04-24 12:58:45 -07:00
Doug Gregor
d6484c8280 [Dependency scanning] Scan and record bridging header dependencies.
When there is a bridging header associated with the module, scan and record
its dependencies. Note them in a separate structure to capture the specific
dependencies of the bridging header.
2020-04-24 12:58:45 -07:00
Doug Gregor
33cdd61835 Fast dependency scanning for Swift
Implement a new "fast" dependency scanning option,
`-scan-dependencies`, in the Swift frontend that determines all
of the source file and module dependencies for a given set of
Swift sources. It covers four forms of modules:

1) Swift (serialized) module files, by reading the module header
2) Swift interface files, by parsing the source code to find imports
3) Swift source modules, by parsing the source code to find imports
4) Clang modules, using Clang's fast dependency scanning tool

A single `-scan-dependencies` operation maps out the full
dependency graph for the given Swift source files, including all
of the Swift and Clang modules that may need to be built, such
that all of the work can be scheduled up front by the Swift
driver or any other build system that understands this
option. The dependency graph is emitted as JSON, which can be
consumed by these other tools.
2020-04-24 12:58:41 -07:00