Commit Graph

63 Commits

Author SHA1 Message Date
Harlan Haskins
67a447f15f [Frontend] Add flag to use hash-based dependencies
Since prebuilt modules are going to use hashes for their dependencies, we need a flag to turn that behavior on. By default, we use modification times.
2019-03-05 11:46:21 -08:00
Harlan Haskins
7d71579950 [Serialization] Allow either hash-based or mtime-based deps
Add a bit to the module to determine whether the dependency’s stored bit pattern is a hash or an mtime.

Prebuilt modules store a hash of their dependencies because we can’t be sure their dependencies will have the same modtime as when they were built.
2019-03-05 11:46:21 -08:00
Bob Wilson
213efe089c Merge commit '06120c9d9d1a28275a0ecd7466775b1d71716be7' into stable-update-5.1 2019-02-17 10:20:59 -08:00
Nathan Hawes
d164c616b4 [ParseableInterface][sourcekitd] Set the DetailedPreprocessorRecord ClangImporter option on the sub invocation if it's set on the parent
In addition to capturing more detailed preprocessor info, the
DetailedPreprocessorRecord option sets the clang module format to 'raw'
rather than the default 'object'. Sourcekitd doesn't link the code
generation libs, which it looks like the default 'object' format requires,
so it sets this option to true. The subinvocation generated when loading a
module from a .swiftinterface file still used the default prior to this
change though, so it would end up crashing sourcekitd.

This change sets the DetailedProccessorRecord option if the DetailedRecord
option is set on the preprocessor options of parent context's clang module
loader. This fixes interface generation crashing for modules that only have
a .swiftinterface file.

rdar://problem/43906499
2019-02-13 14:13:25 -08:00
Nathan Hawes
e146630b63 [ParseableInterface] Fix failing to build a module when the importing file has errors.
We were checking the parent invocation's DiagnosticEnginer rather than the
subinstance's to determine if there were any errors building the module, which
meant we would fail to load the module if there were errors prior to the import
statement in the importing file.

This also meant code completion would fail to load the module, because it always
emits a bogus error in order to mark the AST as erroneous so that different
parts of the compiler (e.g. the verifier) have less strict assumptions.

rdar://problem/43906499
2019-02-12 12:32:32 -08:00
Brent Royal-Gordon
031166e25b Revert "[ParseableInterface] Fix failing to build a module when the importing file has errors." 2019-02-11 15:59:42 -08:00
Bob Wilson
06120c9d9d More fixes in recent Swift changes to work with newer VFS code. 2019-02-08 16:01:41 -08:00
Nathan Hawes
2a746da9bc [ParseableInterface] Fix failing to build a module when the importing file has errors.
We were checking the parent invocation's DiagnosticEnginer rather than the
subinstance's to determine if there were any errors building the module, which
meant we would fail to load the module if there were errors prior to the import
statement in the importing file.

This also meant code completion would fail to load the module, because it always
emits a bogus error in order to mark the AST as erroneous so that different
parts of the compiler (e.g. the verifier) have less strict assumptions.

rdar://problem/43906499
2019-02-08 09:08:27 -08:00
Saleem Abdulrasool
adcdc39791 swift: update for LLVM SVN r344140
Update swift's usage of clang::vfs which has been hoisted into LLVM.
2019-02-07 17:53:42 -08:00
Harlan Haskins
4eafcc9a6f [ParseableInterface] Use arch for cache key instead of full triple
The target triple actually includes too much information -- just use the
target architecture.

rdar://46503065
2019-02-05 15:44:39 -08:00
Harlan Haskins
6ae20a959b [ParseableInterface] Refine cache key for cached swiftmodules
Previously, we included the PCH hash components in the cache key. While they didn’t do any harm, they didn’t contribute any unique information about the module in question.

Additionally, passing the effective language version in means that each dependency that uses a different -swift-version would re-compile all of its dependencies. This is unfortunate, as that means the standard library is recompiled potentially several times.
2019-02-04 14:39:46 -08:00
Harlan Haskins
6f94720b01 [Serialization] Use mtime instead of hash for file dependencies
Hashing the contents of the interface files is overkill. In practice, size and last modification time are enough to determine if a file has changed on disk, and therefore should be rebuilt.
2019-02-04 13:26:38 -08:00
Slava Pestov
81c5a67489 Merge pull request #21758 from pschuh/s-1
Rename NameAliasType to TypeAliasType.
2019-01-10 15:20:41 -05:00
Parker Schuh
f5859ff46e Rename NameAliasType to TypeAliasType. 2019-01-09 16:47:13 -08:00
Jordan Rose
c88c8b5f90 [ParseableInterface] Don't serialize deps for explicit builds
If the frontend is invoked with
-build-module-from-parseable-interface, we might be trying to persist
and distribute the swiftmodule that gets built. In that case, any
dependencies we list might not be relevant.

This probably isn't really the final answer here; what we want is some
way to say /which/ dependencies are relevant, and how they're related
to how the swiftmodule that gets used. Most likely the right answer
here is to limit this to dependencies within the SDK or something.
2018-12-21 15:41:23 -08:00
Jordan Rose
614deb640b [ParseableInterface] Pass prebuilt cache path down to sub-invocations
Otherwise, the top-level compilation gets the benefit of the prebuilt
cache path, but the sub-invocations for swiftinterfaces that /do/
need to be compiled do not.
2018-12-21 15:41:17 -08:00
Jordan Rose
7562137fab [ParseableInterfaces] Move call to helper to the one place it's needed
This is a little trickier than it sounds because we have 'friend'
access into the FrontendInputsAndOutputs structure, which means all
the helpers need to be declared in the header file. But it makes the
two use sites simpler, and does slightly less work in the cache hit
path.
2018-12-21 15:41:10 -08:00
Jordan Rose
5417ca0aa2 [ParseableInterfaces] Handle swiftdoc files correctly
The previous 'openModuleFiles' interface in SerializedModuleLoaderBase
still assumed that swiftmodule files and swiftdoc files would be found
next to each other, but that's not true anymore with
swiftinterfaces-built-to-modules. Give up on this assumption (and on
the minor optimization of passing down a scratch buffer) and split out
the interface into the customization point
'findModuleFilesInDirectory' and the implementation 'openModuleFiles'.
The latter now takes two full paths: one for the swiftmodule, one for
the swiftdoc.
2018-12-21 15:37:32 -08:00
Jordan Rose
1c3d467fe9 [ParseableInterfaces] Use namespace path = llvm::sys::path
Makes this code easier to read. No functionality change.
2018-12-17 18:23:28 -08:00
Jordan Rose
4bfe4eff6d [ParseableInterfaces] Add -prebuilt-module-cache-path to the frontend
When trying to load a swiftinterface, search this directory before
doing all the work of building a swiftmodule.
2018-12-17 18:23:28 -08:00
Jordan Rose
73de196fb5 [ParseableInterface] Accept no space after "swift-module-flags:" (#21334)
I lost about a minute or so to this with a manually-written
swiftinterface, so may as well avoid that problem in the future.
2018-12-17 13:20:24 -08:00
Jordan Rose
37708ede6e Add frontend mode -build-module-from-parseable-interface
Makes it easier to test the caching behavior, and may also be useful
for "prebuilding" swiftinterfaces in the future, or having the Driver
kick off a bunch of separate builds as proper tasks.
2018-12-13 11:18:05 -08:00
Jordan Rose
13c8a75da5 [ParseableInterface] Split up creation of the sub-CompilerInvocation
The goal here is to separate the parts that compute an output file
name from the parts that do the actual compilation, so that we can
test the swiftinterface -> swiftmodule behavior more directly. No
functionality change in this commit; the next will take advantage
of the refactoring.
2018-12-12 19:49:02 -08:00
Slava Pestov
e28b0ec7f3 Frontend: Remove a usage of DeclContext::getGenericParamsOfContext() 2018-12-11 23:55:41 -05:00
Jordan Rose
813316190b [ParseableInterface] Don't require Foundation to use @objc
Deinitializers are always @objc. (Arguably, this makes it unnecessary
to print, but we don't want to do any @objc inference at all in a
swiftinterface.)
2018-12-06 14:57:18 -08:00
Jordan Rose
a51f1dd3d2 [ParseableInterface] Pass down the module name and import source loc
- Use the name for the cached module, so that we don't end up with a
  zillion "x86_64-XXXXXXXX.swiftmodule" files in the cache when we're
  working with architecture-specific swiftmodules.

- Diagnose if the expected name is different from the name specified
  in the swiftinterface.

- Emit all diagnostics at the location of the import, instead of
  without any location at all.
2018-12-06 13:33:07 -08:00
Harlan Haskins
3716858d81 Merge pull request #20936 from harlanhaskins/optimus-prime
[ParseableInterface] Optimize parseable modules
2018-12-03 18:30:07 -08:00
Jordan Rose
f8852c97de [ParseableInterface] Don't serialize all SIL like a SIB file (#20976)
This would break resilience, which makes a distinction between "SIL
only inside the module, which is inside the resilience domain" and
"SIL we're going to serialize, which is outside the resilience
domain".
2018-12-03 18:29:48 -08:00
Harlan Haskins
95a17b5afe [ParseableInterface] Optimize parseable modules
This turns on optimization for speed for modules compiled from interfaces during module loading.
2018-12-03 13:17:35 -08:00
Jordan Rose
1c91dd4933 [ParseableInterface] Include "import Swift" in swiftinterface files (#20935)
Otherwise we've got a problem with modules that use -parse-stdlib but
aren't the stdlib themselves. Ideally we'd /only/ print this in that
case, but we don't have that information at this point in the pipeline
and I'm not sure it would be a good idea to include it in the set of
options we pass through.
2018-11-30 18:07:14 -08:00
Jordan Rose
7d30f9cb1f [ParseableInterface] Fixes and tests for Graydon's fallback work 2018-11-29 11:02:24 -08:00
Graydon Hoare
f7200e87bd [ModuleInterface] <rdar://46081260> Fallback behaviour and testing env vars. 2018-11-28 18:34:41 -08:00
Jordan Rose
0ccfe34513 [ParseableInterface] mkdir -p the module cache before using it
Clang does the same thing for its module cache.
2018-11-28 18:34:41 -08:00
Harlan Haskins
3e15224d0b [ParseableInterface] Serialize module-link-name in binary module
We weren’t serializing the module-link-name before, which was causing link errors when trying to import one of these interfaces from the cache.
2018-11-27 15:17:22 -08:00
Jordan Rose
9f6de1fb8e [ParseableInterface] Don't print conformances from other modules (#20657)
...even if they're depended on by protocols we conform to.
2018-11-26 17:38:24 -08:00
Jordan Rose
f56af4e0af [ParseableInterface] Don't print conformances for non-public types (#20656)
I have nothing to say but "oops".
2018-11-26 11:29:36 -08:00
Graydon Hoare
657543119c [ModuleInterface] Version string (semi)finalization, format version checking. 2018-11-13 13:25:15 -08:00
Graydon Hoare
c6ac3867cd [ModuleInterface] Address review comments. 2018-11-13 13:25:15 -08:00
Graydon Hoare
8959923ac8 [ModuleInterface] Propagate dependencies to outer DependencyTracker for use in .d files. 2018-11-13 13:25:15 -08:00
Graydon Hoare
d44943a482 [ModuleInterface] Include and dedupe (transitive) FILE_DEPENDENCY records from dependencies. 2018-11-13 13:25:15 -08:00
Graydon Hoare
b07425ac1d [ModuleInterface] Switch from mtime to xxhash in FILE_DEPENDENCY records. 2018-11-13 13:25:15 -08:00
Graydon Hoare
8b0b5ad475 [ModuleInterface] Suppress warnings in sub-invocation. 2018-11-13 13:24:23 -08:00
Graydon Hoare
be7fcfdc2d [ModuleInterface] Emit error when we fail to find a dependency. 2018-11-13 13:24:23 -08:00
Graydon Hoare
3aab6fd5f3 [ModuleInterface] Use ForwardingDiagnosticConsumer in sub-instance. 2018-11-13 13:24:23 -08:00
Jordan Rose
ff7d03fbd1 [ParseableInterfaces] Handle unsatisfiable conditional conformances (#20433)
...by printing them with a dummy, unsatisfiable condition. This
happens when a public type conforms to a public protocol with
non-public conditions; the conformance can't be used in inlinable
code, but neither is it okay for a client to declare their own
conformance (constrained or unconstrained).

rdar://problem/45657450
2018-11-09 08:28:49 -08:00
Jordan Rose
4d041a360a [ParseableInterface] Print protocols inherited through private protos (#20169)
In this code:

    private protocol MyProto: Hashable {}
    public struct MyStruct: MyProto {}

Being Hashable is part of MyStruct's public API, even though it's not
written explicitly. If we're not going to require people to write it
explicitly, we need to make sure it gets printed.

rdar://problem/44662501
2018-11-08 10:33:42 -08:00
Graydon Hoare
0a3bd3eae9 [ModuleInterface] Address more review comments. 2018-11-01 21:17:09 -07:00
Graydon Hoare
fc4510e2b8 [ModuleInterface] Make up-to-date check recursive, since it runs first. 2018-11-01 10:51:44 -07:00
Graydon Hoare
9b258192de [ModuleInterface] Add more debug logging. 2018-11-01 10:51:44 -07:00
Graydon Hoare
6cb7b46f39 [ModuleInterface] Set EnableParseableModuleInterface in sub-instance. 2018-11-01 10:51:44 -07:00