Commit Graph

61 Commits

Author SHA1 Message Date
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
1c1a263315 Factor out Explicit Module Map parsing into a standalone utility. 2020-07-27 09:24:35 -07:00
Xi Ge
9a33ac63a5 ExplicitModuleLoader: teach the module loader to accept forwarding modules
Since -emit-module-from-interface now emits forwarding modules, explicit module
loader should be able to accept forwarding modules and unbox their actual binary
contents.
2020-07-19 16:12:08 -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
Xi Ge
a5ad5eb54c ModuleInterface: refactor a utility function out for collecting candidate compiled modules. NFC
The compiled module is either adjacent to the interface file or in prebuilt module cache directory.
2020-07-16 15:47:07 -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
d2bf4473ae Revert "ModuleLoader: refactor computePrebuiltModulePath to facilitate dependencies scanner's invocation, NFC" 2020-07-01 09:53:58 -07:00
Hamish Knight
7bc5440d17 [Frontend] Internalize createDependencyTracker
Expand the FrontendOptions to allow the enabling
of the dependency tracker for non-system
dependencies, and switch the previous clients of
`createDependencyTracker` over to using this
option. This ensures that the dependency tracker
is now set only during `CompilerInstance::setup`.
2020-06-29 15:26:26 -07:00
Xi Ge
0816167abd Merge pull request #32564 from nkcsgexi/scanner-report-prebuilt-module
ModuleLoader: refactor computePrebuiltModulePath to facilitate dependencies scanner's invocation, NFC
2020-06-26 18:04:10 -07:00
Xi Ge
a5369475ab ModuleLoader: refactor computePrebuiltModulePath to facilitate dependencies scanner's invocation, NFC 2020-06-26 15:01:19 -07:00
Xi Ge
fb99e840cc ExplicitModuleLoader: use a temporary source manager for loading the explicit module map, NFC
We don't need the buffer for the explicit module map to be persistent in the ASTContext.
2020-06-26 14:44:20 -07:00
Xi Ge
05de54f635 ExplicitModules: use key names conforming to Swift naming convention in explicit Swift module maps. NFC 2020-06-22 22:22:05 -07:00
Xi Ge
0fd75b4eb9 ExplictModuleLoader: don't fail while no explicit Swift module map is specified
We will eventually move the protocol entirely to using a JSON file for
explicit Swift modules. Before we finish migrating, we should be forgiving
about using the legacy -swift-module-file argument.
2020-06-19 10:23:43 -07:00
Xi Ge
23ef061b14 ExplictModuleLoader: update acceptable JSON format to be more Codable friendly
Explicit Swift module map will be constructed from the swift-driver side using
the Codable protocol. We should change the format to facilitate that.
2020-06-18 10:44:36 -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
Alexis Laferrière
1c8ad2f615 Merge pull request #32423 from xymus/module-loading-order
[ModuleInterface] Prefer the swiftmodule in the SDK over the prebuilt-cache
2020-06-17 11:27:29 -07:00
Alexis Laferrière
b4f2e63df8 [ModuleInterface] Prefer the swiftmodule in the SDK over the prebuilt-cache
Fix the search order for module interfaces to respect the documented
behavior:

1. Local cache
2. Next to the .swiftinterface
3. Prebuilt cache

Fixing the order of the last two allows the XcodeDefault compiler to
prioritize swiftmodule files with SPI information.

rdar://problem/64097455
2020-06-17 08:36:08 -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
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
Karoy Lorentey
68351d2110 Revert "Merge remote-tracking branch 'origin/master-next'"
This reverts commit 1c9b0908e6, reversing
changes made to 3eb82c1836.
2020-06-08 16:48:38 -07:00
Karoy Lorentey
1c9b0908e6 Merge remote-tracking branch 'origin/master-next'
# Conflicts:
#	include/swift/Frontend/FrontendInputsAndOutputs.h
2020-06-08 16:43:40 -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
0d74428575 Front-end: use separate flag for -swift-module-file instead of EQ 2020-06-02 16:51:45 -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
1ae70a5b26 DependenciesScanner: avoid reporting output file path because build system should specify it 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
swift_jenkins
68af9d595b Merge remote-tracking branch 'origin/master' into master-next 2020-05-22 20:18:30 -07:00
Xi Ge
38c0452d65 DependenciesScanner: report command-line arguments for building pcm explicitly 2020-05-22 07:50:08 -07:00
Erik Eckstein
82a006be26 Merge remote-tracking branch 'origin/master' into master-next 2020-05-16 10:26:27 +02:00
Xi Ge
7d08a24161 ModuleInterface: reconstruct command-line arguments for building Swift module from interface explicitly 2020-05-15 10:49:45 -07:00
Arnold Schwaighofer
622fee54a7 Another std::string StringRef assignment. 2020-05-13 07:35:11 -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
Fred Riss
259d78a350 Adapt to llvm.org StringRef API change 2020-03-13 19:08:22 +01: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
Alexis Laferrière
ffa0bda67e [Frontend] Use the private module interface when available 2020-02-19 14:17: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
Xi Ge
e1f6e846ca Re-apply "ModuleInterface: lock .swiftinterface while generating module cache" 2020-01-10 12:25:15 -08:00
Mishal Shah
c769e491e2 Revert "ModuleInterface: lock .swiftinterface while generating module cache" 2020-01-09 22:54:41 -08:00
Xi Ge
a8baeb3670 Merge pull request #29101 from nkcsgexi/lock-interface-gen-module
ModuleInterface: lock .swiftinterface while generating module cache
2020-01-09 17:41:20 -08:00
Xi Ge
8dda0193a6 ModuleInterface: lock .swiftinterface while generating module cache
This ensures only one process is generating module cache from an interface
file so that we don't blow up memory usage when multiple processes are
doing the same. The locking mechanism is similar to that of Clang's.

A better approach is that the build system takes care of the module building
step as a formal dependency.

rdar://52839445
2020-01-09 15:45:48 -08:00
Kita, Maksim
ea6a2dc094 SR-11889: Fixed code review issues
1. Updated Located field names with Pascal Case
2. Updated Located constuctor
3. Formatted lines with more than 80 symbols
2019-12-20 17:18:59 +03:00
Kita, Maksim
b7cb3b67bf SR-11889: Using Located<T> instead of std::pair<SourceLoc, T> 2019-12-20 17:18:58 +03: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