Commit Graph

356 Commits

Author SHA1 Message Date
Alexis Laferrière
a4becdac81 [Serialization] Load swiftmodule files as volatile to avoid mmap
Avoid mmaping swiftmodule files to hopefully fix issues seen when
building many Swift projects in parallel on NFS. This only affects
loading ModuleFile, it doesn't affect scanning swiftmodule for
dependecies which are still handled as non-volatile.

rdar://63755989
2020-07-21 10:32:16 -07:00
Nathan Hawes
9d4ed5f39c Manually merge remote-tracking branch 'upstream/master' into manually-merge-master-to-master-rebranch 2020-07-20 16:09:55 -07:00
Nathan Hawes
244dc4a768 [AST] Rename PlatformKind::OSX to PlatformKind::macOS
Because the names are coming from a .def file used for printing too, this
simplifies the printing logic as well.
2020-07-08 16:29:31 -07:00
Argyrios Kyrtzidis
99c29145b2 [Serialization] Refactor subset of ModuleFile into ModuleFileSharedCore
The difference with `ModuleFile` is that `ModuleFileSharedCore` provides immutable data and is independent of a particular ASTContext.
It is designed to be able to be shared across multiple `ModuleFile`s of different `ASTContext`s in a thread-safe manner.
2020-07-06 00:44:36 -07:00
swift_jenkins
d883300bc1 Merge remote-tracking branch 'origin/master' into master-next 2020-07-01 17:59:25 -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
swift_jenkins
75bea14185 Merge remote-tracking branch 'origin/master' into master-next 2020-06-23 10:39:14 -07:00
Robert Widmann
0da060e95e Merge pull request #32447 from martinboehme/option-set-initializer-list
Give OptionSet an initializer_list constructor
2020-06-23 10:36:57 -07:00
Martin Boehme
d806ba53f6 Give OptionSet an initializer_list constructor.
This makes it easier to specify OptionSet arguments.

Also modify appropriate uses of ModuleDecl::ImportFilter to take
advantage of the new constructor.
2020-06-22 06:57:29 +02:00
swift_jenkins
20ba5d3171 Merge remote-tracking branch 'origin/master' into master-next 2020-06-16 21:38:08 -07:00
Robert Widmann
057097a6c3 [NFC] Hide LoadedModules From Clients of ASTContext
There's no reason clients need to be able to access this data directly.
It obscures where module loading is actually happening, and makes it too
easy to accidentally register a module with the wrong identifier in the
context.

Hide the registration operations behind opaque accessors.
2020-06-16 15:09:19 -07:00
swift_jenkins
48530ac212 Merge remote-tracking branch 'origin/master' into master-next 2020-06-10 10:39:00 -07:00
Arnold Schwaighofer
825a2a259b Mark non-foreign entry points of @objc dynamic methods in generic classes dynamically_replaceable
```
class Generic<T> {
  @objc dynamic func method() {}
}

extension Generic {
  @_dynamicReplacement(for:method())
  func replacement() {}
}
```

The standard mechanism of using Objective-C categories for dynamically
replacing @objc methods in generic classes does not work.

Instead we mark the native entry point as replaceable.

Because this affects all @objc methods in generic classes (whether there
is a replacement or not) by making the native entry point
`[dynamically_replaceable]` (regardless of optimization mode) we guard this by
the -enable-implicit-dynamic flag because we are late in the release cycle.

* Replace isNativeDynamic and isObjcDynamic by calls to shouldUse*Dispatch and
  shouldUse*Replacement
  This disambiguates between which dispatch method we should use at call
  sites and how these methods should  implement dynamic function
  replacement.

* Don't emit the method entry for @_dynamicReplacement(for:) of generic class
  methods
  There is not way to call this entry point since we can't generate an
  objective-c category for generic classes.

rdar://63679357
2020-06-09 09:23:29 -07:00
Karoy Lorentey
57ea964f2c Merge commit '3eb82c183662945687f48e11c09828f551b34858' into master-next
# Conflicts:
#	include/swift/Frontend/FrontendInputsAndOutputs.h
2020-06-08 16:58:37 -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
swift_jenkins
47c0e4c987 Merge remote-tracking branch 'origin/master' into master-next 2020-06-01 11:55:33 -07:00
Alexis Laferrière
21bf781067 Merge pull request #32049 from xymus/spi-unique-imports
[ModuleInterface] Print the SPI attribute only once per group and import
2020-06-01 11:24:21 -07:00
swift_jenkins
305cbfeba3 Merge remote-tracking branch 'origin/master' into master-next 2020-05-28 18:58:45 -07:00
Hamish Knight
439c1481be Assert that an added file loaded without error 2020-05-28 15:19:19 -07:00
Hamish Knight
6477cc68eb [Serialization] Delay adding ModuleFiles until they're loaded
Rather than adding a ModuleFile to a parent module
and then removing it afterwards if it fails to
load, let's wait until we've loaded the file before
deciding to add it to the parent module. This then
allows us to get rid of `ModuleDecl::removeFile`.

In addition, push down the calls to `addFile` into
the callers of `loadAST` in preparation for
`addFile` being replaced with a one-time-only call
to a `setFiles` method.
2020-05-28 12:09:10 -07:00
Hamish Knight
f810cfcc45 [Serialization] Remove treatAsPartialModule parameter
This information can be derived from whether we're
installing the module file into the main module.
2020-05-28 12:09:10 -07:00
Alexis Laferrière
8fefdece2c Use a SetVector when looking up the SPI attributes on imports
Using a SetVector fixes an issue where many source files imported the
same SPI group from the same module, the emitted private textual
interfaces superfluously repeated the `@_spi` attribute on the import.

rdar://problem/63681845
2020-05-27 16:11:12 -07:00
swift_jenkins
4cdb7fa2c8 Merge remote-tracking branch 'origin/master' into master-next 2020-05-19 07:58:16 -07:00
Saleem Abdulrasool
a5646e1351 Serialization: permit the directory layout on non-Apple targets
Permit the directory style `.swiftmodule` on non-Apple targets.  This
allows all platforms to use the directory layout enabling
multi-architecture SDKs.  This not only unifies the layout of the SDK
across the various targets, it also enables Windows to have a single
unified SDK.

The complexity here is due to the compatibility for older layouts.  This
change does not break compatibility on Linux/Android/Windows for the old
style layout.
2020-05-18 08:55:50 -07:00
swift_jenkins
9b6f01b6d9 Merge remote-tracking branch 'origin/master' into master-next 2020-04-30 20:37:34 -07:00
Daniel Sweeney
ea526c6383 Converting ModuleDecl::ImportedModule from std::pair to a dedicated struct. (#31360) 2020-04-30 20:26:03 -07:00
swift_jenkins
c6d56ba570 Merge remote-tracking branch 'origin/master' into master-next 2020-04-30 15:57:39 -07:00
Hamish Knight
b6150b06b3 [Serialization] Remove duplicated IsSIB bit
Store the bit on the ModuleFile, and query it
from the SerializedASTFile.
2020-04-30 14:17:29 -07:00
swift_jenkins
ed20b9c058 Merge remote-tracking branch 'origin/master' into master-next 2020-04-24 23:58:13 -07:00
Doug Gregor
172c0472f6 Merge pull request #28515 from DougGregor/fast-dependency-scanning
Fast dependency scanning for Swift
2020-04-24 23:54:06 -07:00
swift_jenkins
df6fe6509c Merge remote-tracking branch 'origin/master' into master-next 2020-04-24 21:20:17 -07:00
Brent Royal-Gordon
e7bd60494a Revert "[ModuleLoader] Emit a better diagnostic for swiftinterfaces with wrong arch."
This reverts commit 412ee0a922.
2020-04-24 13:45:05 -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
swift_jenkins
dae7b2425d Merge remote-tracking branch 'origin/master' into master-next 2020-04-23 19:39:25 -07:00
Nathan Hawes
083e95ca9d Merge pull request #31227 from nathawes/cross-import-tooling-fixes
[IDE][AST] Handle frameworks with traditional overlays where the underlying module declares cross imports in sourcekit
2020-04-23 19:28:28 -07:00
Nathan Hawes
b7ac8f87b1 [IDE][AST] Handle frameworks with traditional overlays where the underlying module declares cross imports in sourcekit.
We weren't handling this case, so their generated interfaces / doc info
wouldn't include symbols from the cross-import overlays, and we wouldn't
map the underscored cross-import overlay name back to the declaring
framework's name in cusor-info, completion results or when indexing.

Resolves rdar://problem/62138551
2020-04-23 13:03:59 -07:00
swift_jenkins
01ac52612f Merge remote-tracking branch 'origin/master' into master-next 2020-04-23 07:59:46 -07:00
Varun Gandhi
9c1615c761 Merge pull request #31196 from varungandhi-apple/vg-remove-arm64e-fallback
Remove fallback for arm64e -> arm64.
2020-04-23 07:57:55 -07:00
Varun Gandhi
412ee0a922 [ModuleLoader] Emit a better diagnostic for swiftinterfaces with wrong arch.
Before this change, we would emit the warning only for swiftmodules; however,
it may be the case that only a swiftinterface (of a different arch) is present
but no swiftmodule is present.

Fixes rdar://problem/50905075.
2020-04-22 23:58:54 -07:00
Varun Gandhi
c4134ca452 [ModuleInterface] Remove fallback behavior for arm64e -> arm64.
Addresses rdar://problem/61407215.
2020-04-22 23:58:33 -07:00
swift_jenkins
e44d529e6b Merge remote-tracking branch 'origin/master' into master-next 2020-04-20 08:37:18 -07:00
Max Desiatov
5a2b42d054 [NFC] Fix typo in SerializedModuleLoader.cpp 2020-04-20 14:27:02 +01:00
swift_jenkins
340839a81d Merge remote-tracking branch 'origin/master' into master-next 2020-03-27 12:19:29 -07:00
Hamish Knight
6f212634c8 Add getOperatorDecls to FileUnit and ModuleDecl
Query the SourceLookupCache for the operator decls,
and use ModuleDecl::getOperatorDecls for both
frontend stats and to clean up some code
completion logic.

In addition, this commit switches getPrecedenceGroups
over to querying SourceLookupCache.
2020-03-27 09:44:55 -07:00
swift_jenkins
e4ce785e76 Merge remote-tracking branch 'origin/master' into master-next 2020-03-27 06:42:06 -07:00
Dan Zheng
28315487dc [AutoDiff upstream] Serialize derivative function configurations. (#30672)
Serialize derivative function configurations per module.

`@differentiable` and `@derivative` attributes register derivatives for
`AbstractFunctionDecl`s for a particular "derivative function configuration":
parameter indices and dervative generic signature.

To find `@derivative` functions registered in other Swift modules, derivative
function configurations must be serialized per module. When configurations for
a `AbstractFunctionDecl` are requested, all configurations from imported
modules are deserialized. This module serialization technique has precedent: it
is used for protocol conformances (e.g. extension declarations for a nominal
type) and Obj-C members for a class type.

Add `AbstractFunctionDecl::getDerivativeFunctionConfigurations` entry point
for accessing derivative function configurations.

In the differentiation transform: use
`AbstractFunctionDecl::getDerivativeFunctionConfigurations` to implement
`findMinimalDerivativeConfiguration` for canonical derivative function
configuration lookup, replacing `getMinimalASTDifferentiableAttr`.

Resolves TF-1100.
2020-03-27 06:40:27 -07:00
swift_jenkins
4ccdfa27aa Merge remote-tracking branch 'origin/master' into master-next 2020-03-23 12:20:10 -07:00
Hamish Knight
cc9c851856 Add direct operator lookup requests
Introduce DirectOperatorLookupRequest &
DirectPrecedenceGroupLookupRequest that lookup
operator and precedence groups within a given
file or module without looking through imports.

These will eventually be used as the basis for the
new operator lookup implementation, but for now
just use them when querying lookup results from
serialized module files.
2020-03-23 09:17:58 -07:00