Commit Graph

43 Commits

Author SHA1 Message Date
Brent Royal-Gordon
cff4ddf13a [NFC] Adopt new ImportPath types and terminology
# Conflicts:
#	lib/IDE/CodeCompletion.cpp
2020-09-10 19:07:49 -07:00
Xi Ge
a4d731ed9f ModuleLoader: remove several walk-arounds for not having a persistent ClangImporterOptions available. NFC 2020-09-02 15:10:50 -07:00
Brent Royal-Gordon
8fbd449501 Merge pull request #33114 from brentdax/check-your-interfaces-at-the-door
Verify that just-emitted module interfaces parse and typecheck
2020-08-24 20:33:58 -07:00
Xi Ge
5c9b737c89 DependenciesScanner: prefer private Swift module interfaces if present
rdar://67257185
2020-08-18 13:09:07 -07:00
Artem Chikin
721f903567 Address code-review feedback for #33430 2020-08-13 13:26:41 -07:00
Artem Chikin
cf773c3d0e [Explicit Module Loader] Refactor ESWL to use findModule instead of findModuleFilesInDirectory
And add isFramework to the Explicit Module Map and its parser.
2020-08-12 12:06:46 -07:00
Artem Chikin
40c1687fd2 [Fast Dependency Scanner] Produce information on whether an explicit module is a framework
In the fast dependency scanner, depending on whether a module intrface was found via the import search path or framework search path, encode into the dependency graph Swift module details, whether a given module is a framework.
2020-08-12 10:12:35 -07:00
Brent Royal-Gordon
9bc787ef5f Add a “typecheck module interface” mode 2020-08-07 16:00:15 -07:00
Xi Ge
f0cf2206a2 DependenciesScanner: add implicitly imported modules to dependencies of Swift module interfaces
Some implicitly imported modules aren't printed in the textual interface file as explicit import,
e.g. SwiftOnoneSupport. We should check implicit imports and add them to the dependency graph.
2020-08-03 14:43:09 -07:00
Xi Ge
bfacad6f43 Front-end: pass down main executable path to the sub-ASTContext for building module interfaces. NFC 2020-07-30 12:17:02 -07:00
Artem Chikin
fd96bbd054 Use .str() when converting StringRef to std::string in ModuleInterfaceLoader 2020-07-29 08:47:26 -07:00
Artem Chikin
70585b4f0f Change ExplicitModuleInfo to have String members instead of StringRef 2020-07-28 15:57:17 -07:00
Artem Chikin
965ca698d5 Add in-source rationale for why Placeholder dependencies are needed. 2020-07-28 11:34:27 -07:00
Artem Chikin
1d49d22574 Keep the memory allocator local to module loaders, instead of module map parser. 2020-07-27 09:24:35 -07:00
Artem Chikin
b85f547b13 Add an external module dependency test 2020-07-27 09:24:35 -07:00
Artem Chikin
1c1a263315 Factor out Explicit Module Map parsing into a standalone utility. 2020-07-27 09:24:35 -07:00
Xi Ge
f9396f2812 ModuleInterface: teach -compile-module-from-interface to emit forwarding module
-compile-module-from-interface action now takes arguments of -candidate-module-file.
If one of the candidate module files is up-to-date, the action emits a forwarding
module pointing to the candidate module instead of building a binary module.
2020-07-18 19:13:47 -07:00
Xi Ge
b93ff79cb0 DependenciesScanner: include compiled module candidates for textual module interface in JSON output
Instead of replacing an interface file with its up-to-date compile module,
the dep-scanner should report potentially up-to-date module candidates either adjacent to
the interface file or in the prebuilt module cache. swift-driver should later pass down
these candidates to -compile-module-from-interface invocation and the front-end job
will check if one of the candidates is ready to use. The front-end job then either emits a forwarding
module to an up-to-date candidate or a binary module.
2020-07-17 12:32:38 -07:00
Artem Chikin
7dd220f5ef Merge pull request #32754 from artemcm/CanImportExplicitly
[Explicit Module Builds] Add canImport functionality to the ExplicitSwiftModuleLoader
2020-07-09 16:06:40 -07:00
Artem Chikin
f361b250de [Explicit Module Builds] Add canImport functionality to the ExplicitSwiftModuleLoader
It needs to check against the provided ExplicitModuleMap instead of looking into search paths.
2020-07-08 10:11:49 -07:00
Xi Ge
84dd4db0b1 Dependencies Scanner: report compiled Swift module paths if they are available
For the explicit module mode, swift-driver uses -compile-module-from-interface to
generate modules from interfaces found by the dependency scanner. However, we don't
need to build the binary module if up-to-date modules are available, either adjacent
to the interface file or in the prebuilt module cache directory. This patch teaches
dependencies scanner to report these ready-to-use binary modules.
2020-07-01 11:54:15 -07:00
Xi Ge
ec9cd91c1b ExplicitModuleLoader: take a JSON file that specifies details of explicit Swift modules
Instead of taking paths of Swift module files from front-end command line
arguments, we should take a JSON file specifying details of explicit modules.
The advantages is (1) .swiftdoc and .swiftsourceinfo can be associated
with a .swiftmodule file, and (2) module names are explicitly used as
keys in the JSON input so we don't need to eagerly deserialize a .swiftmodule
file to collect the module name.
2020-06-17 14:02:50 -07:00
Robert Widmann
260b6a1e2f Merge pull request #32409 from CodaFi/fixing-a-whole-where-the-rain-gets-in
Build Module Interfaces in WMO
2020-06-16 21:18:49 -07:00
Robert Widmann
0ca2399cab Build Module Interfaces in WMO
Building in incremental mode incurs the overhead associated with the
incremental dependency tracking infrastructure. Considering we're
throwing away all of this stuff anyways, let's just build in WMO to
avoid that.
2020-06-16 11:48:56 -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
bd782be654 Front-end: add a new module loader that loads explicitly built Swift modules
To support -disable-implicit-swift-modules, the explicitly built modules
are passed down as compiler arguments. We need this new module loader to
handle these modules.

This patch also stops ModuleInterfaceLoader from building module from interface
when -disable-implicit-swift-modules is set.
2020-06-03 18:59:18 -07:00
Xi Ge
01c18d01c1 Frontend: move ExplicitSwiftModules into SearchPathOptions, NFC 2020-06-02 16:51:45 -07:00
Xi Ge
38b3d81905 ModuleInterface: pass-down explicit Swift module paths when building module from interface 2020-06-02 16:51:45 -07:00
Xi Ge
28b0b22a42 ModuleInterface: refactor several configuration values into an Option struct 2020-06-02 16:51:45 -07:00
Xi Ge
3a214d99f6 Frontend: add an argument to disable implicitly built Swift modules 2020-06-02 16:51:45 -07:00
Xi Ge
38c0452d65 DependenciesScanner: report command-line arguments for building pcm explicitly 2020-05-22 07:50:08 -07:00
Xi Ge
7d08a24161 ModuleInterface: reconstruct command-line arguments for building Swift module from interface explicitly 2020-05-15 10:49:45 -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
3cb8d8e814 DependencyScanner: inherit ASTContext options when configuring a sub compiler instance for interface scanner. NFC 2020-05-05 11:29:12 -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
Xi Ge
8c2a041822 Front-end: add an option to not lock interface file when building module
This could help fix a flaky test.

Related to: rdar://58578342
2020-02-25 12:13:14 -08:00
Brent Royal-Gordon
e4c1de675a [NFC-ish] Simplify module loader filename handling (#29295)
* Remove dead ModuleSourceInfoFilename parameters

These were never actually used; we might find a way to bring them back later.

* Introduce SerializedModuleBaseName

This is intended to replace the _n_ filename parameters that tend to get passed around in the SerializedModuleLoader classes.

* Manipulate currPath in SerializedModuleLoader less often

* Don’t pass raw paths around SerializedModuleLoader

Only pass base names.

* Regularize module file opening functions
2020-01-21 13:02:20 -08:00
Varun Gandhi
68a68cb564 Merge pull request #27635 from varungandhi-apple/vg-robustify-module-trace-emission
Make module trace emission more robust.
2019-10-15 20:45:04 -07:00
Varun Gandhi
903add2c3f [Frontend] Make the module trace emission more robust.
✔ More informative error messages in case of crashes.
✔ Handling and documenting different cases.
✔ Test cases for different cases.
✔ Make SDKDependencies.swift pass again.
2019-10-15 15:44:26 -07:00
Xi Ge
0a396ab38f Front-end: add an option to ignore .swiftsourceinfo file for testing purposes
We generate .swiftsourceinfo for stdlib in the build directory because ABI checker
could issue diagnostics to the stdlib source. However, this may also change other
diagnostic tests. Both Brent and Jordan have raised concern about this. After
adding this flag, other diagnostic tests could ignore .swiftsourceinfo files even
though when they are present so our tests will reflect what most users experience
when sources for stdlib are unavailable.
2019-10-15 10:52:46 -07:00
Xi Ge
e9dfdea6fd SerializeLoc: serialize basic decl source location information to .swiftsourceinfo file
After setting up the .swiftsourceinfo file, this patch starts to actually serialize
and de-serialize source locations for declaration. The binary format of .swiftsourceinfo
currently contains these three records:

BasicDeclLocs: a hash table mapping from a USR ID to a list of basic source locations. The USR id
could be retrieved from the following DeclUSRs record using an actual decl USR. The basic source locations
include a file ID and the results from Decl::getLoc(), ValueDecl::getNameLoc(), Decl::getStartLoc() and Decl::getEndLoc().
The file ID could be used to retrieve the actual file name from the following SourceFilePaths record.
Each location is encoded as a line:column pair.

DeclUSRS: a hash table mapping from USR to a USR ID used by location records.

SourceFilePaths: a hash table mapping from a file ID to actual file name.

BasicDeclLocs should be sufficient for most diagnostic cases. If additional source locations
are needed, we could always add new source location records without breaking the backward compatibility.
When de-serializing the source location from a module-imported decl, we calculate its USR, retrieve the USR ID
from the DeclUSRS record, and use the USR ID to look up the basic location list in the BasicDeclLocs record.

For more details about .swiftsourceinfo file: https://forums.swift.org/t/proposal-emitting-source-information-file-during-compilation
2019-10-09 15:29:51 -07:00
Harlan Haskins
c82c9b8210 [ModuleInterfaces] Remove references to 'parseable' interfaces everywhere
Now that we've settled on Module Interface as the name, let's remove the
vestiges of "Parseable Interfaces"
2019-09-13 14:55:48 -07:00
Harlan Haskins
fafc5832fe [ModuleInterfaces] ParseableInterfaceModuleLoader -> ModuleInterfaceLoader
Rename this class to better fit the user-facing name.
2019-09-13 13:40:01 -07:00