Commit Graph

421 Commits

Author SHA1 Message Date
Xi Ge
e107182f1a Merge remote-tracking branch 'apple/master' into master-rebranch 2020-09-02 18:36:37 -07:00
Rintaro Ishizaki
aa48494c74 [Serialization] Local allocate ModuleFileSharedCore.ModuleInterfacePath
'ModuleInterfacePath' is passed as 'StringRef' that memory used to
reside in ASTContext. But 'ModuleFileSharedCore' should be 'ASTContext'
independent. So copy it using its own allocator.
2020-09-02 12:52:14 -07:00
Nathan Hawes
f0c8b8e571 Manually merge remote-tracking branch 'upstream/master' into HEAD
Conflicts:
	include/swift/AST/PrettyStackTrace.h
2020-08-14 11:06:27 -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
Nathan Hawes
b0a2230860 Manually merge remote-tracking branch 'upstream/master' into merge-in-master 2020-07-27 09:25:01 -07:00
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
swift-ci
cdcf7e3c56 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-07-22 17:04:32 -07:00
Alexis Laferrière
d9a88b948b Merge pull request #33052 from xymus/swiftmodule-files-are-volatile-opt
[Serialization] Move loading swiftmodule files as volatile behind a flag
2020-07-22 16:48:25 -07:00
swift-ci
627ed18e79 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-07-22 12:04:54 -07:00
Alexis Laferrière
2c66f0c75d [Serialization] Move loading swiftmodule files as volatile behind a flag
Introduce a new frontend flag -enable-volatile-modules to trigger
loading swiftmodule files as volatile and avoid using mmap. Revert the
default behavior to using mmap.
2020-07-22 12:04:44 -07:00
Artem Chikin
95c8391cd7 Merge pull request #32903 from artemcm/NoImplicitWhenExplicit
[Explicit Module Builds] Prevent SerializedModuleLoader from running in Explicit Module Build mode.
2020-07-22 11:49:08 -07:00
Artem Chikin
140fd73f83 [Explicit Module Builds] Prevent SerializedModuleLoader from running in Explicit Module Build mode.
In order to avoid accidentally implicitly loading modules that are expected but were not provided as explicit inputs.

- Use either SerializedModuleLoader or ExplicitSwiftModuleLoader for loading of partial modules, depending on whether we are in Explicit Module Build or Implicit Module Build mode.
2020-07-22 09:00:40 -07:00
swift-ci
c22b1f580b Merge remote-tracking branch 'origin/master' into master-rebranch 2020-07-21 16:24:01 -07:00
Alexis Laferrière
0ede7282bb [Serialization] Add more context to why we load swiftmodule files as volatile 2020-07-21 12:17:57 -07:00
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